{ "manifest": { "name": "rambda", "version": "9.4.2", "scripts": { "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build && yarn create-docsify", "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x && yarn create-docsify:x", "build": "yarn build:main && yarn build:web", "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs", "build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs", "immutable": "cd ../rambda-scripts && yarn immutable:rambda", "immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax", "populatedocs": "cd ../rambda-scripts && yarn populate:docs", "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax", "populatereadme": "cd ../rambda-scripts && yarn populate:readme", "populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax", "test": "jest -o -u --watch", "test:all": "jest source/*.spec.js -u --bail=false", "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1", "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source", "create-docsify": "cd ../rambda-scripts && yarn create-docsify", "create-docsify:x": "cd ../rambda-scripts && yarn create-docsify:rambdax", "ts": "yarn test:typings" }, "depFn": [ "@definitelytyped/dtslint" ], "dependencies": {}, "devDependencies": { "@babel/core": "7.26.0", "@babel/plugin-proposal-object-rest-spread": "7.20.7", "@babel/preset-env": "7.26.0", "@definitelytyped/dtslint": "0.0.182", "@rollup/plugin-babel": "6.0.4", "@rollup/plugin-commonjs": "28.0.1", "@rollup/plugin-node-resolve": "15.3.0", "@rollup/plugin-replace": "6.0.1", "@types/jest": "29.5.14", "combinate": "1.1.11", "cross-env": "7.0.3", "fast-check": "3.23.1", "helpers-fn": "2.0.0", "is-ci": "3.0.1", "jest": "29.7.0", "jest-extended": "4.0.2", "lodash": "4.17.21", "rambdax": "11.2.0", "ramda": "0.30.1", "rollup": "4.28.1", "rollup-plugin-cleanup": "3.2.1", "rollup-plugin-sourcemaps": "0.6.3", "rollup-plugin-uglify": "6.0.4", "types-ramda": "0.30.1", "typescript": "5.7.2" }, "jest": { "testEnvironment": "node", "testRegex": ".*\\.(spec|test)\\.js$", "setupFilesAfterEnv": [ "./files/testSetup.js" ], "collectCoverageFrom": [ "source/*.js", "!_internals", "!benchmarks" ] }, "repository": { "type": "git", "url": "git+https://github.com/selfrefactor/rambda.git" }, "license": "MIT", "author": { "name": "self_refactor" }, "description": "Lightweight and faster alternative to Ramda with included TS definitions", "keywords": [ "ramda", "fp", "functional", "utility", "lodash" ], "homepage": "https://github.com/selfrefactor/rambda#readme", "files": [ "dist", "src", "CHANGELOG.md", "index.d.ts", "immutable.d.ts", "rambda.js", "immutable.js" ], "sideEffects": false, "main": "./dist/rambda.js", "umd": "./dist/rambda.umd.js", "module": "./rambda.js", "types": "./index.d.ts", "_registry": "npm", "_loc": "/home/josie/.cache/yarn/v6/npm-rambda-9.4.2-integrity/node_modules/rambda/package.json", "readmeFilename": "README.md", "readme": "# Rambda\n\n`Rambda` is smaller and faster alternative to the popular functional programming library **Ramda**. - [Documentation](https://selfrefactor.github.io/rambda/#/)\n\n[![codecov](https://codecov.io/gh/selfrefactor/rambda/branch/master/graph/badge.svg)](https://codecov.io/gh/selfrefactor/rambda)\n![Commit activity](https://img.shields.io/github/commit-activity/y/selfrefactor/rambda)\n![Library size](https://img.shields.io/bundlephobia/minzip/rambda)\n[![install size](https://packagephobia.com/badge?p=rambda)](https://packagephobia.com/result?p=rambda)\n[![PR's Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/selfrefactor/rambda/pulls)\n[![GitHub contributors](https://img.shields.io/github/contributors/selfrefactor/rambda.svg)](https://github.com/selfrefactor/rambda/graphs/contributors)\n\n## ❯ Example use\n\n```javascript\nimport { compose, map, filter } from 'rambda'\n\nconst result = compose(\n map(x => x * 2),\n filter(x => x > 2)\n)([1, 2, 3, 4])\n// => [6, 8]\n```\n\nYou can test this example in Rambda's REPL\n\n* [Differences between Rambda and Ramda](#differences-between-rambda-and-ramda)\n* [API](#api)\n* [Changelog](#-changelog)\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-example-use)\n\n## ❯ Rambda's advantages\n\n### TypeScript included\n\nTypeScript definitions are included in the library, in comparison to **Ramda**, where you need to additionally install `@types/ramda`.\n\nStill, you need to be aware that functional programming features in `TypeScript` are in development, which means that using **R.compose/R.pipe** can be problematic.\n\nImportant - Rambda version `7.1.0`(or higher) requires TypeScript version `4.3.3`(or higher).\n\n### Understandable source code due to little usage of internals\n\n`Ramda` uses a lot of internals, which hides a lot of logic. Reading the full source code of a method can be challenging.\n\n### Better VSCode experience\n\nIf the project is written in Javascript, then `go to source definition` action will lead you to actual implementation of the method.\n\n### Immutable TS definitions\n\nYou can use immutable version of Rambda definitions, which is linted with ESLint `functional/prefer-readonly-type` plugin.\n\n```\nimport {add} from 'rambda/immutable'\n```\n\n### Deno support\n\nLatest version of **Ramba** available for `Deno` users is 3 years old. This is not the case with **Rambda** as most of recent releases are available for `Deno` users.\n\nAlso, `Rambda` provides you with included TS definitions:\n\n```\n// Deno extension(https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno)\n// is installed and initialized\nimport * as R from \"https://deno.land/x/rambda/mod.ts\";\nimport * as Ramda from \"https://deno.land/x/ramda/mod.ts\";\n\nR.add(1)('foo') // => will trigger warning in VSCode as it should\nRamda.add(1)('foo') // => will not trigger warning in VSCode\n```\n\n### Dot notation for `R.path`, `R.paths`, `R.assocPath` and `R.lensPath`\n\nStandard usage of `R.path` is `R.path(['a', 'b'], {a: {b: 1} })`.\n\nIn **Rambda** you have the choice to use dot notation(which is arguably more readable):\n\n```\nR.path('a.b', {a: {b: 1} })\n```\n\nPlease note that since path input is turned into array, i.e. if you want `R.path(['a','1', 'b'], {a: {'1': {b: 2}}})` to return `2`, you will have to pass array path, not string path. If you pass `a.1.b`, it will turn path input to `['a', 1, 'b']`.\nThe other side effect is in `R.assocPath` and `R.dissocPath`, where inputs such as `['a', '1', 'b']` will be turned into `['a', 1, 'b']`.\n\n### Comma notation for `R.pick` and `R.omit`\n\nSimilar to dot notation, but the separator is comma(`,`) instead of dot(`.`).\n\n```\nR.pick('a,b', {a: 1 , b: 2, c: 3} })\n// No space allowed between properties\n```\n\n### Speed\n\n**Rambda** is generally more performant than `Ramda` as the [benchmarks](#-benchmarks) can prove that.\n\n### Support\n\nOne of the main issues with `Ramda` is the slow process of releasing new versions. This is not the case with **Rambda** as releases are made on regular basis.\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-rambdas-advantages)\n\n## ❯ Missing Ramda methods\n\n
\n\n Click to see the full list of 46 Ramda methods not implemented in Rambda and their status.\n\n\n- construct - Using classes is not very functional programming oriented.\n- constructN - same as above\n- into - no support for transducer as it is overly complex to implement, understand and read.\n- invert - overly complicated and limited use case\n- invertObj\n- invoker\n- keysIn - we shouldn't encourage extending object with `.prototype` \n- lift\n- liftN\n- mapAccum - `Ramda` example doesn't looks convincing\n- mapAccumRight\n- memoizeWith - hard to imagine its usage in context of `R.pipe`/`R.compose`\n- mergeDeepWith - limited use case\n- mergeDeepWithKey\n- mergeWithKey\n- nAry - hard to argument about and hard to create meaningful TypeScript definitions\n- nthArg - limited use case\n- o - enough TypeScript issues with `R.pipe`/`R.compose` to add more composition methods\n- otherwise - naming is confusing\n- pair - `left-pad` types of debacles happens partially because of such methods that should not be hidden, bur rather part of your code base even if they need to exist.\n- partialRight - I dislike `R.partial`, so I don't want to add more methods that are based on it\n- pipeWith\n- project - naming is confusing, but also limited use case\n- promap\n- reduceRight - I find `right/left` methods confusing so I added them only where it makes sense.\n- reduceWhile - functions with 4 inputs - I think that even 3 is too much\n- reduced\n- remove - nice name but it is too generic. Also, `Rambdax` has such method and there it works very differently\n- scan - hard to explain\n- sequence\n- splitWhenever\n- symmetricDifferenceWith\n- andThen\n- toPairsIn\n- transduce - currently is out of focus\n- traverse - same as above\n- unary\n- uncurryN\n- unfold - similar to `R.scan` and I find that it doesn't help with readability\n- unionWith - why it has its usage, I want to limit number of methods that accept more than 2 arguments\n- until\n- useWith - hard to explain\n- valuesIn\n- xprod - limited use case\n- thunkify\n- __ - placeholder method allows user to further customize the method call. While, it seems useful initially, the price is too high in terms of complexity for TypeScript definitions. If it is not easy exressable in TypeScript, it is not worth it as **Rambda** is a TypeScript first library.\n\nThe following methods are not going to be added(reason for exclusion is provided as a comment):\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-missing-ramda-methods)\n \n## ❯ Install\n\n- **yarn add rambda**\n\n- For UMD usage either use `./dist/rambda.umd.js` or the following CDN link:\n\n```\nhttps://unpkg.com/rambda@CURRENT_VERSION/dist/rambda.umd.js\n```\n\n- with deno\n\n```\nimport {add} from \"https://deno.land/x/rambda/mod.ts\";\n```\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-install)\n\n## Differences between Rambda and Ramda\n\n- Rambda's **type** detects async functions and unresolved `Promises`. The returned values are `'Async'` and `'Promise'`.\n\n- Rambda's **type** handles *NaN* input, in which case it returns `NaN`.\n\n- Rambda's **forEach** can iterate over objects not only arrays.\n\n- Rambda's **map**, **filter**, **partition** when they iterate over objects, they pass property and input object as predicate's argument.\n\n- Rambda's **filter** returns empty array with bad input(`null` or `undefined`), while Ramda throws.\n\n- Ramda's **clamp** work with strings, while Rambda's method work only with numbers.\n\n- Ramda's **indexOf/lastIndexOf** work with strings and lists, while Rambda's method work only with lists as iterable input.\n\n- Error handling, when wrong inputs are provided, may not be the same. This difference will be better documented once all brute force tests are completed.\n\n- TypeScript definitions between `rambda` and `@types/ramda` may vary.\n\n> If you need more **Ramda** methods in **Rambda**, you may either submit a `PR` or check the extended version of **Rambda** - [Rambdax](https://github.com/selfrefactor/rambdax). In case of the former, you may want to consult with [Rambda contribution guidelines.](CONTRIBUTING.md)\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-differences-between-rambda-and-ramda)\n\n## ❯ Benchmarks\n\n
\n\n\nClick to expand all benchmark results\n\nThere are methods which are benchmarked only with `Ramda` and `Rambda`(i.e. no `Lodash`).\n\nNote that some of these methods, are called with and without curring. This is done in order to give more detailed performance feedback.\n\nThe benchmarks results are produced from latest versions of *Rambda*, *Lodash*(4.17.21) and *Ramda*(0.30.1).\n\n\n\nmethod | Rambda | Ramda | Lodash\n--- |--- | --- | ---\n *add* | 🚀 Fastest | 21.52% slower | 82.15% slower\n *adjust* | 8.48% slower | 🚀 Fastest | 🔳\n *all* | 🚀 Fastest | 7.18% slower | 🔳\n *allPass* | 🚀 Fastest | 88.25% slower | 🔳\n *allPass* | 🚀 Fastest | 98.56% slower | 🔳\n *and* | 🚀 Fastest | 89.09% slower | 🔳\n *any* | 🚀 Fastest | 92.87% slower | 45.82% slower\n *anyPass* | 🚀 Fastest | 98.25% slower | 🔳\n *append* | 🚀 Fastest | 2.07% slower | 🔳\n *applySpec* | 🚀 Fastest | 80.43% slower | 🔳\n *assoc* | 72.32% slower | 60.08% slower | 🚀 Fastest\n *clone* | 🚀 Fastest | 91.86% slower | 86.48% slower\n *compose* | 6.07% slower | 16.89% slower | 🚀 Fastest\n *converge* | 78.63% slower | 🚀 Fastest | 🔳\n *curry* | 🚀 Fastest | 28.86% slower | 🔳\n *curryN* | 🚀 Fastest | 41.05% slower | 🔳\n *defaultTo* | 🚀 Fastest | 48.91% slower | 🔳\n *drop* | 🚀 Fastest | 82.35% slower | 🔳\n *dropLast* | 🚀 Fastest | 86.74% slower | 🔳\n *equals* | 58.37% slower | 96.73% slower | 🚀 Fastest\n *filter* | 6.7% slower | 72.03% slower | 🚀 Fastest\n *find* | 🚀 Fastest | 85.14% slower | 42.65% slower\n *findIndex* | 🚀 Fastest | 86.48% slower | 72.27% slower\n *flatten* | 🚀 Fastest | 85.68% slower | 3.57% slower\n *ifElse* | 🚀 Fastest | 58.56% slower | 🔳\n *includes* | 🚀 Fastest | 81.64% slower | 🔳\n *indexOf* | 🚀 Fastest | 80.17% slower | 🔳\n *indexOf* | 🚀 Fastest | 82.2% slower | 🔳\n *init* | 🚀 Fastest | 92.24% slower | 13.3% slower\n *is* | 🚀 Fastest | 57.69% slower | 🔳\n *isEmpty* | 🚀 Fastest | 97.14% slower | 54.99% slower\n *last* | 🚀 Fastest | 93.43% slower | 5.28% slower\n *lastIndexOf* | 🚀 Fastest | 85.19% slower | 🔳\n *map* | 🚀 Fastest | 86.6% slower | 11.73% slower\n *match* | 🚀 Fastest | 44.83% slower | 🔳\n *merge* | 🚀 Fastest | 12.21% slower | 55.76% slower\n *none* | 🚀 Fastest | 96.48% slower | 🔳\n *objOf* | 🚀 Fastest | 38.05% slower | 🔳\n *omit* | 🚀 Fastest | 69.95% slower | 97.34% slower\n *over* | 🚀 Fastest | 56.23% slower | 🔳\n *path* | 37.81% slower | 77.81% slower | 🚀 Fastest\n *pick* | 🚀 Fastest | 19.07% slower | 80.2% slower\n *pipe* | 🚀 Fastest | 0.11% slower | 🔳\n *prop* | 🚀 Fastest | 87.95% slower | 🔳\n *propEq* | 🚀 Fastest | 91.92% slower | 🔳\n *range* | 🚀 Fastest | 61.8% slower | 57.44% slower\n *reduce* | 60.48% slower | 77.1% slower | 🚀 Fastest\n *repeat* | 48.57% slower | 68.98% slower | 🚀 Fastest\n *replace* | 33.45% slower | 33.99% slower | 🚀 Fastest\n *set* | 🚀 Fastest | 50.35% slower | 🔳\n *sort* | 🚀 Fastest | 40.23% slower | 🔳\n *sortBy* | 🚀 Fastest | 25.29% slower | 56.88% slower\n *split* | 🚀 Fastest | 55.37% slower | 17.64% slower\n *splitEvery* | 🚀 Fastest | 71.98% slower | 🔳\n *take* | 🚀 Fastest | 91.96% slower | 4.72% slower\n *takeLast* | 🚀 Fastest | 93.39% slower | 19.22% slower\n *test* | 🚀 Fastest | 82.34% slower | 🔳\n *type* | 🚀 Fastest | 48.6% slower | 🔳\n *uniq* | 🚀 Fastest | 84.9% slower | 🔳\n *uniqBy* | 51.93% slower | 🚀 Fastest | 🔳\n *uniqWith* | 8.29% slower | 🚀 Fastest | 🔳\n *uniqWith* | 14.23% slower | 🚀 Fastest | 🔳\n *update* | 🚀 Fastest | 52.35% slower | 🔳\n *view* | 🚀 Fastest | 76.15% slower | 🔳\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-benchmarks)\n\n## ❯ Used by\n\n- [ESLint plugin Mocha](https://www.npmjs.com/package/eslint-plugin-mocha)\n\n- [WatermelonDB](https://github.com/Nozbe/WatermelonDB)\n\n- [Walmart Canada](https://www.walmart.ca) reported by [w-b-dev](https://github.com/w-b-dev) \n\n- [VSCode Slack integration](https://github.com/verydanny/vcslack)\n\n- [Webpack PostCSS](https://github.com/sectsect/webpack-postcss)\n\n- [MobX-State-Tree decorators](https://github.com/farwayer/mst-decorators)\n\n- [Rewrite of the Betaflight configurator](https://github.com/freshollie/fresh-configurator)\n\n- [MineFlayer plugin](https://github.com/G07cha/MineflayerArmorManager)\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-used-by)\n\n## API\n\n### add\n\nIt adds `a` and `b`.\n\nTry this R.add example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#add)\n\n### addIndex\n\nTry this R.addIndex example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#addIndex)\n\n### addIndexRight\n\nSame as `R.addIndex`, but it will passed indexes are decreasing, instead of increasing.\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#addIndexRight)\n\n### adjust\n\n```typescript\n\nadjust(index: number, replaceFn: (x: T) => T, list: T[]): T[]\n```\n\nIt replaces `index` in array `list` with the result of `replaceFn(list[i])`.\n\nTry this R.adjust example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nadjust(index: number, replaceFn: (x: T) => T, list: T[]): T[];\nadjust(index: number, replaceFn: (x: T) => T): (list: T[]) => T[];\n```\n\n
\n\n
\n\nR.adjust source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\nimport { curry } from './curry.js'\n\nfunction adjustFn(\n index, replaceFn, list\n){\n const actualIndex = index < 0 ? list.length + index : index\n if (index >= list.length || actualIndex < 0) return list\n\n const clone = cloneList(list)\n clone[ actualIndex ] = replaceFn(clone[ actualIndex ])\n\n return clone\n}\n\nexport const adjust = curry(adjustFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { add } from './add.js'\nimport { adjust } from './adjust.js'\nimport { pipe } from './pipe.js'\n\nconst list = [ 0, 1, 2 ]\nconst expected = [ 0, 11, 2 ]\n\ntest('happy', () => {})\n\ntest('happy', () => {\n expect(adjust(\n 1, add(10), list\n )).toEqual(expected)\n})\n\ntest('with curring type 1 1 1', () => {\n expect(adjust(1)(add(10))(list)).toEqual(expected)\n})\n\ntest('with curring type 1 2', () => {\n expect(adjust(1)(add(10), list)).toEqual(expected)\n})\n\ntest('with curring type 2 1', () => {\n expect(adjust(1, add(10))(list)).toEqual(expected)\n})\n\ntest('with negative index', () => {\n expect(adjust(\n -2, add(10), list\n )).toEqual(expected)\n})\n\ntest('when index is out of bounds', () => {\n const list = [ 0, 1, 2, 3 ]\n expect(adjust(\n 4, add(1), list\n )).toEqual(list)\n expect(adjust(\n -5, add(1), list\n )).toEqual(list)\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#adjust)\n\n### all\n\n```typescript\n\nall(predicate: (x: T) => boolean, list: T[]): boolean\n```\n\nIt returns `true`, if all members of array `list` returns `true`, when applied as argument to `predicate` function.\n\nTry this R.all example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nall(predicate: (x: T) => boolean, list: T[]): boolean;\nall(predicate: (x: T) => boolean): (list: T[]) => boolean;\n```\n\n
\n\n
\n\nR.all source\n\n```javascript\nexport function all(predicate, list){\n if (arguments.length === 1) return _list => all(predicate, _list)\n\n for (let i = 0; i < list.length; i++){\n if (!predicate(list[ i ])) return false\n }\n\n return true\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { all } from './all.js'\n\nconst list = [ 0, 1, 2, 3, 4 ]\n\ntest('when true', () => {\n const fn = x => x > -1\n\n expect(all(fn)(list)).toBeTrue()\n})\n\ntest('when false', () => {\n const fn = x => x > 2\n\n expect(all(fn, list)).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {all} from 'rambda'\n\ndescribe('all', () => {\n it('happy', () => {\n const result = all(\n x => {\n x // $ExpectType number\n return x > 0\n },\n [1, 2, 3]\n )\n result // $ExpectType boolean\n })\n it('curried needs a type', () => {\n const result = all(x => {\n x // $ExpectType number\n return x > 0\n })([1, 2, 3])\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#all)\n\n### allPass\n\n```typescript\n\nallPass(predicates: ((x: T) => boolean)[]): (input: T) => boolean\n```\n\nIt returns `true`, if all functions of `predicates` return `true`, when `input` is their argument.\n\nTry this R.allPass example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nallPass(predicates: ((x: T) => boolean)[]): (input: T) => boolean;\nallPass(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean;\n```\n\n
\n\n
\n\nR.allPass source\n\n```javascript\nexport function allPass(predicates){\n return (...input) => {\n let counter = 0\n while (counter < predicates.length){\n if (!predicates[ counter ](...input)){\n return false\n }\n counter++\n }\n\n return true\n }\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { allPass } from './allPass.js'\n\ntest('happy', () => {\n const rules = [ x => typeof x === 'number', x => x > 10, x => x * 7 < 100 ]\n\n expect(allPass(rules)(11)).toBeTrue()\n\n expect(allPass(rules)(undefined)).toBeFalse()\n})\n\ntest('when returns true', () => {\n const conditionArr = [ val => val.a === 1, val => val.b === 2 ]\n\n expect(allPass(conditionArr)({\n a : 1,\n b : 2,\n })).toBeTrue()\n})\n\ntest('when returns false', () => {\n const conditionArr = [ val => val.a === 1, val => val.b === 3 ]\n\n expect(allPass(conditionArr)({\n a : 1,\n b : 2,\n })).toBeFalse()\n})\n\ntest('works with multiple inputs', () => {\n const fn = function (\n w, x, y, z\n ){\n return w + x === y + z\n }\n expect(allPass([ fn ])(\n 3, 3, 3, 3\n )).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {allPass, filter} from 'rambda'\n\ndescribe('allPass', () => {\n it('happy', () => {\n const x = allPass([\n y => {\n y // $ExpectType number\n return typeof y === 'number'\n },\n y => {\n return y > 0\n },\n ])(11)\n\n x // $ExpectType boolean\n })\n it('issue #642', () => {\n const isGreater = (num: number) => num > 5\n const pred = allPass([isGreater])\n const xs = [0, 1, 2, 3]\n\n const filtered1 = filter(pred)(xs)\n filtered1 // $ExpectType number[]\n const filtered2 = xs.filter(pred)\n filtered2 // $ExpectType number[]\n })\n it('issue #604', () => {\n const plusEq = function(w: number, x: number, y: number, z: number) {\n return w + x === y + z\n }\n const result = allPass([plusEq])(3, 3, 3, 3)\n\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#allPass)\n\n### always\n\nIt returns function that always returns `x`.\n\nTry this R.always example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#always)\n\n### and\n\nLogical AND\n\nTry this R.and example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#and)\n\n### any\n\n```typescript\n\nany(predicate: (x: T) => boolean, list: T[]): boolean\n```\n\nIt returns `true`, if at least one member of `list` returns true, when passed to a `predicate` function.\n\nTry this R.any example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nany(predicate: (x: T) => boolean, list: T[]): boolean;\nany(predicate: (x: T) => boolean): (list: T[]) => boolean;\n```\n\n
\n\n
\n\nR.any source\n\n```javascript\nexport function any(predicate, list){\n if (arguments.length === 1) return _list => any(predicate, _list)\n\n let counter = 0\n while (counter < list.length){\n if (predicate(list[ counter ], counter)){\n return true\n }\n counter++\n }\n\n return false\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { any } from './any.js'\n\nconst list = [ 1, 2, 3 ]\n\ntest('happy', () => {\n expect(any(x => x < 0, list)).toBeFalse()\n})\n\ntest('with curry', () => {\n expect(any(x => x > 2)(list)).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {any} from 'rambda'\n\ndescribe('R.any', () => {\n it('happy', () => {\n const result = any(\n x => {\n x // $ExpectType number\n return x > 2\n },\n [1, 2, 3]\n )\n result // $ExpectType boolean\n })\n\n it('when curried needs a type', () => {\n const result = any(x => {\n x // $ExpectType number\n return x > 2\n })([1, 2, 3])\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#any)\n\n### anyPass\n\n```typescript\n\nanyPass(predicates: ((x: T) => boolean)[]): (input: T) => boolean\n```\n\nIt accepts list of `predicates` and returns a function. This function with its `input` will return `true`, if any of `predicates` returns `true` for this `input`.\n\nTry this R.anyPass example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nanyPass(predicates: ((x: T) => boolean)[]): (input: T) => boolean;\nanyPass(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean;\n```\n\n
\n\n
\n\nR.anyPass source\n\n```javascript\nexport function anyPass(predicates){\n return (...input) => {\n let counter = 0\n while (counter < predicates.length){\n if (predicates[ counter ](...input)){\n return true\n }\n counter++\n }\n\n return false\n }\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { anyPass } from './anyPass.js'\n\ntest('happy', () => {\n const rules = [ x => typeof x === 'string', x => x > 10 ]\n const predicate = anyPass(rules)\n expect(predicate('foo')).toBeTrue()\n expect(predicate(6)).toBeFalse()\n})\n\ntest('happy', () => {\n const rules = [ x => typeof x === 'string', x => x > 10 ]\n\n expect(anyPass(rules)(11)).toBeTrue()\n expect(anyPass(rules)(undefined)).toBeFalse()\n})\n\nconst obj = {\n a : 1,\n b : 2,\n}\n\ntest('when returns true', () => {\n const conditionArr = [ val => val.a === 1, val => val.a === 2 ]\n\n expect(anyPass(conditionArr)(obj)).toBeTrue()\n})\n\ntest('when returns false + curry', () => {\n const conditionArr = [ val => val.a === 2, val => val.b === 3 ]\n\n expect(anyPass(conditionArr)(obj)).toBeFalse()\n})\n\ntest('with empty predicates list', () => {\n expect(anyPass([])(3)).toBeFalse()\n})\n\ntest('works with multiple inputs', () => {\n const fn = function (\n w, x, y, z\n ){\n console.log(\n w, x, y, z\n )\n\n return w + x === y + z\n }\n expect(anyPass([ fn ])(\n 3, 3, 3, 3\n )).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {anyPass, filter} from 'rambda'\n\ndescribe('anyPass', () => {\n it('happy', () => {\n const x = anyPass([\n y => {\n y // $ExpectType number\n return typeof y === 'number'\n },\n y => {\n return y > 0\n },\n ])(11)\n\n x // $ExpectType boolean\n })\n it('issue #604', () => {\n const plusEq = function(w: number, x: number, y: number, z: number) {\n return w + x === y + z\n }\n const result = anyPass([plusEq])(3, 3, 3, 3)\n\n result // $ExpectType boolean\n })\n it('issue #642', () => {\n const isGreater = (num: number) => num > 5\n const pred = anyPass([isGreater])\n const xs = [0, 1, 2, 3]\n\n const filtered1 = filter(pred)(xs)\n filtered1 // $ExpectType number[]\n const filtered2 = xs.filter(pred)\n filtered2 // $ExpectType number[]\n })\n it('functions as a type guard', () => {\n const isString = (x: unknown): x is string => typeof x === 'string'\n const isNumber = (x: unknown): x is number => typeof x === 'number'\n const isBoolean = (x: unknown): x is boolean => typeof x === 'boolean'\n\n const isStringNumberOrBoolean = anyPass([isString, isNumber, isBoolean])\n\n isStringNumberOrBoolean // $ExpectType (input: unknown) => boolean\n\n const aValue: unknown = 1\n\n if (isStringNumberOrBoolean(aValue)) {\n aValue // $ExpectType unknown\n }\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#anyPass)\n\n### ap\n\n```typescript\n\nap(fns: Array<(a: T) => U>[], vs: T[]): U[]\n```\n\nIt takes a list of functions and a list of values. Then it returns a list of values obtained by applying each function to each value.\n\nTry this R.ap example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nap(fns: Array<(a: T) => U>[], vs: T[]): U[];\nap(fns: Array<(a: T) => U>): (vs: T[]) => U[];\nap(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B;\n```\n\n
\n\n
\n\nR.ap source\n\n```javascript\nexport function ap(functions, input){\n if (arguments.length === 1){\n return _inputs => ap(functions, _inputs)\n }\n\n return functions.reduce((acc, fn) => [ ...acc, ...input.map(fn) ], [])\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { ap } from './ap.js'\n\nfunction mult2(x){\n return x * 2\n}\nfunction plus3(x){\n return x + 3\n}\n\ntest('happy', () => {\n expect(ap([ mult2, plus3 ], [ 1, 2, 3 ])).toEqual([ 2, 4, 6, 4, 5, 6 ])\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#ap)\n\n### aperture\n\n```typescript\n\naperture(n: N, list: T[]): Array> | []\n```\n\nIt returns a new list, composed of consecutive `n`-tuples from a `list`.\n\nTry this R.aperture example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\naperture(n: N, list: T[]): Array> | [];\naperture(n: N): (list: T[]) => Array> | [];\n```\n\n
\n\n
\n\nR.aperture source\n\n```javascript\nexport function aperture(step, list){\n if (arguments.length === 1){\n return _list => aperture(step, _list)\n }\n if (step > list.length) return []\n let idx = 0\n const limit = list.length - (step - 1)\n const acc = new Array(limit)\n while (idx < limit){\n acc[ idx ] = list.slice(idx, idx + step)\n idx += 1\n }\n\n return acc\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { aperture } from './aperture.js'\n\nconst list = [ 1, 2, 3, 4, 5, 6, 7 ]\n\ntest('happy', () => {\n expect(aperture(1, list)).toEqual([ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ] ])\n expect(aperture(2, list)).toEqual([\n [ 1, 2 ],\n [ 2, 3 ],\n [ 3, 4 ],\n [ 4, 5 ],\n [ 5, 6 ],\n [ 6, 7 ],\n ])\n expect(aperture(3, list)).toEqual([\n [ 1, 2, 3 ],\n [ 2, 3, 4 ],\n [ 3, 4, 5 ],\n [ 4, 5, 6 ],\n [ 5, 6, 7 ],\n ])\n expect(aperture(8, list)).toEqual([])\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#aperture)\n\n### append\n\n```typescript\n\nappend(xToAppend: T, iterable: T[]): T[]\n```\n\nIt adds element `x` at the end of `iterable`.\n\nTry this R.append example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nappend(xToAppend: T, iterable: T[]): T[];\nappend(xToAppend: T, iterable: IsFirstSubtypeOfSecond[]) : U[];\nappend(xToAppend: T): (iterable: IsFirstSubtypeOfSecond[]) => U[];\nappend(xToAppend: T): (iterable: T[]) => T[];\n```\n\n
\n\n
\n\nR.append source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\n\nexport function append(x, input){\n if (arguments.length === 1) return _input => append(x, _input)\n\n if (typeof input === 'string') return input.split('').concat(x)\n\n const clone = cloneList(input)\n clone.push(x)\n\n return clone\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { append } from './append.js'\n\ntest('happy', () => {\n expect(append('tests', [ 'write', 'more' ])).toEqual([\n 'write',\n 'more',\n 'tests',\n ])\n})\n\ntest('append to empty array', () => {\n expect(append('tests')([])).toEqual([ 'tests' ])\n})\n\ntest('with strings', () => {\n expect(append('o', 'fo')).toEqual([ 'f', 'o', 'o' ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {append, prepend} from 'rambda'\n\nconst listOfNumbers = [1, 2, 3]\nconst listOfNumbersAndStrings = [1, 'b', 3]\n\ndescribe('R.append/R.prepend', () => {\n describe(\"with the same primitive type as the array's elements\", () => {\n it('uncurried', () => {\n // @ts-expect-error\n append('d', listOfNumbers)\n // @ts-expect-error\n prepend('d', listOfNumbers)\n append(4, listOfNumbers) // $ExpectType number[]\n prepend(4, listOfNumbers) // $ExpectType number[]\n })\n\n it('curried', () => {\n // @ts-expect-error\n append('d')(listOfNumbers)\n append(4)(listOfNumbers) // $ExpectType number[]\n prepend(4)(listOfNumbers) // $ExpectType number[]\n })\n })\n\n describe(\"with a subtype of the array's elements\", () => {\n it('uncurried', () => {\n // @ts-expect-error\n append(true, listOfNumbersAndStrings)\n append(4, listOfNumbersAndStrings) // $ExpectType (string | number)[]\n prepend(4, listOfNumbersAndStrings) // $ExpectType (string | number)[]\n })\n\n it('curried', () => {\n // @ts-expect-error\n append(true)(listOfNumbersAndStrings)\n append(4)(listOfNumbersAndStrings) // $ExpectType (string | number)[]\n prepend(4)(listOfNumbersAndStrings) // $ExpectType (string | number)[]\n })\n })\n\n describe(\"expanding the type of the array's elements\", () => {\n it('uncurried', () => {\n // @ts-expect-error\n append('d', listOfNumbers)\n append('d', listOfNumbers) // $ExpectType (string | number)[]\n prepend('d', listOfNumbers) // $ExpectType (string | number)[]\n })\n\n it('curried', () => {\n // @ts-expect-error\n append('d')(listOfNumbers)\n const appendD = append('d')\n appendD(listOfNumbers) // $ExpectType (string | number)[]\n const prependD = prepend('d')\n prependD(listOfNumbers) // $ExpectType (string | number)[]\n })\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#append)\n\n### apply\n\n```typescript\n\napply(fn: (...args: any[]) => T, args: any[]): T\n```\n\nIt applies function `fn` to the list of arguments. \n\nThis is useful for creating a fixed-arity function from a variadic function. `fn` should be a bound function if context is significant.\n\nTry this R.apply example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\napply(fn: (...args: any[]) => T, args: any[]): T;\napply(fn: (...args: any[]) => T): (args: any[]) => T;\n```\n\n
\n\n
\n\nR.apply source\n\n```javascript\nexport function apply(fn, args){\n if (arguments.length === 1){\n return _args => apply(fn, _args)\n }\n\n return fn.apply(this, args)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { apply } from './apply.js'\nimport { bind } from './bind.js'\nimport { identity } from './identity.js'\n\ntest('happy', () => {\n expect(apply(identity, [ 1, 2, 3 ])).toBe(1)\n})\n\ntest('applies function to argument list', () => {\n expect(apply(Math.max, [ 1, 2, 3, -99, 42, 6, 7 ])).toBe(42)\n})\n\ntest('provides no way to specify context', () => {\n const obj = {\n method (){\n return this === obj\n },\n }\n expect(apply(obj.method, [])).toBeFalse()\n expect(apply(bind(obj.method, obj), [])).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {apply, identity} from 'rambda'\n\ndescribe('R.apply', () => {\n it('happy', () => {\n const result = apply(identity, [1, 2, 3])\n\n result // $ExpectType number\n })\n it('curried', () => {\n const fn = apply(identity)\n const result = fn([1, 2, 3])\n\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#apply)\n\n### applySpec\n\n```typescript\n\napplySpec>(\n spec: Spec\n): (\n ...args: Parameters>\n) => { [Key in keyof Spec]: ReturnType }\n```\n\nTry this R.applySpec example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\napplySpec>(\n spec: Spec\n): (\n ...args: Parameters>\n) => { [Key in keyof Spec]: ReturnType };\napplySpec(spec: any): (...args: unknown[]) => T;\n```\n\n
\n\n
\n\nR.applySpec source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\n// recursively traverse the given spec object to find the highest arity function\nexport function __findHighestArity(spec, max = 0){\n for (const key in spec){\n if (spec.hasOwnProperty(key) === false || key === 'constructor') continue\n\n if (typeof spec[ key ] === 'object'){\n max = Math.max(max, __findHighestArity(spec[ key ]))\n }\n\n if (typeof spec[ key ] === 'function'){\n max = Math.max(max, spec[ key ].length)\n }\n }\n\n return max\n}\n\nfunction __filterUndefined(){\n const defined = []\n let i = 0\n const l = arguments.length\n while (i < l){\n if (typeof arguments[ i ] === 'undefined') break\n defined[ i ] = arguments[ i ]\n i++\n }\n\n return defined\n}\n\nfunction __applySpecWithArity(\n spec, arity, cache\n){\n const remaining = arity - cache.length\n\n if (remaining === 1)\n return x =>\n __applySpecWithArity(\n spec, arity, __filterUndefined(...cache, x)\n )\n if (remaining === 2)\n return (x, y) =>\n __applySpecWithArity(\n spec, arity, __filterUndefined(\n ...cache, x, y\n )\n )\n if (remaining === 3)\n return (\n x, y, z\n ) =>\n __applySpecWithArity(\n spec, arity, __filterUndefined(\n ...cache, x, y, z\n )\n )\n if (remaining === 4)\n return (\n x, y, z, a\n ) =>\n __applySpecWithArity(\n spec,\n arity,\n __filterUndefined(\n ...cache, x, y, z, a\n )\n )\n if (remaining > 4)\n return (...args) =>\n __applySpecWithArity(\n spec, arity, __filterUndefined(...cache, ...args)\n )\n\n // handle spec as Array\n if (isArray(spec)){\n const ret = []\n let i = 0\n const l = spec.length\n for (; i < l; i++){\n // handle recursive spec inside array\n if (typeof spec[ i ] === 'object' || isArray(spec[ i ])){\n ret[ i ] = __applySpecWithArity(\n spec[ i ], arity, cache\n )\n }\n // apply spec to the key\n if (typeof spec[ i ] === 'function'){\n ret[ i ] = spec[ i ](...cache)\n }\n }\n\n return ret\n }\n\n // handle spec as Object\n const ret = {}\n // apply callbacks to each property in the spec object\n for (const key in spec){\n if (spec.hasOwnProperty(key) === false || key === 'constructor') continue\n\n // apply the spec recursively\n if (typeof spec[ key ] === 'object'){\n ret[ key ] = __applySpecWithArity(\n spec[ key ], arity, cache\n )\n continue\n }\n\n // apply spec to the key\n if (typeof spec[ key ] === 'function'){\n ret[ key ] = spec[ key ](...cache)\n }\n }\n\n return ret\n}\n\nexport function applySpec(spec, ...args){\n // get the highest arity spec function, cache the result and pass to __applySpecWithArity\n const arity = __findHighestArity(spec)\n\n if (arity === 0){\n return () => ({})\n }\n const toReturn = __applySpecWithArity(\n spec, arity, args\n )\n\n return toReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { applySpec as applySpecRamda, nAry } from 'ramda'\n\nimport {\n add,\n always,\n compose,\n dec,\n inc,\n map,\n path,\n prop,\n T,\n} from '../rambda.js'\nimport { applySpec } from './applySpec.js'\n\ntest('different than Ramda when bad spec', () => {\n const result = applySpec({ sum : { a : 1 } })(1, 2)\n const ramdaResult = applySpecRamda({ sum : { a : 1 } })(1, 2)\n expect(result).toEqual({})\n expect(ramdaResult).toEqual({ sum : { a : {} } })\n})\n\ntest('works with empty spec', () => {\n expect(applySpec({})()).toEqual({})\n expect(applySpec([])(1, 2)).toEqual({})\n expect(applySpec(null)(1, 2)).toEqual({})\n})\n\ntest('works with unary functions', () => {\n const result = applySpec({\n v : inc,\n u : dec,\n })(1)\n const expected = {\n v : 2,\n u : 0,\n }\n expect(result).toEqual(expected)\n})\n\ntest('works with binary functions', () => {\n const result = applySpec({ sum : add })(1, 2)\n expect(result).toEqual({ sum : 3 })\n})\n\ntest('works with nested specs', () => {\n const result = applySpec({\n unnested : always(0),\n nested : { sum : add },\n })(1, 2)\n const expected = {\n unnested : 0,\n nested : { sum : 3 },\n }\n expect(result).toEqual(expected)\n})\n\ntest('works with arrays of nested specs', () => {\n const result = applySpec({\n unnested : always(0),\n nested : [ { sum : add } ],\n })(1, 2)\n\n expect(result).toEqual({\n unnested : 0,\n nested : [ { sum : 3 } ],\n })\n})\n\ntest('works with arrays of spec objects', () => {\n const result = applySpec([ { sum : add } ])(1, 2)\n\n expect(result).toEqual([ { sum : 3 } ])\n})\n\ntest('works with arrays of functions', () => {\n const result = applySpec([ map(prop('a')), map(prop('b')) ])([\n {\n a : 'a1',\n b : 'b1',\n },\n {\n a : 'a2',\n b : 'b2',\n },\n ])\n const expected = [\n [ 'a1', 'a2' ],\n [ 'b1', 'b2' ],\n ]\n expect(result).toEqual(expected)\n})\n\ntest('works with a spec defining a map key', () => {\n expect(applySpec({ map : prop('a') })({ a : 1 })).toEqual({ map : 1 })\n})\n\ntest('cannot retains the highest arity', () => {\n const f = applySpec({\n f1 : nAry(2, T),\n f2 : nAry(5, T),\n })\n const fRamda = applySpecRamda({\n f1 : nAry(2, T),\n f2 : nAry(5, T),\n })\n expect(f).toHaveLength(0)\n expect(fRamda).toHaveLength(5)\n})\n\ntest('returns a curried function', () => {\n expect(applySpec({ sum : add })(1)(2)).toEqual({ sum : 3 })\n})\n\n// Additional tests\n// ============================================\ntest('arity', () => {\n const spec = {\n one : x1 => x1,\n two : (x1, x2) => x1 + x2,\n three : (\n x1, x2, x3\n ) => x1 + x2 + x3,\n }\n expect(applySpec(\n spec, 1, 2, 3\n )).toEqual({\n one : 1,\n two : 3,\n three : 6,\n })\n})\n\ntest('arity over 5 arguments', () => {\n const spec = {\n one : x1 => x1,\n two : (x1, x2) => x1 + x2,\n three : (\n x1, x2, x3\n ) => x1 + x2 + x3,\n four : (\n x1, x2, x3, x4\n ) => x1 + x2 + x3 + x4,\n five : (\n x1, x2, x3, x4, x5\n ) => x1 + x2 + x3 + x4 + x5,\n }\n expect(applySpec(\n spec, 1, 2, 3, 4, 5\n )).toEqual({\n one : 1,\n two : 3,\n three : 6,\n four : 10,\n five : 15,\n })\n})\n\ntest('curried', () => {\n const spec = {\n one : x1 => x1,\n two : (x1, x2) => x1 + x2,\n three : (\n x1, x2, x3\n ) => x1 + x2 + x3,\n }\n expect(applySpec(spec)(1)(2)(3)).toEqual({\n one : 1,\n two : 3,\n three : 6,\n })\n})\n\ntest('curried over 5 arguments', () => {\n const spec = {\n one : x1 => x1,\n two : (x1, x2) => x1 + x2,\n three : (\n x1, x2, x3\n ) => x1 + x2 + x3,\n four : (\n x1, x2, x3, x4\n ) => x1 + x2 + x3 + x4,\n five : (\n x1, x2, x3, x4, x5\n ) => x1 + x2 + x3 + x4 + x5,\n }\n expect(applySpec(spec)(1)(2)(3)(4)(5)).toEqual({\n one : 1,\n two : 3,\n three : 6,\n four : 10,\n five : 15,\n })\n})\n\ntest('undefined property', () => {\n const spec = { prop : path([ 'property', 'doesnt', 'exist' ]) }\n expect(applySpec(spec, {})).toEqual({ prop : undefined })\n})\n\ntest('restructure json object', () => {\n const spec = {\n id : path('user.id'),\n name : path('user.firstname'),\n profile : path('user.profile'),\n doesntExist : path('user.profile.doesntExist'),\n info : { views : compose(inc, prop('views')) },\n type : always('playa'),\n }\n\n const data = {\n user : {\n id : 1337,\n firstname : 'john',\n lastname : 'shaft',\n profile : 'shaft69',\n },\n views : 42,\n }\n\n expect(applySpec(spec, data)).toEqual({\n id : 1337,\n name : 'john',\n profile : 'shaft69',\n doesntExist : undefined,\n info : { views : 43 },\n type : 'playa',\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {multiply, applySpec, inc, dec, add} from 'rambda'\n\ndescribe('applySpec', () => {\n it('ramda 1', () => {\n const result = applySpec({\n v: inc,\n u: dec,\n })(1)\n result // $ExpectType { v: number; u: number; }\n })\n it('ramda 1', () => {\n interface Output {\n sum: number,\n multiplied: number,\n }\n const result = applySpec({\n sum: add,\n multiplied: multiply,\n })(1, 2)\n\n result // $ExpectType Output\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#applySpec)\n\n### applyTo\n\nTry this R.applyTo example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#applyTo)\n\n### ascend\n\nTry this R.ascend example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#ascend)\n\n### assoc\n\nIt makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`.\n\nTry this R.assoc example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#assoc)\n\n### assocPath\n\n```typescript\n\nassocPath(path: Path, newValue: any, obj: object): Output\n```\n\nIt makes a shallow clone of `obj` with setting or overriding with `newValue` the property found with `path`.\n\nTry this R.assocPath example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nassocPath(path: Path, newValue: any, obj: object): Output;\nassocPath(path: Path, newValue: any): (obj: object) => Output;\nassocPath(path: Path): (newValue: any) => (obj: object) => Output;\n```\n\n
\n\n
\n\nR.assocPath source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\nimport { createPath } from './_internals/createPath.js'\nimport { isArray } from './_internals/isArray.js'\nimport { isIndexInteger } from './_internals/isInteger.js'\nimport { assocFn } from './assoc.js'\nimport { curry } from './curry.js'\n\nexport function assocPathFn(\n path, newValue, input\n){\n const pathArrValue = createPath(path)\n if (pathArrValue.length === 0) return newValue\n\n const index = pathArrValue[ 0 ]\n if (pathArrValue.length > 1){\n const condition =\n typeof input !== 'object' ||\n input === null ||\n !input.hasOwnProperty(index)\n\n const nextInput = condition ?\n isIndexInteger(pathArrValue[ 1 ]) ?\n [] :\n {} :\n input[ index ]\n\n newValue = assocPathFn(\n Array.prototype.slice.call(pathArrValue, 1),\n newValue,\n nextInput\n )\n }\n\n if (isIndexInteger(index) && isArray(input)){\n const arr = cloneList(input)\n arr[ index ] = newValue\n\n return arr\n }\n\n return assocFn(\n index, newValue, input\n )\n}\n\nexport const assocPath = curry(assocPathFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { assocPathFn } from './assocPath.js'\n\ntest('happy', () => {\n const path = 'a.c.1'\n const input = {\n a : {\n b : 1,\n c : [ 1, 2 ],\n },\n }\n assocPathFn(\n path, 3, input\n )\n expect(input).toEqual({\n a : {\n b : 1,\n c : [ 1, 2 ],\n },\n })\n})\n\ntest('string can be used as path input', () => {\n const testObj = {\n a : [ { b : 1 }, { b : 2 } ],\n d : 3,\n }\n const result1 = assocPathFn(\n [ 'a', 0, 'b' ], 10, testObj\n )\n const result2 = assocPathFn(\n 'a.0.b', 10, testObj\n )\n\n const expected = {\n a : [ { b : 10 }, { b : 2 } ],\n d : 3,\n }\n expect(result1).toEqual(expected)\n expect(result2).toEqual(expected)\n})\n\ntest('difference with ramda - doesn\\'t overwrite primitive values with keys in the path', () => {\n const obj = { a : 'str' }\n const result = assocPathFn(\n [ 'a', 'b' ], 42, obj\n )\n\n expect(result).toEqual({\n a : {\n 0 : 's',\n 1 : 't',\n 2 : 'r',\n b : 42,\n },\n })\n})\n\ntest('adds a key to an empty object', () => {\n expect(assocPathFn(\n [ 'a' ], 1, {}\n )).toEqual({ a : 1 })\n})\n\ntest('adds a key to a non-empty object', () => {\n expect(assocPathFn(\n 'b', 2, { a : 1 }\n )).toEqual({\n a : 1,\n b : 2,\n })\n})\n\ntest('adds a nested key to a non-empty object', () => {\n expect(assocPathFn(\n 'b.c', 2, { a : 1 }\n )).toEqual({\n a : 1,\n b : { c : 2 },\n })\n})\n\ntest('adds a nested key to a nested non-empty object', () => {\n expect(assocPathFn('b.d',\n 3,{\n a : 1,\n b : { c : 2 },\n })).toEqual({\n a : 1,\n b : {\n c : 2,\n d : 3,\n },\n })\n})\n\ntest('adds a key to a non-empty object', () => {\n expect(assocPathFn('b', 2, { a : 1 })).toEqual({\n a : 1,\n b : 2,\n })\n})\n\ntest('adds a nested key to a non-empty object', () => {\n expect(assocPathFn('b.c', 2, { a : 1 })).toEqual({\n a : 1,\n b : { c : 2 },\n })\n})\n\ntest('changes an existing key', () => {\n expect(assocPathFn(\n 'a', 2, { a : 1 }\n )).toEqual({ a : 2 })\n})\n\ntest('undefined is considered an empty object', () => {\n expect(assocPathFn(\n 'a', 1, undefined\n )).toEqual({ a : 1 })\n})\n\ntest('null is considered an empty object', () => {\n expect(assocPathFn(\n 'a', 1, null\n )).toEqual({ a : 1 })\n})\n\ntest('value can be null', () => {\n expect(assocPathFn(\n 'a', null, null\n )).toEqual({ a : null })\n})\n\ntest('value can be undefined', () => {\n expect(assocPathFn(\n 'a', undefined, null\n )).toEqual({ a : undefined })\n})\n\ntest('assignment is shallow', () => {\n expect(assocPathFn(\n 'a', { b : 2 }, { a : { c : 3 } }\n )).toEqual({ a : { b : 2 } })\n})\n\ntest('empty array as path', () => {\n const result = assocPathFn(\n [], 3, {\n a : 1,\n b : 2,\n }\n )\n expect(result).toBe(3)\n})\n\ntest('happy', () => {\n const expected = { foo : { bar : { baz : 42 } } }\n const result = assocPathFn(\n [ 'foo', 'bar', 'baz' ], 42, { foo : null }\n )\n expect(result).toEqual(expected)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {assocPath} from 'rambda'\n\ninterface Output {\n a: number,\n foo: {bar: number},\n}\n\ndescribe('R.assocPath - user must explicitly set type of output', () => {\n it('with array as path input', () => {\n const result = assocPath(['foo', 'bar'], 2, {a: 1})\n\n result // $ExpectType Output\n })\n it('with string as path input', () => {\n const result = assocPath('foo.bar', 2, {a: 1})\n\n result // $ExpectType Output\n })\n})\n\ndescribe('R.assocPath - curried', () => {\n it('with array as path input', () => {\n const result = assocPath(['foo', 'bar'], 2)({a: 1})\n\n result // $ExpectType Output\n })\n it('with string as path input', () => {\n const result = assocPath('foo.bar', 2)({a: 1})\n\n result // $ExpectType Output\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#assocPath)\n\n### binary\n\nTry this R.binary example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#binary)\n\n### bind\n\n```typescript\n\nbind(fn: F, thisObj: T): (...args: Parameters) => ReturnType\n```\n\nCreates a function that is bound to a context.\n\nTry this R.bind example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nbind(fn: F, thisObj: T): (...args: Parameters) => ReturnType;\nbind(fn: F): (thisObj: T) => (...args: Parameters) => ReturnType;\n```\n\n
\n\n
\n\nR.bind source\n\n```javascript\nimport { curryN } from './curryN.js'\n\nexport function bind(fn, thisObj){\n if (arguments.length === 1){\n return _thisObj => bind(fn, _thisObj)\n }\n\n return curryN(fn.length, (...args) => fn.apply(thisObj, args))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { bind } from './bind.js'\n\nfunction Foo(x){\n this.x = x\n}\nfunction add(x){\n return this.x + x\n}\nfunction Bar(x, y){\n this.x = x\n this.y = y\n}\nBar.prototype = new Foo()\nBar.prototype.getX = function (){\n return 'prototype getX'\n}\n\ntest('returns a function', () => {\n expect(typeof bind(add)(Foo)).toBe('function')\n})\n\ntest('returns a function bound to the specified context object', () => {\n const f = new Foo(12)\n function isFoo(){\n return this instanceof Foo\n }\n const isFooBound = bind(isFoo, f)\n expect(isFoo()).toBeFalse()\n expect(isFooBound()).toBeTrue()\n})\n\ntest('works with built-in types', () => {\n const abc = bind(String.prototype.toLowerCase, 'ABCDEFG')\n expect(typeof abc).toBe('function')\n expect(abc()).toBe('abcdefg')\n})\n\ntest('works with user-defined types', () => {\n const f = new Foo(12)\n function getX(){\n return this.x\n }\n const getXFooBound = bind(getX, f)\n expect(getXFooBound()).toBe(12)\n})\n\ntest('works with plain objects', () => {\n const pojso = { x : 100 }\n function incThis(){\n return this.x + 1\n }\n const incPojso = bind(incThis, pojso)\n expect(typeof incPojso).toBe('function')\n expect(incPojso()).toBe(101)\n})\n\ntest('does not interfere with existing object methods', () => {\n const b = new Bar('a', 'b')\n function getX(){\n return this.x\n }\n const getXBarBound = bind(getX, b)\n expect(b.getX()).toBe('prototype getX')\n expect(getXBarBound()).toBe('a')\n})\n\ntest('preserves arity', () => {\n const f0 = function (){\n return 0\n }\n const f1 = function (a){\n return a\n }\n const f2 = function (a, b){\n return a + b\n }\n const f3 = function (\n a, b, c\n ){\n return a + b + c\n }\n\n expect(bind(f0, {})).toHaveLength(0)\n expect(bind(f1, {})).toHaveLength(1)\n expect(bind(f2, {})).toHaveLength(2)\n expect(bind(f3, {})).toHaveLength(3)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {bind} from 'rambda'\n\nclass Foo {}\nfunction isFoo(this: T): boolean {\n return this instanceof Foo\n}\n\ndescribe('R.bind', () => {\n it('happy', () => {\n const foo = new Foo()\n const result = bind(isFoo, foo)()\n\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#bind)\n\n### both\n\n```typescript\n\nboth(pred1: Pred, pred2: Pred): Pred\n```\n\nIt returns a function with `input` argument. \n\nThis function will return `true`, if both `firstCondition` and `secondCondition` return `true` when `input` is passed as their argument.\n\nTry this R.both example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nboth(pred1: Pred, pred2: Pred): Pred;\nboth(pred1: Predicate, pred2: Predicate): Predicate;\nboth(pred1: Predicate): (pred2: Predicate) => Predicate;\nboth(pred1: Pred): (pred2: Pred) => Pred;\n```\n\n
\n\n
\n\nR.both source\n\n```javascript\nexport function both(f, g){\n if (arguments.length === 1) return _g => both(f, _g)\n\n return (...input) => f(...input) && g(...input)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { both } from './both.js'\n\nconst firstFn = val => val > 0\nconst secondFn = val => val < 10\n\ntest('with curry', () => {\n expect(both(firstFn)(secondFn)(17)).toBeFalse()\n})\n\ntest('without curry', () => {\n expect(both(firstFn, secondFn)(7)).toBeTrue()\n})\n\ntest('with multiple inputs', () => {\n const between = function (\n a, b, c\n ){\n return a < b && b < c\n }\n const total20 = function (\n a, b, c\n ){\n return a + b + c === 20\n }\n const fn = both(between, total20)\n expect(fn(\n 5, 7, 8\n )).toBeTrue()\n})\n\ntest('skip evaluation of the second expression', () => {\n let effect = 'not evaluated'\n const F = function (){\n return false\n }\n const Z = function (){\n effect = 'Z got evaluated'\n }\n both(F, Z)()\n\n expect(effect).toBe('not evaluated')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {both} from 'rambda'\n\ndescribe('R.both', () => {\n it('with passed type', () => {\n const fn = both(\n x => x > 1,\n x => x % 2 === 0\n )\n fn // $ExpectType Predicate\n const result = fn(2) // $ExpectType boolean\n result // $ExpectType boolean\n })\n it('with passed type - curried', () => {\n const fn = both(x => x > 1)(x => x % 2 === 0)\n fn // $ExpectType Predicate\n const result = fn(2)\n result // $ExpectType boolean\n })\n it('no type passed', () => {\n const fn = both(\n x => {\n x // $ExpectType any\n return x > 1\n },\n x => {\n x // $ExpectType any\n return x % 2 === 0\n }\n )\n const result = fn(2)\n result // $ExpectType boolean\n })\n it('no type passed - curried', () => {\n const fn = both((x: number) => {\n x // $ExpectType number\n return x > 1\n })((x: number) => {\n x // $ExpectType number\n return x % 2 === 0\n })\n const result = fn(2)\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#both)\n\n### call\n\nTry this R.call example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#call)\n\n### chain\n\n```typescript\n\nchain(fn: (n: T) => U[], list: T[]): U[]\n```\n\nThe method is also known as `flatMap`.\n\nTry this R.chain example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nchain(fn: (n: T) => U[], list: T[]): U[];\nchain(fn: (n: T) => U[]): (list: T[]) => U[];\n```\n\n
\n\n
\n\nR.chain source\n\n```javascript\nexport function chain(fn, list){\n if (arguments.length === 1){\n return _list => chain(fn, _list)\n }\n\n return [].concat(...list.map(fn))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { chain as chainRamda } from 'ramda'\n\nimport { chain } from './chain.js'\n\nconst duplicate = n => [ n, n ]\n\ntest('happy', () => {\n const fn = x => [ x * 2 ]\n const list = [ 1, 2, 3 ]\n\n const result = chain(fn, list)\n\n expect(result).toEqual([ 2, 4, 6 ])\n})\n\ntest('maps then flattens one level', () => {\n expect(chain(duplicate, [ 1, 2, 3 ])).toEqual([ 1, 1, 2, 2, 3, 3 ])\n})\n\ntest('maps then flattens one level - curry', () => {\n expect(chain(duplicate)([ 1, 2, 3 ])).toEqual([ 1, 1, 2, 2, 3, 3 ])\n})\n\ntest('flattens only one level', () => {\n const nest = n => [ [ n ] ]\n expect(chain(nest, [ 1, 2, 3 ])).toEqual([ [ 1 ], [ 2 ], [ 3 ] ])\n})\n\ntest('can compose', () => {\n function dec(x){\n return [ x - 1 ]\n }\n function times2(x){\n return [ x * 2 ]\n }\n\n const mdouble = chain(times2)\n const mdec = chain(dec)\n expect(mdec(mdouble([ 10, 20, 30 ]))).toEqual([ 19, 39, 59 ])\n})\n\ntest('@types/ramda broken test', () => {\n const score = {\n maths : 90,\n physics : 80,\n }\n\n const calculateTotal = score => {\n const { maths, physics } = score\n\n return maths + physics\n }\n\n const assocTotalToScore = (total, score) => ({\n ...score,\n total,\n })\n\n const calculateAndAssocTotalToScore = chainRamda(assocTotalToScore,\n calculateTotal)\n expect(() =>\n calculateAndAssocTotalToScore(score)).toThrowErrorMatchingInlineSnapshot('\"fn(...) is not a function\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {chain} from 'rambda'\n\nconst list = [1, 2, 3]\nconst fn = (x: number) => [`${x}`, `${x}`]\n\ndescribe('R.chain', () => {\n it('without passing type', () => {\n const result = chain(fn, list)\n result // $ExpectType string[]\n\n const curriedResult = chain(fn)(list)\n curriedResult // $ExpectType string[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#chain)\n\n### clamp\n\nRestrict a number `input` to be within `min` and `max` limits.\n\nIf `input` is bigger than `max`, then the result is `max`.\n\nIf `input` is smaller than `min`, then the result is `min`.\n\nTry this R.clamp example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#clamp)\n\n### clone\n\nIt creates a deep copy of the `input`, which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates.\n\nTry this R.clone example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#clone)\n\n### collectBy\n\nTry this R.collectBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#collectBy)\n\n### comparator\n\nIt returns a comparator function that can be used in `sort` method.\n\nTry this R.comparator example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#comparator)\n\n### complement\n\nIt returns `inverted` version of `origin` function that accept `input` as argument.\n\nThe return value of `inverted` is the negative boolean value of `origin(input)`.\n\nTry this R.complement example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#complement)\n\n### compose\n\nIt performs right-to-left function composition.\n\nTry this R.compose example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#compose)\n\n### composeWith\n\nTry this R.composeWith example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#composeWith)\n\n### concat\n\nIt returns a new string or array, which is the result of merging `x` and `y`.\n\nTry this R.concat example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#concat)\n\n### cond\n\nIt takes list with `conditions` and returns a new function `fn` that expects `input` as argument. \n\nThis function will start evaluating the `conditions` in order to find the first winner(order of conditions matter). \n\nThe winner is this condition, which left side returns `true` when `input` is its argument. Then the evaluation of the right side of the winner will be the final result.\n\nIf no winner is found, then `fn` returns `undefined`.\n\nTry this R.cond example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#cond)\n\n### converge\n\nAccepts a converging function and a list of branching functions and returns a new function. When invoked, this new function is applied to some arguments, each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value.\n\nTry this R.converge example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#converge)\n\n### count\n\nIt counts how many times `predicate` function returns `true`, when supplied with iteration of `list`.\n\nTry this R.count example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#count)\n\n### countBy\n\n```typescript\n\ncountBy(transformFn: (x: T) => any, list: T[]): Record\n```\n\nIt counts elements in a list after each instance of the input list is passed through `transformFn` function.\n\nTry this R.countBy example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ncountBy(transformFn: (x: T) => any, list: T[]): Record;\ncountBy(transformFn: (x: T) => any): (list: T[]) => Record;\n```\n\n
\n\n
\n\nR.countBy source\n\n```javascript\nexport function countBy(fn, list){\n if (arguments.length === 1){\n return _list => countBy(fn, _list)\n }\n const willReturn = {}\n\n list.forEach(item => {\n const key = fn(item)\n if (!willReturn[ key ]){\n willReturn[ key ] = 1\n } else {\n willReturn[ key ]++\n }\n })\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { countBy } from './countBy.js'\n\nconst list = [ 'a', 'A', 'b', 'B', 'c', 'C' ]\n\ntest('happy', () => {\n const result = countBy(x => x.toLowerCase(), list)\n expect(result).toEqual({\n a : 2,\n b : 2,\n c : 2,\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {countBy} from 'rambda'\n\nconst transformFn = (x: string) => x.toLowerCase()\nconst list = ['a', 'A', 'b', 'B', 'c', 'C']\n\ndescribe('R.countBy', () => {\n it('happy', () => {\n const result = countBy(transformFn, list)\n\n result // $ExpectType Record\n })\n it('curried', () => {\n const result = countBy(transformFn)(list)\n\n result // $ExpectType Record\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#countBy)\n\n### curry\n\nIt expects a function as input and returns its curried version.\n\nTry this R.curry example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#curry)\n\n### curryN\n\nIt returns a curried equivalent of the provided function, with the specified arity.\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#curryN)\n\n### dec\n\nIt decrements a number.\n\nTry this R.dec example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dec)\n\n### defaultTo\n\n```typescript\n\ndefaultTo(defaultValue: T, input: T | null | undefined): T\n```\n\nIt returns `defaultValue`, if all of `inputArguments` are `undefined`, `null` or `NaN`.\n\nElse, it returns the first truthy `inputArguments` instance(from left to right).\n\nTry this R.defaultTo example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ndefaultTo(defaultValue: T, input: T | null | undefined): T;\ndefaultTo(defaultValue: T): (input: T | null | undefined) => T;\n```\n\n
\n\n
\n\nR.defaultTo source\n\n```javascript\nfunction isFalsy(input){\n return (\n input === undefined || input === null || Number.isNaN(input) === true\n )\n}\n\nexport function defaultTo(defaultArgument, input){\n if (arguments.length === 1){\n return _input => defaultTo(defaultArgument, _input)\n }\n\n return isFalsy(input) ? defaultArgument : input\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { defaultTo } from './defaultTo.js'\n\ntest('with undefined', () => {\n expect(defaultTo('foo')(undefined)).toBe('foo')\n})\n\ntest('with null', () => {\n expect(defaultTo('foo')(null)).toBe('foo')\n})\n\ntest('with NaN', () => {\n expect(defaultTo('foo')(NaN)).toBe('foo')\n})\n\ntest('with empty string', () => {\n expect(defaultTo('foo', '')).toBe('')\n})\n\ntest('with false', () => {\n expect(defaultTo('foo', false)).toBeFalse()\n})\n\ntest('when inputArgument passes initial check', () => {\n expect(defaultTo('foo', 'bar')).toBe('bar')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {defaultTo} from 'rambda'\n\ndescribe('R.defaultTo with Ramda spec', () => {\n it('happy', () => {\n const result = defaultTo('foo', '')\n result // $ExpectType \"\" | \"foo\"\n })\n it('with explicit type', () => {\n const result = defaultTo('foo', null)\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#defaultTo)\n\n### descend\n\nTry this R.descend example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#descend)\n\n### difference\n\n```typescript\n\ndifference(a: T[], b: T[]): T[]\n```\n\nIt returns the uniq set of all elements in the first list `a` not contained in the second list `b`.\n\n`R.equals` is used to determine equality.\n\nTry this R.difference example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ndifference(a: T[], b: T[]): T[];\ndifference(a: T[]): (b: T[]) => T[];\n```\n\n
\n\n
\n\nR.difference source\n\n```javascript\nimport { includes } from './includes.js'\nimport { uniq } from './uniq.js'\n\nexport function difference(a, b){\n if (arguments.length === 1) return _b => difference(a, _b)\n\n return uniq(a).filter(aInstance => !includes(aInstance, b))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { difference as differenceRamda } from 'ramda'\n\nimport { difference } from './difference.js'\n\ntest('difference', () => {\n const a = [ 1, 2, 3, 4 ]\n const b = [ 3, 4, 5, 6 ]\n expect(difference(a)(b)).toEqual([ 1, 2 ])\n\n expect(difference([], [])).toEqual([])\n})\n\ntest('difference with objects', () => {\n const a = [ { id : 1 }, { id : 2 }, { id : 3 }, { id : 4 } ]\n const b = [ { id : 3 }, { id : 4 }, { id : 5 }, { id : 6 } ]\n expect(difference(a, b)).toEqual([ { id : 1 }, { id : 2 } ])\n})\n\ntest('no duplicates in first list', () => {\n const M2 = [ 1, 2, 3, 4, 1, 2, 3, 4 ]\n const N2 = [ 3, 3, 4, 4, 5, 5, 6, 6 ]\n expect(difference(M2, N2)).toEqual([ 1, 2 ])\n})\n\ntest('should use R.equals', () => {\n expect(difference([ 1 ], [ 1 ])).toHaveLength(0)\n expect(differenceRamda([ NaN ], [ NaN ])).toHaveLength(0)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {difference} from 'rambda'\n\nconst list1 = [1, 2, 3]\nconst list2 = [1, 2, 4]\n\ndescribe('R.difference', () => {\n it('happy', () => {\n const result = difference(list1, list2)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = difference(list1)(list2)\n\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#difference)\n\n### differenceWith\n\n```typescript\n\ndifferenceWith(\n pred: (a: T1, b: T2) => boolean,\n list1: T1[],\n list2: T2[],\n): T1[]\n```\n\nTry this R.differenceWith example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ndifferenceWith(\n pred: (a: T1, b: T2) => boolean,\n list1: T1[],\n list2: T2[],\n): T1[];\ndifferenceWith(\n pred: (a: T1, b: T2) => boolean,\n): (list1: T1[], list2: T2[]) => T1[];\ndifferenceWith(\n pred: (a: T1, b: T2) => boolean,\n list1: T1[],\n): (list2: T2[]) => T1[];\n```\n\n
\n\n
\n\nR.differenceWith source\n\n```javascript\nimport { curry } from './curry.js'\nimport { _indexOf } from './equals.js'\n\nexport function differenceWithFn(\n fn, a, b\n){\n const willReturn = []\n const [ first, second ] = a.length >= b.length ? [ a, b ] : [ b, a ]\n\n first.forEach(item => {\n const hasItem = second.some(secondItem => fn(item, secondItem))\n if (!hasItem && _indexOf(item, willReturn) === -1){\n willReturn.push(item)\n }\n })\n\n return willReturn\n}\n\nexport const differenceWith = curry(differenceWithFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { differenceWith } from './differenceWith.js';\n\nconst fn = (a, b) => a.x === b.x;\n\ntest('same length of list', () => {\n\tconst result = differenceWith(fn, [{ x: 1 }, { x: 2 }], [{ x: 1 }, { x: 3 }]);\n\texpect(result).toEqual([{ x: 2 }]);\n});\n\ntest('different length of list', () => {\n\tconst foo = [{ x: 1 }, { x: 2 }, { x: 3 }];\n\tconst bar = [{ x: 3 }, { x: 4 }];\n\tconst result = differenceWith(fn, foo, bar);\n\texpect(result).toEqual([{ x: 1 }, { x: 2 }]);\n});\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#differenceWith)\n\n### dissoc\n\nIt returns a new object that does not contain property `prop`.\n\nTry this R.dissoc example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dissoc)\n\n### dissocPath\n\nTry this R.dissocPath example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dissocPath)\n\n### divide\n\nTry this R.divide example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#divide)\n\n### drop\n\n```typescript\n\ndrop(howMany: number, input: T[]): T[]\n```\n\nIt returns `howMany` items dropped from beginning of list or string `input`.\n\nTry this R.drop example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ndrop(howMany: number, input: T[]): T[];\ndrop(howMany: number, input: string): string;\ndrop(howMany: number): {\n (input: T[]): T[];\n (input: string): string;\n};\n```\n\n
\n\n
\n\nR.drop source\n\n```javascript\nexport function drop(howManyToDrop, listOrString){\n if (arguments.length === 1) return _list => drop(howManyToDrop, _list)\n\n return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport assert from 'assert'\n\nimport { drop } from './drop.js'\n\ntest('with array', () => {\n expect(drop(2)([ 'foo', 'bar', 'baz' ])).toEqual([ 'baz' ])\n expect(drop(3, [ 'foo', 'bar', 'baz' ])).toEqual([])\n expect(drop(4, [ 'foo', 'bar', 'baz' ])).toEqual([])\n})\n\ntest('with string', () => {\n expect(drop(3, 'rambda')).toBe('bda')\n})\n\ntest('with non-positive count', () => {\n expect(drop(0, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n expect(drop(-1, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n expect(drop(-Infinity, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n})\n\ntest('should return copy', () => {\n const xs = [ 1, 2, 3 ]\n\n assert.notStrictEqual(drop(0, xs), xs)\n assert.notStrictEqual(drop(-1, xs), xs)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {drop} from 'rambda'\n\nconst list = [1, 2, 3, 4]\nconst str = 'foobar'\nconst howMany = 2\n\ndescribe('R.drop - array', () => {\n it('happy', () => {\n const result = drop(howMany, list)\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = drop(howMany)(list)\n result // $ExpectType number[]\n })\n})\n\ndescribe('R.drop - string', () => {\n it('happy', () => {\n const result = drop(howMany, str)\n result // $ExpectType string\n })\n it('curried', () => {\n const result = drop(howMany)(str)\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#drop)\n\n### dropLast\n\n```typescript\n\ndropLast(howMany: number, input: T[]): T[]\n```\n\nIt returns `howMany` items dropped from the end of list or string `input`.\n\nTry this R.dropLast example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ndropLast(howMany: number, input: T[]): T[];\ndropLast(howMany: number, input: string): string;\ndropLast(howMany: number): {\n (input: T[]): T[];\n (input: string): string;\n};\n```\n\n
\n\n
\n\nR.dropLast source\n\n```javascript\nexport function dropLast(howManyToDrop, listOrString){\n if (arguments.length === 1){\n return _listOrString => dropLast(howManyToDrop, _listOrString)\n }\n\n return howManyToDrop > 0 ?\n listOrString.slice(0, -howManyToDrop) :\n listOrString.slice()\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport assert from 'assert'\n\nimport { dropLast } from './dropLast.js'\n\ntest('with array', () => {\n expect(dropLast(2)([ 'foo', 'bar', 'baz' ])).toEqual([ 'foo' ])\n expect(dropLast(3, [ 'foo', 'bar', 'baz' ])).toEqual([])\n expect(dropLast(4, [ 'foo', 'bar', 'baz' ])).toEqual([])\n})\n\ntest('with string', () => {\n expect(dropLast(3, 'rambda')).toBe('ram')\n})\n\ntest('with non-positive count', () => {\n expect(dropLast(0, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n expect(dropLast(-1, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n expect(dropLast(-Infinity, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n})\n\ntest('should return copy', () => {\n const xs = [ 1, 2, 3 ]\n\n assert.notStrictEqual(dropLast(0, xs), xs)\n assert.notStrictEqual(dropLast(-1, xs), xs)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {dropLast} from 'rambda'\n\nconst list = [1, 2, 3, 4]\nconst str = 'foobar'\nconst howMany = 2\n\ndescribe('R.dropLast - array', () => {\n it('happy', () => {\n const result = dropLast(howMany, list)\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = dropLast(howMany)(list)\n result // $ExpectType number[]\n })\n})\n\ndescribe('R.dropLast - string', () => {\n it('happy', () => {\n const result = dropLast(howMany, str)\n result // $ExpectType string\n })\n it('curried', () => {\n const result = dropLast(howMany)(str)\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropLast)\n\n### dropLastWhile\n\nTry this R.dropLastWhile example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropLastWhile)\n\n### dropRepeats\n\n```typescript\n\ndropRepeats(list: T[]): T[]\n```\n\nIt removes any successive duplicates according to `R.equals`.\n\nTry this R.dropRepeats example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ndropRepeats(list: T[]): T[];\n```\n\n
\n\n
\n\nR.dropRepeats source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { equals } from './equals.js'\n\nexport function dropRepeats(list){\n if (!isArray(list)){\n throw new Error(`${ list } is not a list`)\n }\n\n const toReturn = []\n\n list.reduce((prev, current) => {\n if (!equals(prev, current)){\n toReturn.push(current)\n }\n\n return current\n }, undefined)\n\n return toReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { dropRepeats as dropRepeatsRamda } from 'ramda'\n\nimport { compareCombinations } from './_internals/testUtils.js'\nimport { add } from './add.js'\nimport { dropRepeats } from './dropRepeats.js'\n\nconst list = [ 1, 2, 2, 2, 3, 4, 4, 5, 5, 3, 2, 2, { a : 1 }, { a : 1 } ]\nconst listClean = [ 1, 2, 3, 4, 5, 3, 2, { a : 1 } ]\n\ntest('happy', () => {\n const result = dropRepeats(list)\n expect(result).toEqual(listClean)\n})\n\nconst possibleLists = [\n [ add(1), async () => {}, [ 1 ], [ 1 ], [ 2 ], [ 2 ] ],\n [ add(1), add(1), add(2) ],\n [],\n 1,\n /foo/g,\n Promise.resolve(1),\n]\n\ndescribe('brute force', () => {\n compareCombinations({\n firstInput : possibleLists,\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n {\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 0,\n \"RESULTS_MISMATCH\": 1,\n \"SHOULD_NOT_THROW\": 3,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 6,\n }\n `)\n },\n fn : dropRepeats,\n fnRamda : dropRepeatsRamda,\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {dropRepeats} from 'rambda'\n\ndescribe('R.dropRepeats', () => {\n it('happy', () => {\n const result = dropRepeats([1, 2, 2, 3])\n\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropRepeats)\n\n### dropRepeatsBy\n\nTry this R.dropRepeatsBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropRepeatsBy)\n\n### dropRepeatsWith\n\nTry this R.dropRepeatsWith example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropRepeatsWith)\n\n### dropWhile\n\nTry this R.dropWhile example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#dropWhile)\n\n### either\n\n```typescript\n\neither(firstPredicate: Pred, secondPredicate: Pred): Pred\n```\n\nIt returns a new `predicate` function from `firstPredicate` and `secondPredicate` inputs.\n\nThis `predicate` function will return `true`, if any of the two input predicates return `true`.\n\nTry this R.either example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\neither(firstPredicate: Pred, secondPredicate: Pred): Pred;\neither(firstPredicate: Predicate, secondPredicate: Predicate): Predicate;\neither(firstPredicate: Predicate): (secondPredicate: Predicate) => Predicate;\neither(firstPredicate: Pred): (secondPredicate: Pred) => Pred;\n```\n\n
\n\n
\n\nR.either source\n\n```javascript\nexport function either(firstPredicate, secondPredicate){\n if (arguments.length === 1){\n return _secondPredicate => either(firstPredicate, _secondPredicate)\n }\n\n return (...input) =>\n Boolean(firstPredicate(...input) || secondPredicate(...input))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { either } from './either.js'\n\ntest('with multiple inputs', () => {\n const between = function (\n a, b, c\n ){\n return a < b && b < c\n }\n const total20 = function (\n a, b, c\n ){\n return a + b + c === 20\n }\n const fn = either(between, total20)\n expect(fn(\n 7, 8, 5\n )).toBeTrue()\n})\n\ntest('skip evaluation of the second expression', () => {\n let effect = 'not evaluated'\n const F = function (){\n return true\n }\n const Z = function (){\n effect = 'Z got evaluated'\n }\n either(F, Z)()\n\n expect(effect).toBe('not evaluated')\n})\n\ntest('case 1', () => {\n const firstFn = val => val > 0\n const secondFn = val => val * 5 > 10\n\n expect(either(firstFn, secondFn)(1)).toBeTrue()\n})\n\ntest('case 2', () => {\n const firstFn = val => val > 0\n const secondFn = val => val === -10\n const fn = either(firstFn)(secondFn)\n\n expect(fn(-10)).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {either} from 'rambda'\n\ndescribe('R.either', () => {\n it('with passed type', () => {\n const fn = either(\n x => x > 1,\n x => x % 2 === 0\n )\n fn // $ExpectType Predicate\n const result = fn(2) // $ExpectType boolean\n result // $ExpectType boolean\n })\n it('with passed type - curried', () => {\n const fn = either(x => x > 1)(x => x % 2 === 0)\n fn // $ExpectType Predicate\n const result = fn(2)\n result // $ExpectType boolean\n })\n it('no type passed', () => {\n const fn = either(\n x => {\n x // $ExpectType any\n return x > 1\n },\n x => {\n x // $ExpectType any\n return x % 2 === 0\n }\n )\n const result = fn(2)\n result // $ExpectType boolean\n })\n it('no type passed - curried', () => {\n const fn = either((x: number) => {\n x // $ExpectType number\n return x > 1\n })((x: number) => {\n x // $ExpectType number\n return x % 2 === 0\n })\n const result = fn(2)\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#either)\n\n### empty\n\nTry this R.empty example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#empty)\n\n### endsWith\n\n```typescript\n\nendsWith(question: T, str: string): boolean\n```\n\nWhen iterable is a string, then it behaves as `String.prototype.endsWith`.\nWhen iterable is a list, then it uses R.equals to determine if the target list ends in the same way as the given target.\n\nTry this R.endsWith example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nendsWith(question: T, str: string): boolean;\nendsWith(question: T): (str: string) => boolean;\nendsWith(question: T[], list: T[]): boolean;\nendsWith(question: T[]): (list: T[]) => boolean;\n```\n\n
\n\n
\n\nR.endsWith source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { equals } from './equals.js'\n\nexport function endsWith(target, iterable){\n if (arguments.length === 1) return _iterable => endsWith(target, _iterable)\n\n if (typeof iterable === 'string'){\n return iterable.endsWith(target)\n }\n if (!isArray(target)) return false\n\n const diff = iterable.length - target.length\n let correct = true\n const filtered = target.filter((x, index) => {\n if (!correct) return false\n const result = equals(x, iterable[ index + diff ])\n if (!result) correct = false\n\n return result\n })\n\n return filtered.length === target.length\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { endsWith as endsWithRamda } from 'ramda'\n\nimport { compareCombinations } from './_internals/testUtils.js'\nimport { endsWith } from './endsWith.js'\n\ntest('with string', () => {\n expect(endsWith('bar', 'foo-bar')).toBeTrue()\n expect(endsWith('baz')('foo-bar')).toBeFalse()\n})\n\ntest('use R.equals with array', () => {\n const list = [ { a : 1 }, { a : 2 }, { a : 3 } ]\n expect(endsWith({ a : 3 }, list)).toBeFalse(),\n expect(endsWith([ { a : 3 } ], list)).toBeTrue()\n expect(endsWith([ { a : 2 }, { a : 3 } ], list)).toBeTrue()\n expect(endsWith(list, list)).toBeTrue()\n expect(endsWith([ { a : 1 } ], list)).toBeFalse()\n})\n\nexport const possibleTargets = [\n NaN,\n [ NaN ],\n /foo/,\n [ /foo/ ],\n Promise.resolve(1),\n [ Promise.resolve(1) ],\n Error('foo'),\n [ Error('foo') ],\n]\n\nexport const possibleIterables = [\n [ Promise.resolve(1), Promise.resolve(2) ],\n [ /foo/, /bar/ ],\n [ NaN ],\n [ Error('foo'), Error('bar') ],\n]\n\ndescribe('brute force', () => {\n compareCombinations({\n fn : endsWith,\n fnRamda : endsWithRamda,\n firstInput : possibleTargets,\n secondInput : possibleIterables,\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n {\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 0,\n \"RESULTS_MISMATCH\": 0,\n \"SHOULD_NOT_THROW\": 0,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 32,\n }\n `)\n },\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {endsWith} from 'rambda'\n\ndescribe('R.endsWith - array', () => {\n const target = [{a: 2}]\n const input = [{a: 1}, {a: 2}]\n it('happy', () => {\n const result = endsWith(target, input)\n result // $ExpectType boolean\n })\n it('curried', () => {\n const result = endsWith(target)(input)\n result // $ExpectType boolean\n })\n})\n\ndescribe('R.endsWith - string', () => {\n const target = 'bar'\n const input = 'foo bar'\n it('happy', () => {\n const result = endsWith(target, input)\n result // $ExpectType boolean\n })\n it('curried', () => {\n const result = endsWith(target)(input)\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#endsWith)\n\n### eqBy\n\nTry this R.eqBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#eqBy)\n\n### eqProps\n\nIt returns `true` if property `prop` in `obj1` is equal to property `prop` in `obj2` according to `R.equals`.\n\nTry this R.eqProps example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#eqProps)\n\n### equals\n\n```typescript\n\nequals(x: T, y: T): boolean\n```\n\nIt deeply compares `x` and `y` and returns `true` if they are equal.\n\nTry this R.equals example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nequals(x: T, y: T): boolean;\nequals(x: T): (y: T) => boolean;\n```\n\n
\n\n
\n\nR.equals source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { type } from './type.js'\n\nexport function _lastIndexOf(valueToFind, list){\n if (!isArray(list))\n throw new Error(`Cannot read property 'indexOf' of ${ list }`)\n\n const typeOfValue = type(valueToFind)\n if (![ 'Array', 'NaN', 'Object', 'RegExp' ].includes(typeOfValue))\n return list.lastIndexOf(valueToFind)\n\n const { length } = list\n let index = length\n let foundIndex = -1\n\n while (--index > -1 && foundIndex === -1)\n if (equals(list[ index ], valueToFind))\n foundIndex = index\n\n return foundIndex\n}\n\nexport function _indexOf(valueToFind, list){\n if (!isArray(list))\n throw new Error(`Cannot read property 'indexOf' of ${ list }`)\n\n const typeOfValue = type(valueToFind)\n if (![ 'Array', 'NaN', 'Object', 'RegExp' ].includes(typeOfValue))\n return list.indexOf(valueToFind)\n\n let index = -1\n let foundIndex = -1\n const { length } = list\n\n while (++index < length && foundIndex === -1)\n if (equals(list[ index ], valueToFind))\n foundIndex = index\n\n return foundIndex\n}\n\nfunction _arrayFromIterator(iter){\n const list = []\n let next\n while (!(next = iter.next()).done)\n list.push(next.value)\n\n return list\n}\n\nfunction _compareSets(a, b){\n if (a.size !== b.size)\n return false\n\n const aList = _arrayFromIterator(a.values())\n const bList = _arrayFromIterator(b.values())\n\n const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1)\n\n return filtered.length === 0\n}\n\nfunction compareErrors(a, b){\n if (a.message !== b.message) return false\n if (a.toString !== b.toString) return false\n\n return a.toString() === b.toString()\n}\n\nfunction parseDate(maybeDate){\n if (!maybeDate.toDateString) return [ false ]\n\n return [ true, maybeDate.getTime() ]\n}\n\nfunction parseRegex(maybeRegex){\n if (maybeRegex.constructor !== RegExp) return [ false ]\n\n return [ true, maybeRegex.toString() ]\n}\n\nexport function equals(a, b){\n if (arguments.length === 1) return _b => equals(a, _b)\n\n if (Object.is(a, b)) return true\n\n const aType = type(a)\n\n if (aType !== type(b)) return false\n if (aType === 'Function')\n return a.name === undefined ? false : a.name === b.name\n\n if ([ 'NaN', 'Null', 'Undefined' ].includes(aType)) return true\n\n if ([ 'BigInt', 'Number' ].includes(aType)){\n if (Object.is(-0, a) !== Object.is(-0, b)) return false\n\n return a.toString() === b.toString()\n }\n\n if ([ 'Boolean', 'String' ].includes(aType))\n return a.toString() === b.toString()\n\n if (aType === 'Array'){\n const aClone = Array.from(a)\n const bClone = Array.from(b)\n\n if (aClone.toString() !== bClone.toString())\n return false\n\n let loopArrayFlag = true\n aClone.forEach((aCloneInstance, aCloneIndex) => {\n if (loopArrayFlag)\n if (\n aCloneInstance !== bClone[ aCloneIndex ] &&\n !equals(aCloneInstance, bClone[ aCloneIndex ])\n )\n loopArrayFlag = false\n\n })\n\n return loopArrayFlag\n }\n\n const aRegex = parseRegex(a)\n const bRegex = parseRegex(b)\n\n if (aRegex[ 0 ])\n return bRegex[ 0 ] ? aRegex[ 1 ] === bRegex[ 1 ] : false\n else if (bRegex[ 0 ]) return false\n\n const aDate = parseDate(a)\n const bDate = parseDate(b)\n\n if (aDate[ 0 ])\n return bDate[ 0 ] ? aDate[ 1 ] === bDate[ 1 ] : false\n else if (bDate[ 0 ]) return false\n\n if (a instanceof Error){\n if (!(b instanceof Error)) return false\n\n return compareErrors(a, b)\n }\n\n if (aType === 'Set')\n return _compareSets(a, b)\n\n if (aType === 'Object'){\n const aKeys = Object.keys(a)\n\n if (aKeys.length !== Object.keys(b).length)\n return false\n\n let loopObjectFlag = true\n aKeys.forEach(aKeyInstance => {\n if (loopObjectFlag){\n const aValue = a[ aKeyInstance ]\n const bValue = b[ aKeyInstance ]\n\n if (aValue !== bValue && !equals(aValue, bValue))\n loopObjectFlag = false\n\n }\n })\n\n return loopObjectFlag\n }\n\n return false\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { equals as equalsRamda } from 'ramda'\n\nimport { compareCombinations } from './_internals/testUtils.js'\nimport { variousTypes } from './benchmarks/_utils.js'\nimport { equals } from './equals.js'\n\ntest('compare functions', () => {\n function foo(){}\n function bar(){}\n const baz = () => {}\n\n const expectTrue = equals(foo, foo)\n const expectFalseFirst = equals(foo, bar)\n const expectFalseSecond = equals(foo, baz)\n\n expect(expectTrue).toBeTrue()\n expect(expectFalseFirst).toBeFalse()\n expect(expectFalseSecond).toBeFalse()\n})\n\ntest('with array of objects', () => {\n const list1 = [ { a : 1 }, [ { b : 2 } ] ]\n const list2 = [ { a : 1 }, [ { b : 2 } ] ]\n const list3 = [ { a : 1 }, [ { b : 3 } ] ]\n\n expect(equals(list1, list2)).toBeTrue()\n expect(equals(list1, list3)).toBeFalse()\n})\n\ntest('with regex', () => {\n expect(equals(/s/, /s/)).toBeTrue()\n expect(equals(/s/, /d/)).toBeFalse()\n expect(equals(/a/gi, /a/gi)).toBeTrue()\n expect(equals(/a/gim, /a/gim)).toBeTrue()\n expect(equals(/a/gi, /a/i)).toBeFalse()\n})\n\ntest('not a number', () => {\n expect(equals([ NaN ], [ NaN ])).toBeTrue()\n})\n\ntest('new number', () => {\n expect(equals(new Number(0), new Number(0))).toBeTrue()\n expect(equals(new Number(0), new Number(1))).toBeFalse()\n expect(equals(new Number(1), new Number(0))).toBeFalse()\n})\n\ntest('new string', () => {\n expect(equals(new String(''), new String(''))).toBeTrue()\n expect(equals(new String(''), new String('x'))).toBeFalse()\n expect(equals(new String('x'), new String(''))).toBeFalse()\n expect(equals(new String('foo'), new String('foo'))).toBeTrue()\n expect(equals(new String('foo'), new String('bar'))).toBeFalse()\n expect(equals(new String('bar'), new String('foo'))).toBeFalse()\n})\n\ntest('new Boolean', () => {\n expect(equals(new Boolean(true), new Boolean(true))).toBeTrue()\n expect(equals(new Boolean(false), new Boolean(false))).toBeTrue()\n expect(equals(new Boolean(true), new Boolean(false))).toBeFalse()\n expect(equals(new Boolean(false), new Boolean(true))).toBeFalse()\n})\n\ntest('new Error', () => {\n expect(equals(new Error('XXX'), {})).toBeFalse()\n expect(equals(new Error('XXX'), new TypeError('XXX'))).toBeFalse()\n expect(equals(new Error('XXX'), new Error('YYY'))).toBeFalse()\n expect(equals(new Error('XXX'), new Error('XXX'))).toBeTrue()\n expect(equals(new Error('XXX'), new TypeError('YYY'))).toBeFalse()\n expect(equals(new Error('XXX'), new Error('XXX'))).toBeTrue()\n})\n\ntest('with dates', () => {\n expect(equals(new Date(0), new Date(0))).toBeTrue()\n expect(equals(new Date(1), new Date(1))).toBeTrue()\n expect(equals(new Date(0), new Date(1))).toBeFalse()\n expect(equals(new Date(1), new Date(0))).toBeFalse()\n expect(equals(new Date(0), {})).toBeFalse()\n expect(equals({}, new Date(0))).toBeFalse()\n})\n\ntest('ramda spec', () => {\n expect(equals({}, {})).toBeTrue()\n\n expect(equals({\n a : 1,\n b : 2,\n },\n {\n a : 1,\n b : 2,\n })).toBeTrue()\n\n expect(equals({\n a : 2,\n b : 3,\n },\n {\n a : 2,\n b : 3,\n })).toBeTrue()\n\n expect(equals({\n a : 2,\n b : 3,\n },\n {\n a : 3,\n b : 3,\n })).toBeFalse()\n\n expect(equals({\n a : 2,\n b : 3,\n c : 1,\n },\n {\n a : 2,\n b : 3,\n })).toBeFalse()\n})\n\ntest('works with boolean tuple', () => {\n expect(equals([ true, false ], [ true, false ])).toBeTrue()\n expect(equals([ true, false ], [ true, true ])).toBeFalse()\n})\n\ntest('works with equal objects within array', () => {\n const objFirst = {\n a : {\n b : 1,\n c : 2,\n d : [ 1 ],\n },\n }\n const objSecond = {\n a : {\n b : 1,\n c : 2,\n d : [ 1 ],\n },\n }\n\n const x = [ 1, 2, objFirst, null, '', [] ]\n const y = [ 1, 2, objSecond, null, '', [] ]\n expect(equals(x, y)).toBeTrue()\n})\n\ntest('works with different objects within array', () => {\n const objFirst = { a : { b : 1 } }\n const objSecond = { a : { b : 2 } }\n\n const x = [ 1, 2, objFirst, null, '', [] ]\n const y = [ 1, 2, objSecond, null, '', [] ]\n expect(equals(x, y)).toBeFalse()\n})\n\ntest('works with undefined as second argument', () => {\n expect(equals(1, undefined)).toBeFalse()\n\n expect(equals(undefined, undefined)).toBeTrue()\n})\n\ntest('compare sets', () => {\n const toCompareDifferent = new Set([ { a : 1 }, { a : 2 } ])\n const toCompareSame = new Set([ { a : 1 }, { a : 2 }, { a : 1 } ])\n const testSet = new Set([ { a : 1 }, { a : 2 }, { a : 1 } ])\n expect(equals(toCompareSame, testSet)).toBeTruthy()\n expect(equals(toCompareDifferent, testSet)).toBeFalsy()\n expect(equalsRamda(toCompareSame, testSet)).toBeTruthy()\n expect(equalsRamda(toCompareDifferent, testSet)).toBeFalsy()\n})\n\ntest('compare simple sets', () => {\n const testSet = new Set([ '2', '3', '3', '2', '1' ])\n expect(equals(new Set([ '3', '2', '1' ]), testSet)).toBeTruthy()\n expect(equals(new Set([ '3', '2', '0' ]), testSet)).toBeFalsy()\n})\n\ntest('various examples', () => {\n expect(equals([ 1, 2, 3 ])([ 1, 2, 3 ])).toBeTrue()\n\n expect(equals([ 1, 2, 3 ], [ 1, 2 ])).toBeFalse()\n\n expect(equals(1, 1)).toBeTrue()\n\n expect(equals(1, '1')).toBeFalse()\n\n expect(equals({}, {})).toBeTrue()\n\n expect(equals({\n a : 1,\n b : 2,\n },\n {\n a : 1,\n b : 2,\n })).toBeTrue()\n\n expect(equals({\n a : 1,\n b : 2,\n },\n {\n a : 1,\n b : 1,\n })).toBeFalse()\n\n expect(equals({\n a : 1,\n b : false,\n },\n {\n a : 1,\n b : 1,\n })).toBeFalse()\n\n expect(equals({\n a : 1,\n b : 2,\n },\n {\n a : 1,\n b : 2,\n c : 3,\n })).toBeFalse()\n\n expect(equals({\n x : {\n a : 1,\n b : 2,\n },\n },\n {\n x : {\n a : 1,\n b : 2,\n c : 3,\n },\n })).toBeFalse()\n\n expect(equals({\n a : 1,\n b : 2,\n },\n {\n a : 1,\n b : 3,\n })).toBeFalse()\n\n expect(equals({ a : { b : { c : 1 } } }, { a : { b : { c : 1 } } })).toBeTrue()\n\n expect(equals({ a : { b : { c : 1 } } }, { a : { b : { c : 2 } } })).toBeFalse()\n\n expect(equals({ a : {} }, { a : {} })).toBeTrue()\n\n expect(equals('', '')).toBeTrue()\n\n expect(equals('foo', 'foo')).toBeTrue()\n\n expect(equals('foo', 'bar')).toBeFalse()\n\n expect(equals(0, false)).toBeFalse()\n\n expect(equals(/\\s/g, null)).toBeFalse()\n\n expect(equals(null, null)).toBeTrue()\n\n expect(equals(false)(null)).toBeFalse()\n})\n\ntest('with custom functions', () => {\n function foo(){\n return 1\n }\n foo.prototype.toString = () => ''\n const result = equals(foo, foo)\n\n expect(result).toBeTrue()\n})\n\ntest('with classes', () => {\n class Foo{}\n const foo = new Foo()\n const result = equals(foo, foo)\n\n expect(result).toBeTrue()\n})\n\ntest('with negative zero', () => {\n expect(equals(-0, -0)).toBeTrue()\n expect(equals(-0, 0)).toBeFalse()\n expect(equals(0, 0)).toBeTrue()\n expect(equals(-0, 1)).toBeFalse()\n})\n\ntest('with big int', () => {\n const a = BigInt(9007199254740991)\n const b = BigInt(9007199254740991)\n const c = BigInt(7007199254740991)\n expect(equals(a, b)).toBeTrue()\n expect(equals(a, c)).toBeFalse()\n})\n\ndescribe('brute force', () => {\n compareCombinations({\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n{\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 0,\n \"RESULTS_MISMATCH\": 0,\n \"SHOULD_NOT_THROW\": 0,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 289,\n}\n`)\n },\n firstInput : variousTypes,\n fn : equals,\n fnRamda : equalsRamda,\n secondInput : variousTypes,\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {equals} from 'rambda'\n\ndescribe('R.equals', () => {\n it('happy', () => {\n const result = equals(4, 1)\n result // $ExpectType boolean\n })\n it('with object', () => {\n const foo = {a: 1}\n const bar = {a: 2}\n const result = equals(foo, bar)\n result // $ExpectType boolean\n })\n it('curried', () => {\n const result = equals(4)(1)\n\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#equals)\n\n### evolve\n\n```typescript\n\nevolve(rules: ((x: T) => U)[], list: T[]): U[]\n```\n\nIt takes object or array of functions as set of rules. These `rules` are applied to the `iterable` input to produce the result.\n\nTry this R.evolve example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nevolve(rules: ((x: T) => U)[], list: T[]): U[];\nevolve(rules: ((x: T) => U)[]) : (list: T[]) => U[];\nevolve>(rules: E, obj: V): Evolve;\nevolve(rules: E): >(obj: V) => Evolve;\n```\n\n
\n\n
\n\nR.evolve source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { mapArray, mapObject } from './map.js'\nimport { type } from './type.js'\n\nexport function evolveArray(rules, list){\n return mapArray(\n (x, i) => {\n if (type(rules[ i ]) === 'Function'){\n return rules[ i ](x)\n }\n\n return x\n },\n list,\n true\n )\n}\n\nexport function evolveObject(rules, iterable){\n return mapObject((x, prop) => {\n if (type(x) === 'Object'){\n const typeRule = type(rules[ prop ])\n if (typeRule === 'Function'){\n return rules[ prop ](x)\n }\n if (typeRule === 'Object'){\n return evolve(rules[ prop ], x)\n }\n\n return x\n }\n if (type(rules[ prop ]) === 'Function'){\n return rules[ prop ](x)\n }\n\n return x\n }, iterable)\n}\n\nexport function evolve(rules, iterable){\n if (arguments.length === 1){\n return _iterable => evolve(rules, _iterable)\n }\n const rulesType = type(rules)\n const iterableType = type(iterable)\n\n if (iterableType !== rulesType){\n throw new Error('iterableType !== rulesType')\n }\n\n if (![ 'Object', 'Array' ].includes(rulesType)){\n throw new Error(`'iterable' and 'rules' are from wrong type ${ rulesType }`)\n }\n\n if (iterableType === 'Object'){\n return evolveObject(rules, iterable)\n }\n\n return evolveArray(rules, iterable)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { evolve as evolveRamda } from 'ramda'\n\nimport { add } from '../rambda.js'\nimport { compareCombinations, compareToRamda } from './_internals/testUtils.js'\nimport { evolve } from './evolve.js'\n\ntest('happy', () => {\n const rules = {\n foo : add(1),\n nested : { bar : x => Object.keys(x).length },\n }\n const input = {\n a : 1,\n foo : 2,\n nested : { bar : { z : 3 } },\n }\n const result = evolve(rules, input)\n expect(result).toEqual({\n a : 1,\n foo : 3,\n nested : { bar : 1 },\n })\n})\n\ntest('nested rule is wrong', () => {\n const rules = {\n foo : add(1),\n nested : { bar : 10 },\n }\n const input = {\n a : 1,\n foo : 2,\n nested : { bar : { z : 3 } },\n }\n const result = evolve(rules)(input)\n expect(result).toEqual({\n a : 1,\n foo : 3,\n nested : { bar : { z : 3 } },\n })\n})\n\ntest('is recursive', () => {\n const rules = {\n nested : {\n second : add(-1),\n third : add(1),\n },\n }\n const object = {\n first : 1,\n nested : {\n second : 2,\n third : 3,\n },\n }\n const expected = {\n first : 1,\n nested : {\n second : 1,\n third : 4,\n },\n }\n const result = evolve(rules, object)\n expect(result).toEqual(expected)\n})\n\ntest('ignores primitive values', () => {\n const rules = {\n n : 2,\n m : 'foo',\n }\n const object = {\n n : 0,\n m : 1,\n }\n const expected = {\n n : 0,\n m : 1,\n }\n const result = evolve(rules, object)\n expect(result).toEqual(expected)\n})\n\ntest('with array', () => {\n const rules = [ add(1), add(-1) ]\n const list = [ 100, 1400 ]\n const expected = [ 101, 1399 ]\n const result = evolve(rules, list)\n expect(result).toEqual(expected)\n})\n\nconst rulesObject = { a : add(1) }\nconst rulesList = [ add(1) ]\nconst possibleIterables = [ null, undefined, '', 42, [], [ 1 ], { a : 1 } ]\nconst possibleRules = [ ...possibleIterables, rulesList, rulesObject ]\n\ndescribe('brute force', () => {\n compareCombinations({\n firstInput : possibleRules,\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n {\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 4,\n \"RESULTS_MISMATCH\": 0,\n \"SHOULD_NOT_THROW\": 51,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 63,\n }\n `)\n },\n secondInput : possibleIterables,\n fn : evolve,\n fnRamda : evolveRamda,\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {evolve, add} from 'rambda'\n\ndescribe('R.evolve', () => {\n it('happy', () => {\n const input = {\n foo: 2,\n nested: {\n a: 1,\n bar: 3,\n },\n }\n const rules = {\n foo: add(1),\n nested: {\n a: add(-1),\n bar: add(1),\n },\n }\n const result = evolve(rules, input)\n const curriedResult = evolve(rules)(input)\n\n result.nested.a // $ExpectType number\n curriedResult.nested.a // $ExpectType number\n result.nested.bar // $ExpectType number\n result.foo // $ExpectType number\n })\n it('with array', () => {\n const rules = [String, String]\n const input = [100, 1400]\n const result = evolve(rules, input)\n const curriedResult = evolve(rules)(input)\n result // $ExpectType string[]\n curriedResult // $ExpectType string[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#evolve)\n\n### F\n\n```typescript\n\nF(): boolean\n```\n\nTry this R.F example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nF(): boolean;\n```\n\n
\n\n
\n\nR.F source\n\n```javascript\nexport function F(){\n return false\n}\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#F)\n\n### filter\n\n```typescript\n\nfilter(predicate: Predicate): (input: T[]) => T[]\n```\n\nIt filters list or object `input` using a `predicate` function.\n\nTry this R.filter example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nfilter(predicate: Predicate): (input: T[]) => T[];\nfilter(predicate: Predicate, input: T[]): T[];\nfilter(predicate: ObjectPredicate): (x: Dictionary) => Dictionary;\nfilter(predicate: ObjectPredicate, x: Dictionary): Dictionary;\n```\n\n
\n\n
\n\nR.filter source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function filterObject(predicate, obj){\n const willReturn = {}\n\n for (const prop in obj){\n if (predicate(\n obj[ prop ], prop, obj\n )){\n willReturn[ prop ] = obj[ prop ]\n }\n }\n\n return willReturn\n}\n\nexport function filterArray(\n predicate, list, indexed = false\n){\n let index = 0\n const len = list.length\n const willReturn = []\n\n while (index < len){\n const predicateResult = indexed ?\n predicate(list[ index ], index) :\n predicate(list[ index ])\n if (predicateResult){\n willReturn.push(list[ index ])\n }\n\n index++\n }\n\n return willReturn\n}\n\nexport function filter(predicate, iterable){\n if (arguments.length === 1)\n return _iterable => filter(predicate, _iterable)\n if (!iterable){\n throw new Error('Incorrect iterable input')\n }\n\n if (isArray(iterable)) return filterArray(\n predicate, iterable, false\n )\n\n return filterObject(predicate, iterable)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { filter as filterRamda } from 'ramda'\n\nimport { filter } from './filter.js'\nimport { T } from './T.js'\n\nconst sampleObject = {\n a : 1,\n b : 2,\n c : 3,\n d : 4,\n}\n\ntest('happy', () => {\n const isEven = n => n % 2 === 0\n\n expect(filter(isEven, [ 1, 2, 3, 4 ])).toEqual([ 2, 4 ])\n expect(filter(isEven, {\n a : 1,\n b : 2,\n d : 3,\n })).toEqual({ b : 2 })\n})\n\ntest('predicate when input is object', () => {\n const obj = {\n a : 1,\n b : 2,\n }\n const predicate = (\n val, prop, inputObject\n ) => {\n expect(inputObject).toEqual(obj)\n expect(typeof prop).toBe('string')\n\n return val < 2\n }\n expect(filter(predicate, obj)).toEqual({ a : 1 })\n})\n\ntest('with object', () => {\n const isEven = n => n % 2 === 0\n const result = filter(isEven, sampleObject)\n const expectedResult = {\n b : 2,\n d : 4,\n }\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('bad inputs difference between Ramda and Rambda', () => {\n expect(() => filter(T, null)).toThrowWithMessage(Error,\n 'Incorrect iterable input')\n expect(() => filter(T)(undefined)).toThrowWithMessage(Error,\n 'Incorrect iterable input')\n expect(() => filterRamda(T, null)).toThrowWithMessage(TypeError,\n 'Cannot read properties of null (reading \\'fantasy-land/filter\\')')\n expect(() => filterRamda(T, undefined)).toThrowWithMessage(TypeError,\n 'Cannot read properties of undefined (reading \\'fantasy-land/filter\\')')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {filter} from 'rambda'\n\nconst list = [1, 2, 3]\nconst obj = {a: 1, b: 2}\n\ndescribe('R.filter with array', () => {\n it('happy', () => {\n const result = filter(x => {\n x // $ExpectType number\n return x > 1\n }, list)\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = filter(x => {\n x // $ExpectType number\n return x > 1\n })(list)\n result // $ExpectType number[]\n })\n})\n\ndescribe('R.filter with objects', () => {\n it('happy', () => {\n const result = filter((val, prop, origin) => {\n val // $ExpectType number\n prop // $ExpectType string\n origin // $ExpectType Dictionary\n\n return val > 1\n }, obj)\n result // $ExpectType Dictionary\n })\n it('curried version requires second dummy type', () => {\n const result = filter((val, prop, origin) => {\n val // $ExpectType number\n prop // $ExpectType string\n origin // $ExpectType Dictionary\n\n return val > 1\n })(obj)\n result // $ExpectType Dictionary\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#filter)\n\n### find\n\n```typescript\n\nfind(predicate: (x: T) => boolean, list: T[]): T | undefined\n```\n\nIt returns the first element of `list` that satisfy the `predicate`.\n\nIf there is no such element, it returns `undefined`.\n\nTry this R.find example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nfind(predicate: (x: T) => boolean, list: T[]): T | undefined;\nfind(predicate: (x: T) => boolean): (list: T[]) => T | undefined;\n```\n\n
\n\n
\n\nR.find source\n\n```javascript\nexport function find(predicate, list){\n if (arguments.length === 1) return _list => find(predicate, _list)\n\n let index = 0\n const len = list.length\n\n while (index < len){\n const x = list[ index ]\n if (predicate(x)){\n return x\n }\n\n index++\n }\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { find } from './find.js'\nimport { propEq } from './propEq.js'\n\nconst list = [ { a : 1 }, { a : 2 }, { a : 3 } ]\n\ntest('happy', () => {\n const fn = propEq(2, 'a')\n expect(find(fn, list)).toEqual({ a : 2 })\n})\n\ntest('with curry', () => {\n const fn = propEq(4, 'a')\n expect(find(fn)(list)).toBeUndefined()\n})\n\ntest('with empty list', () => {\n expect(find(() => true, [])).toBeUndefined()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {find} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.find', () => {\n it('happy', () => {\n const predicate = (x: number) => x > 2\n const result = find(predicate, list)\n result // $ExpectType number | undefined\n })\n it('curried', () => {\n const predicate = (x: number) => x > 2\n const result = find(predicate)(list)\n result // $ExpectType number | undefined\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#find)\n\n### findIndex\n\n```typescript\n\nfindIndex(predicate: (x: T) => boolean, list: T[]): number\n```\n\nIt returns the index of the first element of `list` satisfying the `predicate` function.\n\nIf there is no such element, then `-1` is returned.\n\nTry this R.findIndex example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nfindIndex(predicate: (x: T) => boolean, list: T[]): number;\nfindIndex(predicate: (x: T) => boolean): (list: T[]) => number;\n```\n\n
\n\n
\n\nR.findIndex source\n\n```javascript\nexport function findIndex(predicate, list){\n if (arguments.length === 1) return _list => findIndex(predicate, _list)\n\n const len = list.length\n let index = -1\n\n while (++index < len){\n if (predicate(list[ index ])){\n return index\n }\n }\n\n return -1\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { findIndex } from './findIndex.js'\nimport { propEq } from './propEq.js'\n\nconst list = [ { a : 1 }, { a : 2 }, { a : 3 } ]\n\ntest('happy', () => {\n expect(findIndex(propEq(2, 'a'), list)).toBe(1)\n expect(findIndex(propEq(1, 'a'))(list)).toBe(0)\n expect(findIndex(propEq(4, 'a'))(list)).toBe(-1)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {findIndex} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.findIndex', () => {\n it('happy', () => {\n const predicate = (x: number) => x > 2\n const result = findIndex(predicate, list)\n result // $ExpectType number\n })\n it('curried', () => {\n const predicate = (x: number) => x > 2\n const result = findIndex(predicate)(list)\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#findIndex)\n\n### findLast\n\n```typescript\n\nfindLast(fn: (x: T) => boolean, list: T[]): T | undefined\n```\n\nIt returns the last element of `list` satisfying the `predicate` function.\n\nIf there is no such element, then `undefined` is returned.\n\nTry this R.findLast example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nfindLast(fn: (x: T) => boolean, list: T[]): T | undefined;\nfindLast(fn: (x: T) => boolean): (list: T[]) => T | undefined;\n```\n\n
\n\n
\n\nR.findLast source\n\n```javascript\nexport function findLast(predicate, list){\n if (arguments.length === 1) return _list => findLast(predicate, _list)\n\n let index = list.length\n\n while (--index >= 0){\n if (predicate(list[ index ])){\n return list[ index ]\n }\n }\n\n return undefined\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { findLast } from './findLast.js'\n\ntest('happy', () => {\n const result = findLast(x => x > 1, [ 1, 1, 1, 2, 3, 4, 1 ])\n expect(result).toBe(4)\n\n expect(findLast(x => x === 0, [ 0, 1, 1, 2, 3, 4, 1 ])).toBe(0)\n})\n\ntest('with curry', () => {\n expect(findLast(x => x > 1)([ 1, 1, 1, 2, 3, 4, 1 ])).toBe(4)\n})\n\nconst obj1 = { x : 100 }\nconst obj2 = { x : 200 }\nconst a = [ 11, 10, 9, 'cow', obj1, 8, 7, 100, 200, 300, obj2, 4, 3, 2, 1, 0 ]\nconst even = function (x){\n return x % 2 === 0\n}\nconst gt100 = function (x){\n return x > 100\n}\nconst isStr = function (x){\n return typeof x === 'string'\n}\nconst xGt100 = function (o){\n return o && o.x > 100\n}\n\ntest('ramda 1', () => {\n expect(findLast(even, a)).toBe(0)\n expect(findLast(gt100, a)).toBe(300)\n expect(findLast(isStr, a)).toBe('cow')\n expect(findLast(xGt100, a)).toEqual(obj2)\n})\n\ntest('ramda 2', () => {\n expect(findLast(even, [ 'zing' ])).toBeUndefined()\n})\n\ntest('ramda 3', () => {\n expect(findLast(even, [ 2, 3, 5 ])).toBe(2)\n})\n\ntest('ramda 4', () => {\n expect(findLast(even, [])).toBeUndefined()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {findLast} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.findLast', () => {\n it('happy', () => {\n const predicate = (x: number) => x > 2\n const result = findLast(predicate, list)\n result // $ExpectType number | undefined\n })\n it('curried', () => {\n const predicate = (x: number) => x > 2\n const result = findLast(predicate)(list)\n result // $ExpectType number | undefined\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#findLast)\n\n### findLastIndex\n\n```typescript\n\nfindLastIndex(predicate: (x: T) => boolean, list: T[]): number\n```\n\nIt returns the index of the last element of `list` satisfying the `predicate` function.\n\nIf there is no such element, then `-1` is returned.\n\nTry this R.findLastIndex example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nfindLastIndex(predicate: (x: T) => boolean, list: T[]): number;\nfindLastIndex(predicate: (x: T) => boolean): (list: T[]) => number;\n```\n\n
\n\n
\n\nR.findLastIndex source\n\n```javascript\nexport function findLastIndex(fn, list){\n if (arguments.length === 1) return _list => findLastIndex(fn, _list)\n\n let index = list.length\n\n while (--index >= 0){\n if (fn(list[ index ])){\n return index\n }\n }\n\n return -1\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { findLastIndex } from './findLastIndex.js'\n\ntest('happy', () => {\n const result = findLastIndex(x => x > 1, [ 1, 1, 1, 2, 3, 4, 1 ])\n\n expect(result).toBe(5)\n\n expect(findLastIndex(x => x === 0, [ 0, 1, 1, 2, 3, 4, 1 ])).toBe(0)\n})\n\ntest('with curry', () => {\n expect(findLastIndex(x => x > 1)([ 1, 1, 1, 2, 3, 4, 1 ])).toBe(5)\n})\n\nconst obj1 = { x : 100 }\nconst obj2 = { x : 200 }\nconst a = [ 11, 10, 9, 'cow', obj1, 8, 7, 100, 200, 300, obj2, 4, 3, 2, 1, 0 ]\nconst even = function (x){\n return x % 2 === 0\n}\nconst gt100 = function (x){\n return x > 100\n}\nconst isStr = function (x){\n return typeof x === 'string'\n}\nconst xGt100 = function (o){\n return o && o.x > 100\n}\n\ntest('ramda 1', () => {\n expect(findLastIndex(even, a)).toBe(15)\n expect(findLastIndex(gt100, a)).toBe(9)\n expect(findLastIndex(isStr, a)).toBe(3)\n expect(findLastIndex(xGt100, a)).toBe(10)\n})\n\ntest('ramda 2', () => {\n expect(findLastIndex(even, [ 'zing' ])).toBe(-1)\n})\n\ntest('ramda 3', () => {\n expect(findLastIndex(even, [ 2, 3, 5 ])).toBe(0)\n})\n\ntest('ramda 4', () => {\n expect(findLastIndex(even, [])).toBe(-1)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {findLastIndex} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.findLastIndex', () => {\n it('happy', () => {\n const predicate = (x: number) => x > 2\n const result = findLastIndex(predicate, list)\n result // $ExpectType number\n })\n it('curried', () => {\n const predicate = (x: number) => x > 2\n const result = findLastIndex(predicate)(list)\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#findLastIndex)\n\n### flatten\n\n```typescript\n\nflatten(list: any[]): T[]\n```\n\nIt deeply flattens an array.\n\nTry this R.flatten example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nflatten(list: any[]): T[];\n```\n\n
\n\n
\n\nR.flatten source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function flatten(list, input){\n const willReturn = input === undefined ? [] : input\n\n for (let i = 0; i < list.length; i++){\n if (isArray(list[ i ])){\n flatten(list[ i ], willReturn)\n } else {\n willReturn.push(list[ i ])\n }\n }\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { flatten } from './flatten.js'\n\ntest('happy', () => {\n expect(flatten([ 1, 2, 3, [ [ [ [ [ 4 ] ] ] ] ] ])).toEqual([ 1, 2, 3, 4 ])\n\n expect(flatten([ 1, [ 2, [ [ 3 ] ] ], [ 4 ] ])).toEqual([ 1, 2, 3, 4 ])\n\n expect(flatten([ 1, [ 2, [ [ [ 3 ] ] ] ], [ 4 ] ])).toEqual([ 1, 2, 3, 4 ])\n\n expect(flatten([ 1, 2, [ 3, 4 ], 5, [ 6, [ 7, 8, [ 9, [ 10, 11 ], 12 ] ] ] ])).toEqual([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ])\n})\n\ntest('readme example', () => {\n const result = flatten([ 1, 2, [ 3, 30, [ 300 ] ], [ 4 ] ])\n expect(result).toEqual([ 1, 2, 3, 30, 300, 4 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {flatten} from 'rambda'\n\ndescribe('flatten', () => {\n it('happy', () => {\n const result = flatten([1, 2, [3, [4]]])\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#flatten)\n\n### flip\n\nIt returns function which calls `fn` with exchanged first and second argument.\n\nTry this R.flip example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#flip)\n\n### forEach\n\n```typescript\n\nforEach(fn: Iterator, list: T[]): T[]\n```\n\nIt applies `iterable` function over all members of `list` and returns `list`.\n\nTry this R.forEach example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nforEach(fn: Iterator, list: T[]): T[];\nforEach(fn: Iterator): (list: T[]) => T[];\nforEach(fn: ObjectIterator, list: Dictionary): Dictionary;\nforEach(fn: ObjectIterator): (list: Dictionary) => Dictionary;\n```\n\n
\n\n
\n\nR.forEach source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { forEachObjIndexedFn } from './forEachObjIndexed.js'\n\nexport function forEach(fn, iterable){\n if (arguments.length === 1) return _list => forEach(fn, _list)\n if (iterable === undefined) return\n\n if (isArray(iterable)){\n let index = 0\n const len = iterable.length\n\n while (index < len){\n fn(iterable[ index ])\n index++\n }\n } else return forEachObjIndexedFn(fn, iterable)\n\n return iterable\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { forEach } from './forEach.js'\nimport { type } from './type.js'\n\ntest('happy', () => {\n const sideEffect = {}\n forEach(x => sideEffect[ `foo${ x }` ] = x + 10)([ 1, 2 ])\n\n expect(sideEffect).toEqual({\n foo1 : 11,\n foo2 : 12,\n })\n})\n\ntest('iterate over object', () => {\n const obj = {\n a : 1,\n b : [ 1, 2 ],\n c : { d : 7 },\n f : 'foo',\n }\n const result = {}\n const returned = forEach((\n val, prop, inputObj\n ) => {\n expect(type(inputObj)).toBe('Object')\n result[ prop ] = `${ prop }-${ type(val) }`\n })(obj)\n\n const expected = {\n a : 'a-Number',\n b : 'b-Array',\n c : 'c-Object',\n f : 'f-String',\n }\n\n expect(result).toEqual(expected)\n expect(returned).toEqual(obj)\n})\n\ntest('with empty list', () => {\n const list = []\n const result = forEach(x => x * x)(list)\n\n expect(result).toEqual(list)\n})\n\ntest('with wrong input', () => {\n const list = undefined\n const result = forEach(x => x * x)(list)\n\n expect(result).toBeUndefined()\n})\n\ntest('returns the input', () => {\n const list = [ 1, 2, 3 ]\n const result = forEach(x => x * x)(list)\n\n expect(result).toEqual(list)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {forEach} from 'rambda'\n\nconst list = [1, 2, 3]\nconst obj = {a: 1, b: 2}\n\ndescribe('R.forEach with arrays', () => {\n it('happy', () => {\n const result = forEach(a => {\n a // $ExpectType number\n }, list)\n result // $ExpectType number[]\n })\n it('curried require an explicit typing', () => {\n const result = forEach(a => {\n a // $ExpectType number\n })(list)\n result // $ExpectType number[]\n })\n})\n\ndescribe('R.forEach with objects', () => {\n it('happy', () => {\n const result = forEach((a, b, c) => {\n a // $ExpectType number\n b // $ExpectType string\n c // $ExpectType Dictionary\n return `${a}`\n }, obj)\n result // $ExpectType Dictionary\n })\n it('curried require an input typing and a dummy third typing', () => {\n // Required in order all typings to work\n const result = forEach((a, b, c) => {\n a // $ExpectType number\n b // $ExpectType string\n c // $ExpectType Dictionary\n })(obj)\n result // $ExpectType Dictionary\n })\n it('iterator without property', () => {\n const result = forEach(a => {\n a // $ExpectType number\n }, obj)\n result // $ExpectType Dictionary\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#forEach)\n\n### forEachObjIndexed\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#forEachObjIndexed)\n\n### fromPairs\n\nIt transforms a `listOfPairs` to an object.\n\nTry this R.fromPairs example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#fromPairs)\n\n### groupBy\n\nIt splits `list` according to a provided `groupFn` function and returns an object.\n\nTry this R.groupBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#groupBy)\n\n### groupWith\n\nIt returns separated version of list or string `input`, where separation is done with equality `compareFn` function.\n\nTry this R.groupWith example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#groupWith)\n\n### gt\n\nTry this R.gt example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#gt)\n\n### gte\n\nTry this R.gte example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#gte)\n\n### has\n\n```typescript\n\nhas(prop: string, obj: T): boolean\n```\n\nIt returns `true` if `obj` has property `prop`.\n\nTry this R.has example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nhas(prop: string, obj: T): boolean;\nhas(prop: string): (obj: T) => boolean;\n```\n\n
\n\n
\n\nR.has source\n\n```javascript\nexport function has(prop, obj){\n if (arguments.length === 1) return _obj => has(prop, _obj)\n\n if (!obj) return false\n\n return obj.hasOwnProperty(prop)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { has } from './has.js'\n\ntest('happy', () => {\n expect(has('a')({ a : 1 })).toBeTrue()\n expect(has('b', { a : 1 })).toBeFalse()\n})\n\ntest('with non-object', () => {\n expect(has('a', undefined)).toBeFalse()\n expect(has('a', null)).toBeFalse()\n expect(has('a', true)).toBeFalse()\n expect(has('a', '')).toBeFalse()\n expect(has('a', /a/)).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {has} from 'rambda'\n\ndescribe('R.has', () => {\n it('happy', () => {\n const result = has('foo', {a: 1})\n const curriedResult = has('bar')({a: 1})\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#has)\n\n### hasIn\n\nTry this R.hasIn example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#hasIn)\n\n### hasPath\n\n```typescript\n\nhasPath(\n path: string | string[],\n input: object\n): boolean\n```\n\nIt will return true, if `input` object has truthy `path`(calculated with `R.path`).\n\nTry this R.hasPath example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nhasPath(\n path: string | string[],\n input: object\n): boolean;\nhasPath(\n path: string | string[]\n): (input: object) => boolean;\n```\n\n
\n\n
\n\nR.hasPath source\n\n```javascript\nimport { path } from './path.js'\n\nexport function hasPath(pathInput, obj){\n if (arguments.length === 1){\n return objHolder => hasPath(pathInput, objHolder)\n }\n\n return path(pathInput, obj) !== undefined\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { hasPath } from './hasPath.js'\n\ntest('when true', () => {\n const path = 'a.b'\n const obj = { a : { b : [] } }\n\n const result = hasPath(path)(obj)\n const expectedResult = true\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('when false', () => {\n const path = 'a.b'\n const obj = {}\n\n const result = hasPath(path, obj)\n const expectedResult = false\n\n expect(result).toEqual(expectedResult)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {hasPath} from 'rambda'\n\ndescribe('R.hasPath', () => {\n it('string path', () => {\n const obj = {a: {b: 1}}\n const result = hasPath('a.b', obj)\n const curriedResult = hasPath('a.c')(obj)\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n it('array path', () => {\n const obj = {a: {b: 1}}\n const result = hasPath(['a', 'b'], obj)\n const curriedResult = hasPath(['a', 'c'])(obj)\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#hasPath)\n\n### head\n\n```typescript\n\nhead(str: string): string\n```\n\nIt returns the first element of list or string `input`. It returns `undefined` if array has length of 0.\n\nTry this R.head example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nhead(str: string): string;\nhead(str: ''): undefined;\nhead(list: readonly[]): undefined;\nhead(list: never[]): undefined;\nhead(array: T): FirstArrayElement\nhead(array: T): FirstArrayElement\n```\n\n
\n\n
\n\nR.head source\n\n```javascript\nexport function head(listOrString){\n if (typeof listOrString === 'string') return listOrString[ 0 ] || ''\n\n return listOrString[ 0 ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { head } from './head.js'\n\ntest('head', () => {\n expect(head([ 'fi', 'fo', 'fum' ])).toBe('fi')\n expect(head([])).toBeUndefined()\n expect(head('foo')).toBe('f')\n expect(head('')).toBe('')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {\n emptyList,\n emptyString,\n mixedList,\n mixedListConst,\n numberList,\n numberListConst,\n string,\n} from '_internals/typescriptTestUtils'\nimport {head, last} from 'rambda'\n\ndescribe('R.head', () => {\n it('string', () => {\n head(string) // $ExpectType string\n last(string) // $ExpectType string\n })\n it('empty string', () => {\n head(emptyString) // $ExpectType undefined\n last(emptyString) // $ExpectType undefined\n })\n it('array', () => {\n head(numberList) // $ExpectType number\n head(numberListConst) // $ExpectType 1\n\n last(numberList) // $ExpectType number\n last(numberListConst) // $ExpectType 3\n })\n it('empty array', () => {\n const list = [] as const\n head(emptyList) // $ExpectType undefined\n head(list) // $ExpectType undefined\n last(emptyList) // $ExpectType undefined\n last(list) // $ExpectType undefined\n })\n\n it('mixed', () => {\n head(mixedList) // $ExpectType string | number\n head(mixedListConst) // $ExpectType 1\n last(mixedList) // $ExpectType string | number\n last(mixedListConst) // $ExpectType \"bar\"\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#head)\n\n### identical\n\nIt returns `true` if its arguments `a` and `b` are identical.\n\nOtherwise, it returns `false`.\n\nTry this R.identical example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#identical)\n\n### identity\n\n```typescript\n\nidentity(input: T): T\n```\n\nIt just passes back the supplied `input` argument.\n\nTry this R.identity example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nidentity(input: T): T;\n```\n\n
\n\n
\n\nR.identity source\n\n```javascript\nexport function identity(x){\n return x\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { identity } from './identity.js'\n\ntest('happy', () => {\n expect(identity(7)).toBe(7)\n expect(identity(true)).toBeTrue()\n expect(identity({ a : 1 })).toEqual({ a : 1 })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {identity} from 'rambda'\n\ndescribe('R.identity', () => {\n it('happy', () => {\n const result = identity(4)\n result // $ExpectType 4\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#identity)\n\n### ifElse\n\n```typescript\n\nifElse(\n pred: (a: T) => a is TFiltered,\n onTrue: (a: TFiltered) => TOnTrueResult,\n onFalse: (a: Exclude) => TOnFalseResult,\n): (a: T) => TOnTrueResult | TOnFalseResult\n```\n\nIt expects `condition`, `onTrue` and `onFalse` functions as inputs and it returns a new function with example name of `fn`. \n\nWhen `fn`` is called with `input` argument, it will return either `onTrue(input)` or `onFalse(input)` depending on `condition(input)` evaluation.\n\nTry this R.ifElse example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nifElse(\n pred: (a: T) => a is TFiltered,\n onTrue: (a: TFiltered) => TOnTrueResult,\n onFalse: (a: Exclude) => TOnFalseResult,\n): (a: T) => TOnTrueResult | TOnFalseResult;\nifElse(fn: (...args: TArgs) => boolean, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult;\n```\n\n
\n\n
\n\nR.ifElse source\n\n```javascript\nimport { curry } from './curry.js'\n\nfunction ifElseFn(\n condition, onTrue, onFalse\n){\n return (...input) => {\n\t\tconst conditionResult =\n typeof condition === 'boolean' ? condition : condition(...input)\n if (Boolean(conditionResult) ){\n return onTrue(...input)\n }\n\n return onFalse(...input)\n }\n}\n\nexport const ifElse = curry(ifElseFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { always } from './always.js'\nimport { has } from './has.js'\nimport { identity } from './identity.js'\nimport { ifElse } from './ifElse.js'\nimport { prop } from './prop.js'\nimport * as R from 'ramda'\n\nconst condition = has('foo')\nconst v = function (a){\n return typeof a === 'number'\n}\nconst t = function (a){\n return a + 1\n}\nconst ifFn = x => prop('foo', x).length\nconst elseFn = () => false\n\ntest('happy', () => {\n const fn = ifElse(condition, ifFn)(elseFn)\n\n expect(fn({ foo : 'bar' })).toBe(3)\n expect(fn({ fo : 'bar' })).toBeFalse()\n})\n\ntest('ramda spec', () => {\n const ifIsNumber = ifElse(v)\n expect(ifIsNumber(t, identity)(15)).toBe(16)\n expect(ifIsNumber(t, identity)('hello')).toBe('hello')\n})\n\ntest('pass all arguments', () => {\n const identity = function (a){\n return a\n }\n const v = function (){\n return true\n }\n const onTrue = function (a, b){\n expect(a).toBe(123)\n expect(b).toBe('abc')\n }\n ifElse(\n v, onTrue, identity\n )(123, 'abc')\n})\n\ntest('accept constant as condition', () => {\n const fn = ifElse(true)(always(true))(always(false))\n\n expect(fn()).toBeTrue()\n})\n\ntest('accept constant as condition - case 2', () => {\n const fn = ifElse(\n false, always(true), always(false)\n )\n\n expect(fn()).toBeFalse()\n})\n\ntest('curry 1', () => {\n const fn = ifElse(condition, ifFn)(elseFn)\n\n expect(fn({ foo : 'bar' })).toBe(3)\n expect(fn({ fo : 'bar' })).toBeFalse()\n})\n\ntest('curry 2', () => {\n const fn = ifElse(condition)(ifFn)(elseFn)\n\n expect(fn({ foo : 'bar' })).toBe(3)\n expect(fn({ fo : 'bar' })).toBeFalse()\n})\n\ntest('simple arity of 1', () => {\n const condition = x => x > 5\n const onTrue = x => x + 1\n const onFalse = x => x + 10\n const result = ifElse(\n condition, onTrue, onFalse\n )(1)\n expect(result).toBe(11)\n})\n\ntest('simple arity of 2', () => {\n const condition = (x, y) => x + y > 5\n const onTrue = (x, y) => x + y + 1\n const onFalse = (x, y) => x + y + 10\n const result = ifElse(\n condition, onTrue, onFalse\n )(1, 10)\n expect(result).toBe(12)\n})\n\ntest('bug 750', () => {\n\tconst value = 34;\n\n\tlet result = ifElse(\n\tR.identity,\n\tR.always('true'),\n\tR.always('false')\n\t)(value)\n\texpect(result).toBe('true')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {ifElse} from 'rambda'\n\ndescribe('R.ifElse', () => {\n it('happy', () => {\n const condition = (x: number) => x > 5\n const onTrue = (x: number) => `foo${x}`\n const onFalse = (x: number) => `bar${x}`\n const fn = ifElse(condition, onTrue, onFalse)\n fn // $ExpectType (x: number) => string\n const result = fn(3)\n result // $ExpectType string\n })\n it('arity of 2', () => {\n const condition = (x: number, y: string) => x + y.length > 5\n const onTrue = (x: number, y: string) => `foo${x}-${y}`\n const onFalse = (x: number, y: string) => `bar${x}-${y}`\n const fn = ifElse(condition, onTrue, onFalse)\n fn // $ExpectType (x: number, y: string) => string\n const result = fn(3, 'hello')\n result // $ExpectType string\n })\n test('DefinitelyTyped#59291', () => {\n const getLengthIfStringElseDouble = ifElse(\n (a: string | number): a is string => true,\n a => a.length,\n a => a * 2\n )\n\n getLengthIfStringElseDouble('foo') // $ExpectType number\n getLengthIfStringElseDouble(3) // $ExpectType number\n const result = ifElse(\n (a: {\n foo?: string,\n bar: number | string,\n }): a is {foo: string, bar: string} => true,\n (a): [string, string] => [a.foo, a.bar],\n (a): [string | undefined, string | number] => [a.foo, a.bar]\n )\n result // $ExpectType (a: { foo?: string | undefined; bar: string | number; }) => [string, string] | [string | undefined, string | number]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#ifElse)\n\n### inc\n\nIt increments a number.\n\nTry this R.inc example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#inc)\n\n### includes\n\n```typescript\n\nincludes(valueToFind: T, input: string): boolean\n```\n\nIf `input` is string, then this method work as native `String.includes`.\n\nIf `input` is array, then `R.equals` is used to define if `valueToFind` belongs to the list.\n\nTry this R.includes example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nincludes(valueToFind: T, input: string): boolean;\nincludes(valueToFind: T): (input: string) => boolean;\nincludes(valueToFind: T, input: T[]): boolean;\nincludes(valueToFind: T): (input: T[]) => boolean;\n```\n\n
\n\n
\n\nR.includes source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { _indexOf } from './equals.js'\n\nexport function includes(valueToFind, iterable){\n if (arguments.length === 1)\n return _iterable => includes(valueToFind, _iterable)\n if (typeof iterable === 'string'){\n return iterable.includes(valueToFind)\n }\n if (!iterable){\n throw new TypeError(`Cannot read property \\'indexOf\\' of ${ iterable }`)\n }\n if (!isArray(iterable)) return false\n\n return _indexOf(valueToFind, iterable) > -1\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { includes as includesRamda } from 'ramda'\n\nimport { includes } from './includes.js'\n\ntest('with string as iterable', () => {\n const str = 'foo bar'\n\n expect(includes('bar')(str)).toBeTrue()\n expect(includesRamda('bar')(str)).toBeTrue()\n expect(includes('never', str)).toBeFalse()\n expect(includesRamda('never', str)).toBeFalse()\n})\n\ntest('with array as iterable', () => {\n const arr = [ 1, 2, 3 ]\n\n expect(includes(2)(arr)).toBeTrue()\n expect(includesRamda(2)(arr)).toBeTrue()\n\n expect(includes(4, arr)).toBeFalse()\n expect(includesRamda(4, arr)).toBeFalse()\n})\n\ntest('with list of objects as iterable', () => {\n const arr = [ { a : 1 }, { b : 2 }, { c : 3 } ]\n\n expect(includes({ c : 3 }, arr)).toBeTrue()\n expect(includesRamda({ c : 3 }, arr)).toBeTrue()\n})\n\ntest('with NaN', () => {\n const result = includes(NaN, [ NaN ])\n const ramdaResult = includesRamda(NaN, [ NaN ])\n expect(result).toBeTrue()\n expect(ramdaResult).toBeTrue()\n})\n\ntest('with wrong input that does not throw', () => {\n const result = includes(1, /foo/g)\n const ramdaResult = includesRamda(1, /foo/g)\n expect(result).toBeFalse()\n expect(ramdaResult).toBeFalse()\n})\n\ntest('throws on wrong input - match ramda behaviour', () => {\n expect(() => includes(2, null)).toThrowWithMessage(TypeError,\n 'Cannot read property \\'indexOf\\' of null')\n expect(() => includesRamda(2, null)).toThrowWithMessage(TypeError,\n 'Cannot read properties of null (reading \\'indexOf\\')')\n expect(() => includes(2, undefined)).toThrowWithMessage(TypeError,\n 'Cannot read property \\'indexOf\\' of undefined')\n expect(() => includesRamda(2, undefined)).toThrowWithMessage(TypeError,\n 'Cannot read properties of undefined (reading \\'indexOf\\')')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {includes} from 'rambda'\n\nconst list = [{a: {b: '1'}}, {a: {c: '2'}}, {a: {b: '3'}}]\n\ndescribe('R.includes', () => {\n it('happy', () => {\n const result = includes({a: {b: '1'}}, list)\n result // $ExpectType boolean\n const result2 = includes('oo', ['f', 'oo'])\n result2 // $ExpectType boolean\n })\n it('with string', () => {\n const str = 'foo' as 'foo' | 'bar'\n const result = includes('oo', str)\n const curriedResult = includes('oo')(str)\n\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#includes)\n\n### indexBy\n\nIt generates object with properties provided by `condition` and values provided by `list` array.\n\nIf `condition` is a function, then all list members are passed through it.\n\nIf `condition` is a string, then all list members are passed through `R.path(condition)`.\n\nTry this R.indexBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#indexBy)\n\n### indexOf\n\nIt returns the index of the first element of `list` equals to `valueToFind`.\n\nIf there is no such element, it returns `-1`.\n\nTry this R.indexOf example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#indexOf)\n\n### init\n\n```typescript\n\ninit(input: T): T extends readonly [...infer U, any] ? U : [...T]\n```\n\nIt returns all but the last element of list or string `input`.\n\nTry this R.init example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ninit(input: T): T extends readonly [...infer U, any] ? U : [...T];\ninit(input: string): string;\n```\n\n
\n\n
\n\nR.init source\n\n```javascript\nimport baseSlice from './_internals/baseSlice.js'\n\nexport function init(listOrString){\n if (typeof listOrString === 'string') return listOrString.slice(0, -1)\n\n return listOrString.length ?\n baseSlice(\n listOrString, 0, -1\n ) :\n []\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { init } from './init.js'\n\ntest('with array', () => {\n expect(init([ 1, 2, 3 ])).toEqual([ 1, 2 ])\n expect(init([ 1, 2 ])).toEqual([ 1 ])\n expect(init([ 1 ])).toEqual([])\n expect(init([])).toEqual([])\n expect(init([])).toEqual([])\n expect(init([ 1 ])).toEqual([])\n})\n\ntest('with string', () => {\n expect(init('foo')).toBe('fo')\n expect(init('f')).toBe('')\n expect(init('')).toBe('')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {init} from 'rambda'\n\ndescribe('R.init', () => {\n it('with string', () => {\n const result = init('foo')\n\n result // $ExpectType string\n })\n it('with list - one type', () => {\n const result = init([1, 2, 3])\n\n result // $ExpectType number[]\n })\n it('with list - mixed types', () => {\n const result = init([1, 2, 3, 'foo', 'bar'])\n\n result // $ExpectType (string | number)[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#init)\n\n### innerJoin\n\nIt returns a new list by applying a `predicate` function to all elements of `list1` and `list2` and keeping only these elements where `predicate` returns `true`.\n\nTry this R.innerJoin example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#innerJoin)\n\n### insert\n\nTry this R.insert example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#insert)\n\n### insertAll\n\nTry this R.insertAll example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#insertAll)\n\n### intersection\n\nIt loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.\n\nTry this R.intersection example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#intersection)\n\n### intersperse\n\nIt adds a `separator` between members of `list`.\n\nTry this R.intersperse example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#intersperse)\n\n### is\n\nIt returns `true` if `x` is instance of `targetPrototype`.\n\nTry this R.is example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#is)\n\n### isEmpty\n\n```typescript\n\nisEmpty(x: T): boolean\n```\n\nIt returns `true` if `x` is `empty`.\n\nTry this R.isEmpty example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nisEmpty(x: T): boolean;\n```\n\n
\n\n
\n\nR.isEmpty source\n\n```javascript\nimport { type } from './type.js'\n\nexport function isEmpty(input){\n const inputType = type(input)\n if ([ 'Undefined', 'NaN', 'Number', 'Null' ].includes(inputType))\n return false\n if (!input) return true\n\n if (inputType === 'Object'){\n return Object.keys(input).length === 0\n }\n\n if (inputType === 'Array'){\n return input.length === 0\n }\n\n return false\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { isEmpty } from './isEmpty.js'\n\ntest('happy', () => {\n expect(isEmpty(undefined)).toBeFalse()\n expect(isEmpty('')).toBeTrue()\n expect(isEmpty(null)).toBeFalse()\n expect(isEmpty(' ')).toBeFalse()\n expect(isEmpty(new RegExp(''))).toBeFalse()\n expect(isEmpty([])).toBeTrue()\n expect(isEmpty([ [] ])).toBeFalse()\n expect(isEmpty({})).toBeTrue()\n expect(isEmpty({ x : 0 })).toBeFalse()\n expect(isEmpty(0)).toBeFalse()\n expect(isEmpty(NaN)).toBeFalse()\n expect(isEmpty([ '' ])).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {isEmpty} from 'rambda'\n\ndescribe('R.isEmpty', () => {\n it('happy', () => {\n const result = isEmpty('foo')\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#isEmpty)\n\n### isNil\n\n```typescript\n\nisNil(x: any): x is null | undefined\n```\n\nIt returns `true` if `x` is either `null` or `undefined`.\n\nTry this R.isNil example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nisNil(x: any): x is null | undefined;\n```\n\n
\n\n
\n\nR.isNil source\n\n```javascript\nexport function isNil(x){\n return x === undefined || x === null\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { isNil } from './isNil.js'\n\ntest('happy', () => {\n expect(isNil(null)).toBeTrue()\n\n expect(isNil(undefined)).toBeTrue()\n\n expect(isNil([])).toBeFalse()\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#isNil)\n\n### isNotEmpty\n\n```typescript\n\nisNotEmpty(value: T[]): value is NonEmptyArray\n```\n\n
\n\nAll TypeScript definitions\n\n```typescript\nisNotEmpty(value: T[]): value is NonEmptyArray;\nisNotEmpty(value: readonly T[]): value is ReadonlyNonEmptyArray;\nisNotEmpty(value: any): boolean;\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#isNotEmpty)\n\n### isNotNil\n\nTry this R.isNotNil example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#isNotNil)\n\n### join\n\n```typescript\n\njoin(glue: string, list: T[]): string\n```\n\nIt returns a string of all `list` instances joined with a `glue`.\n\nTry this R.join example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\njoin(glue: string, list: T[]): string;\njoin(glue: string): (list: T[]) => string;\n```\n\n
\n\n
\n\nR.join source\n\n```javascript\nexport function join(glue, list){\n if (arguments.length === 1) return _list => join(glue, _list)\n\n return list.join(glue)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { join } from './join.js'\n\ntest('curry', () => {\n expect(join('|')([ 'foo', 'bar', 'baz' ])).toBe('foo|bar|baz')\n\n expect(join('|', [ 1, 2, 3 ])).toBe('1|2|3')\n\n const spacer = join(' ')\n\n expect(spacer([ 'a', 2, 3.4 ])).toBe('a 2 3.4')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {join} from 'rambda'\n\ndescribe('R.join', () => {\n it('happy', () => {\n const result = join('|', [1, 2, 3])\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#join)\n\n### juxt\n\n```typescript\n\njuxt(fns: [(...a: A) => R1]): (...a: A) => [R1]\n```\n\nIt applies list of function to a list of inputs.\n\nTry this R.juxt example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\njuxt(fns: [(...a: A) => R1]): (...a: A) => [R1];\njuxt(fns: [(...a: A) => R1, (...a: A) => R2]): (...a: A) => [R1, R2];\njuxt(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3]): (...a: A) => [R1, R2, R3];\njuxt(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4]): (...a: A) => [R1, R2, R3, R4];\njuxt(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4, (...a: A) => R5]): (...a: A) => [R1, R2, R3, R4, R5];\njuxt(fns: Array<(...args: A) => U>): (...args: A) => U[];\n```\n\n
\n\n
\n\nR.juxt source\n\n```javascript\nexport function juxt(listOfFunctions){\n return (...args) => listOfFunctions.map(fn => fn(...args))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { juxt } from './juxt.js'\n\ntest('happy', () => {\n const fn = juxt([ Math.min, Math.max, Math.min ])\n const result = fn(\n 3, 4, 9, -3\n )\n expect(result).toEqual([ -3, 9, -3 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {juxt} from 'rambda'\n\ndescribe('R.juxt', () => {\n it('happy', () => {\n const fn = juxt([Math.min, Math.max])\n const result = fn(3, 4, 9, -3)\n result // $ExpectType [number, number]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#juxt)\n\n### keys\n\n```typescript\n\nkeys(x: T): (keyof T & string)[]\n```\n\nIt applies `Object.keys` over `x` and returns its keys.\n\n
Try this R.keys example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nkeys(x: T): (keyof T & string)[];\nkeys(x: T): string[];\n```\n\n
\n\n
\n\nR.keys source\n\n```javascript\nexport function keys(x){\n return Object.keys(x)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { keys } from './keys.js'\n\ntest('happy', () => {\n expect(keys({ a : 1 })).toEqual([ 'a' ])\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#keys)\n\n### last\n\n```typescript\n\nlast(str: ''): undefined\n```\n\nIt returns the last element of `input`, as the `input` can be either a string or an array. It returns `undefined` if array has length of 0.\n\nTry this R.last example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nlast(str: ''): undefined;\nlast(str: string): string;\nlast(list: readonly[]): undefined;\nlast(list: never[]): undefined;\nlast(array: T): LastArrayElement;\nlast(array: T): LastArrayElement;\nlast(str: string): string | undefined;\n```\n\n
\n\n
\n\nR.last source\n\n```javascript\nexport function last(listOrString){\n if (typeof listOrString === 'string'){\n return listOrString[ listOrString.length - 1 ] || ''\n }\n\n return listOrString[ listOrString.length - 1 ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { last } from './last.js'\n\ntest('with list', () => {\n expect(last([ 1, 2, 3 ])).toBe(3)\n expect(last([])).toBeUndefined()\n})\n\ntest('with string', () => {\n expect(last('abc')).toBe('c')\n expect(last('')).toBe('')\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#last)\n\n### lastIndexOf\n\n```typescript\n\nlastIndexOf(target: T, list: T[]): number\n```\n\nIt returns the last index of `target` in `list` array.\n\n`R.equals` is used to determine equality between `target` and members of `list`.\n\nIf there is no such index, then `-1` is returned.\n\nTry this R.lastIndexOf example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nlastIndexOf(target: T, list: T[]): number;\nlastIndexOf(target: T): (list: T[]) => number;\n```\n\n
\n\n
\n\nR.lastIndexOf source\n\n```javascript\nimport { _lastIndexOf } from './equals.js'\n\nexport function lastIndexOf(valueToFind, list){\n if (arguments.length === 1){\n return _list => _lastIndexOf(valueToFind, _list)\n }\n\n return _lastIndexOf(valueToFind, list)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { lastIndexOf as lastIndexOfRamda } from 'ramda'\n\nimport { compareCombinations } from './_internals/testUtils.js'\nimport { possibleIterables, possibleTargets } from './indexOf.spec.js'\nimport { lastIndexOf } from './lastIndexOf.js'\n\ntest('with NaN', () => {\n expect(lastIndexOf(NaN, [ NaN ])).toBe(0)\n})\n\ntest('will throw with bad input', () => {\n expect(lastIndexOfRamda([], true)).toBe(-1)\n expect(() => indexOf([], true)).toThrowErrorMatchingInlineSnapshot('\"indexOf is not defined\"')\n})\n\ntest('without list of objects - no R.equals', () => {\n expect(lastIndexOf(3, [ 1, 2, 3, 4 ])).toBe(2)\n expect(lastIndexOf(10)([ 1, 2, 3, 4 ])).toBe(-1)\n})\n\ntest('list of objects uses R.equals', () => {\n const listOfObjects = [ { a : 1 }, { b : 2 }, { c : 3 } ]\n expect(lastIndexOf({ c : 4 }, listOfObjects)).toBe(-1)\n expect(lastIndexOf({ c : 3 }, listOfObjects)).toBe(2)\n})\n\ntest('list of arrays uses R.equals', () => {\n const listOfLists = [ [ 1 ], [ 2, 3 ], [ 2, 3, 4 ], [ 2, 3 ], [ 1 ], [] ]\n expect(lastIndexOf([], listOfLists)).toBe(5)\n expect(lastIndexOf([ 1 ], listOfLists)).toBe(4)\n expect(lastIndexOf([ 2, 3, 4 ], listOfLists)).toBe(2)\n expect(lastIndexOf([ 2, 3, 5 ], listOfLists)).toBe(-1)\n})\n\ntest('with string as iterable', () => {\n expect(() => lastIndexOf('a', 'abc')).toThrowErrorMatchingInlineSnapshot('\"Cannot read property \\'indexOf\\' of abc\"')\n expect(lastIndexOfRamda('a', 'abc')).toBe(0)\n})\n\ndescribe('brute force', () => {\n compareCombinations({\n fn : lastIndexOf,\n fnRamda : lastIndexOfRamda,\n firstInput : possibleTargets,\n secondInput : possibleIterables,\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n {\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 34,\n \"RESULTS_MISMATCH\": 0,\n \"SHOULD_NOT_THROW\": 51,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 170,\n }\n `)\n },\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {lastIndexOf} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.lastIndexOf', () => {\n it('happy', () => {\n const result = lastIndexOf(2, list)\n result // $ExpectType number\n })\n it('curried', () => {\n const result = lastIndexOf(2)(list)\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lastIndexOf)\n\n### length\n\n```typescript\n\nlength(input: T[]): number\n```\n\nIt returns the `length` property of list or string `input`.\n\nTry this R.length example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nlength(input: T[]): number;\n```\n\n
\n\n
\n\nR.length source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function length(x){\n if (isArray(x)) return x.length\n if (typeof x === 'string') return x.length\n\n return NaN\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { length as lengthRamda } from 'ramda'\n\nimport { length } from './length.js'\n\ntest('happy', () => {\n expect(length('foo')).toBe(3)\n expect(length([ 1, 2, 3 ])).toBe(3)\n expect(length([])).toBe(0)\n})\n\ntest('with empty string', () => {\n expect(length('')).toBe(0)\n})\n\ntest('with bad input returns NaN', () => {\n expect(length(0)).toBeNaN()\n expect(length({})).toBeNaN()\n expect(length(null)).toBeNaN()\n expect(length(undefined)).toBeNaN()\n})\n\ntest('with length as property', () => {\n const input1 = { length : '123' }\n const input2 = { length : null }\n const input3 = { length : '' }\n\n expect(length(input1)).toBeNaN()\n expect(lengthRamda(input1)).toBeNaN()\n expect(length(input2)).toBeNaN()\n expect(lengthRamda(input2)).toBeNaN()\n expect(length(input3)).toBeNaN()\n expect(lengthRamda(input3)).toBeNaN()\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#length)\n\n### lens\n\n```typescript\n\nlens(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens\n```\n\nIt returns a `lens` for the given `getter` and `setter` functions. \n\nThe `getter` **gets** the value of the focus; the `setter` **sets** the value of the focus. \n\nThe setter should not mutate the data structure.\n\nTry this R.lens example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nlens(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens;\n```\n\n
\n\n
\n\nR.lens source\n\n```javascript\nexport function lens(getter, setter){\n return function (functor){\n return function (target){\n return functor(getter(target)).map(focus => setter(focus, target))\n }\n }\n}\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {lens, assoc, lensProp, view, lensIndex, over, lensPath} from 'rambda'\n\ninterface Input {\n foo: string,\n}\nconst testObject: Input = {\n foo: 'Jazz',\n}\n\ndescribe('R.lens', () => {\n it('happy', () => {\n const fn = lens((x: Input) => {\n x.foo // $ExpectType string\n return x.foo\n }, assoc('name'))\n fn // $ExpectType Lens\n })\n})\n\ndescribe('R.lensProp', () => {\n it('happy', () => {\n const result = view(lensProp('foo'), testObject)\n result // $ExpectType string\n })\n it('issue 740', () => {\n // @ts-expect-error\n over(lensProp('x'), (n) => String(n), {x: 1})\n })\n})\n\ndescribe('R.lensIndex', () => {\n const testList: Input[] = [{foo: 'bar'}, {foo: 'baz'}]\n it('happy', () => {\n const result = view(lensIndex(0), testList)\n result // $ExpectType Input\n result.foo // $ExpectType string\n })\n})\n\ndescribe('R.lensPath', () => {\n const path = lensPath(['bar', 'a'])\n it('happy', () => {\n const result = view(path, testObject)\n result // $ExpectType string\n })\n})\n\ndescribe('R.view', () => {\n const fooLens = lens((x: Input) => {\n return x.foo\n }, assoc('foo'))\n it('happt', () => {\n const result = view(fooLens, testObject)\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lens)\n\n### lensIndex\n\n```typescript\n\nlensIndex(n: number): Lens\n```\n\nIt returns a lens that focuses on specified `index`.\n\nTry this R.lensIndex example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nlensIndex(n: number): Lens;\nlensIndex(n: N): Lens;\n```\n\n
\n\n
\n\nR.lensIndex source\n\n```javascript\nimport { lens } from './lens.js'\nimport { nth } from './nth.js'\nimport { update } from './update.js'\n\nexport function lensIndex(index){\n return lens(nth(index), update(index))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { compose } from './compose.js'\nimport { keys } from './keys.js'\nimport { lensIndex } from './lensIndex.js'\nimport { over } from './over.js'\nimport { set } from './set.js'\nimport { view } from './view.js'\n\nconst testList = [ { a : 1 }, { b : 2 }, { c : 3 } ]\n\ntest('focuses list element at the specified index', () => {\n expect(view(lensIndex(0), testList)).toEqual({ a : 1 })\n})\n\ntest('returns undefined if the specified index does not exist', () => {\n expect(view(lensIndex(10), testList)).toBeUndefined()\n})\n\ntest('sets the list value at the specified index', () => {\n expect(set(\n lensIndex(0), 0, testList\n )).toEqual([ 0, { b : 2 }, { c : 3 } ])\n})\n\ntest('applies function to the value at the specified list index', () => {\n expect(over(\n lensIndex(2), keys, testList\n )).toEqual([ { a : 1 }, { b : 2 }, [ 'c' ] ])\n})\n\ntest('can be composed', () => {\n const nestedList = [ 0, [ 10, 11, 12 ], 1, 2 ]\n const composedLens = compose(lensIndex(1), lensIndex(0))\n\n expect(view(composedLens, nestedList)).toBe(10)\n})\n\ntest('set s (get s) === s', () => {\n expect(set(\n lensIndex(0), view(lensIndex(0), testList), testList\n )).toEqual(testList)\n})\n\ntest('get (set s v) === v', () => {\n expect(view(lensIndex(0), set(\n lensIndex(0), 0, testList\n ))).toBe(0)\n})\n\ntest('get (set(set s v1) v2) === v2', () => {\n expect(view(lensIndex(0),\n set(\n lensIndex(0), 11, set(\n lensIndex(0), 10, testList\n )\n ))).toBe(11)\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lensIndex)\n\n### lensPath\n\nIt returns a lens that focuses on specified `path`.\n\n
Try this R.lensPath example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lensPath)\n\n### lensProp\n\n```typescript\n\nlensProp(prop: K): Lens\n```\n\nIt returns a lens that focuses on specified property `prop`.\n\nTry this R.lensProp example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nlensProp(prop: K): Lens;\n```\n\n
\n\n
\n\nR.lensProp source\n\n```javascript\nimport { assoc } from './assoc.js'\nimport { lens } from './lens.js'\nimport { prop } from './prop.js'\n\nexport function lensProp(key){\n return lens(prop(key), assoc(key))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { compose } from './compose.js'\nimport { identity } from './identity.js'\nimport { inc } from './inc.js'\nimport { lensProp } from './lensProp.js'\nimport { over } from './over.js'\nimport { set } from './set.js'\nimport { view } from './view.js'\n\nconst testObj = {\n a : 1,\n b : 2,\n c : 3,\n}\n\ntest('focuses object the specified object property', () => {\n expect(view(lensProp('a'), testObj)).toBe(1)\n})\n\ntest('returns undefined if the specified property does not exist', () => {\n expect(view(lensProp('X'), testObj)).toBeUndefined()\n})\n\ntest('sets the value of the object property specified', () => {\n expect(set(\n lensProp('a'), 0, testObj\n )).toEqual({\n a : 0,\n b : 2,\n c : 3,\n })\n})\n\ntest('adds the property to the object if it doesn\\'t exist', () => {\n expect(set(\n lensProp('d'), 4, testObj\n )).toEqual({\n a : 1,\n b : 2,\n c : 3,\n d : 4,\n })\n})\n\ntest('applies function to the value of the specified object property', () => {\n expect(over(\n lensProp('a'), inc, testObj\n )).toEqual({\n a : 2,\n b : 2,\n c : 3,\n })\n})\n\ntest('applies function to undefined and adds the property if it doesn\\'t exist', () => {\n expect(over(\n lensProp('X'), identity, testObj\n )).toEqual({\n a : 1,\n b : 2,\n c : 3,\n X : undefined,\n })\n})\n\ntest('can be composed', () => {\n const nestedObj = {\n a : { b : 1 },\n c : 2,\n }\n const composedLens = compose(lensProp('a'), lensProp('b'))\n\n expect(view(composedLens, nestedObj)).toBe(1)\n})\n\ntest('set s (get s) === s', () => {\n expect(set(\n lensProp('a'), view(lensProp('a'), testObj), testObj\n )).toEqual(testObj)\n})\n\ntest('get (set s v) === v', () => {\n expect(view(lensProp('a'), set(\n lensProp('a'), 0, testObj\n ))).toBe(0)\n})\n\ntest('get (set(set s v1) v2) === v2', () => {\n expect(view(lensProp('a'),\n set(\n lensProp('a'), 11, set(\n lensProp('a'), 10, testObj\n )\n ))).toBe(11)\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lensProp)\n\n### lt\n\nTry this R.lt example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lt)\n\n### lte\n\nTry this R.lte example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#lte)\n\n### map\n\n```typescript\n\nmap(fn: ObjectIterator, iterable: Dictionary): Dictionary\n```\n\nIt returns the result of looping through `iterable` with `fn`.\n\nIt works with both array and object.\n\nTry this R.map example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmap(fn: ObjectIterator, iterable: Dictionary): Dictionary;\nmap(fn: Iterator, iterable: T[]): U[];\nmap(fn: Iterator): (iterable: T[]) => U[];\nmap(fn: ObjectIterator): (iterable: Dictionary) => Dictionary;\nmap(fn: Iterator): (iterable: T[]) => T[];\nmap(fn: Iterator, iterable: T[]): T[];\n```\n\n
\n\n
\n\nR.map source\n\n```javascript\nimport { INCORRECT_ITERABLE_INPUT } from './_internals/constants.js'\nimport { isArray } from './_internals/isArray.js'\nimport { keys } from './_internals/keys.js'\n\nexport function mapArray(\n fn, list, isIndexed = false\n){\n let index = 0\n const willReturn = Array(list.length)\n\n while (index < list.length){\n willReturn[ index ] = isIndexed ? fn(list[ index ], index) : fn(list[ index ])\n\n index++\n }\n\n return willReturn\n}\n\nexport function mapObject(fn, obj){\n if (arguments.length === 1){\n return _obj => mapObject(fn, _obj)\n }\n let index = 0\n const objKeys = keys(obj)\n const len = objKeys.length\n const willReturn = {}\n\n while (index < len){\n const key = objKeys[ index ]\n willReturn[ key ] = fn(\n obj[ key ], key, obj\n )\n index++\n }\n\n return willReturn\n}\n\nexport const mapObjIndexed = mapObject\n\nexport function map(fn, iterable){\n if (arguments.length === 1) return _iterable => map(fn, _iterable)\n if (!iterable){\n throw new Error(INCORRECT_ITERABLE_INPUT)\n }\n\n if (isArray(iterable)) return mapArray(fn, iterable)\n\n return mapObject(fn, iterable)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { map as mapRamda } from 'ramda'\n\nimport { map } from './map.js'\n\nconst double = x => x * 2\n\ndescribe('with array', () => {\n it('happy', () => {\n expect(map(double, [ 1, 2, 3 ])).toEqual([ 2, 4, 6 ])\n })\n\n it('curried', () => {\n expect(map(double)([ 1, 2, 3 ])).toEqual([ 2, 4, 6 ])\n })\n})\n\ndescribe('with object', () => {\n const obj = {\n a : 1,\n b : 2,\n }\n\n it('happy', () => {\n expect(map(double, obj)).toEqual({\n a : 2,\n b : 4,\n })\n })\n\n it('property as second and input object as third argument', () => {\n const obj = {\n a : 1,\n b : 2,\n }\n const iterator = (\n val, prop, inputObject\n ) => {\n expect(prop).toBeString()\n expect(inputObject).toEqual(obj)\n\n return val * 2\n }\n\n expect(map(iterator)(obj)).toEqual({\n a : 2,\n b : 4,\n })\n })\n})\n\ntest('bad inputs difference between Ramda and Rambda', () => {\n expect(() => map(double, null)).toThrowErrorMatchingInlineSnapshot('\"Incorrect iterable input\"')\n expect(() => map(double)(undefined)).toThrowErrorMatchingInlineSnapshot('\"Incorrect iterable input\"')\n expect(() => mapRamda(double, null)).toThrowErrorMatchingInlineSnapshot('\"Cannot read properties of null (reading \\'fantasy-land/map\\')\"')\n expect(() =>\n mapRamda(double, undefined)).toThrowErrorMatchingInlineSnapshot('\"Cannot read properties of undefined (reading \\'fantasy-land/map\\')\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {map} from 'rambda'\n\ndescribe('R.map with arrays', () => {\n it('iterable returns the same type as the input', () => {\n const result = map(\n (x: number) => {\n x // $ExpectType number\n return x + 2\n },\n [1, 2, 3]\n )\n result // $ExpectType number[]\n })\n it('iterable returns the same type as the input - curried', () => {\n const result = map((x: number) => {\n x // $ExpectType number\n return x + 2\n })([1, 2, 3])\n result // $ExpectType number[]\n })\n it('iterable returns different type as the input', () => {\n const result = map(\n (x: number) => {\n x // $ExpectType number\n return String(x)\n },\n [1, 2, 3]\n )\n result // $ExpectType string[]\n })\n})\n\ndescribe('R.map with objects', () => {\n it('iterable with all three arguments - curried', () => {\n // It requires dummy third typing argument\n // in order to identify compared to curry typings for arrays\n // ============================================\n const result = map((a, b, c) => {\n a // $ExpectType number\n b // $ExpectType string\n c // $ExpectType Dictionary\n return `${a}`\n })({a: 1, b: 2})\n result // $ExpectType Dictionary\n })\n it('iterable with all three arguments', () => {\n const result = map(\n (a, b, c) => {\n a // $ExpectType number\n b // $ExpectType string\n c // $ExpectType Dictionary\n return `${a}`\n },\n {a: 1, b: 2}\n )\n result // $ExpectType Dictionary\n })\n it('iterable with property argument', () => {\n const result = map(\n (a, b) => {\n a // $ExpectType number\n b // $ExpectType string\n return `${a}`\n },\n {a: 1, b: 2}\n )\n result // $ExpectType Dictionary\n })\n it('iterable with no property argument', () => {\n const result = map(\n a => {\n a // $ExpectType number\n return `${a}`\n },\n {a: 1, b: 2}\n )\n result // $ExpectType Dictionary\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#map)\n\n### mapObjIndexed\n\n```typescript\n\nmapObjIndexed(fn: ObjectIterator, iterable: Dictionary): Dictionary\n```\n\nIt works the same way as `R.map` does for objects. It is added as Ramda also has this method.\n\nTry this R.mapObjIndexed example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmapObjIndexed(fn: ObjectIterator, iterable: Dictionary): Dictionary;\nmapObjIndexed(fn: ObjectIterator, iterable: Dictionary): Dictionary;\nmapObjIndexed(fn: ObjectIterator): (iterable: Dictionary) => Dictionary;\nmapObjIndexed(fn: ObjectIterator): (iterable: Dictionary) => Dictionary;\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {mapObjIndexed} from 'rambda'\n\nconst obj = {a: 1, b: 2, c: 3}\n\ndescribe('R.mapObjIndexed', () => {\n it('without type transform', () => {\n const result = mapObjIndexed((x, prop, obj) => {\n x // $ExpectType number\n prop // $ExpectType string\n obj // $ExpectType Dictionary\n return x + 2\n }, obj)\n result // $ExpectType Dictionary\n })\n it('without type transform - curried', () => {\n const result = mapObjIndexed((x, prop, obj) => {\n x // $ExpectType number\n prop // $ExpectType string\n obj // $ExpectType Dictionary\n return x + 2\n })(obj)\n result // $ExpectType Dictionary\n })\n it('change of type', () => {\n const result = mapObjIndexed((x, prop, obj) => {\n x // $ExpectType number\n prop // $ExpectType string\n obj // $ExpectType Dictionary\n return String(x + 2)\n }, obj)\n result // $ExpectType Dictionary\n })\n it('change of type - curried', () => {\n const result = mapObjIndexed((x, prop, obj) => {\n x // $ExpectType number\n prop // $ExpectType string\n obj // $ExpectType Dictionary\n return String(x + 2)\n })(obj)\n result // $ExpectType Dictionary\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mapObjIndexed)\n\n### match\n\n```typescript\n\nmatch(regExpression: RegExp, str: string): string[]\n```\n\nCurried version of `String.prototype.match` which returns empty array, when there is no match.\n\nTry this R.match example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmatch(regExpression: RegExp, str: string): string[];\nmatch(regExpression: RegExp): (str: string) => string[];\n```\n\n
\n\n
\n\nR.match source\n\n```javascript\nexport function match(pattern, input){\n if (arguments.length === 1) return _input => match(pattern, _input)\n\n const willReturn = input.match(pattern)\n\n return willReturn === null ? [] : willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { equals } from './equals.js'\nimport { match } from './match.js'\n\ntest('happy', () => {\n expect(match(/a./g)('foo bar baz')).toEqual([ 'ar', 'az' ])\n})\n\ntest('fallback', () => {\n expect(match(/a./g)('foo')).toEqual([])\n})\n\ntest('with string', () => {\n expect(match('a', 'foo')).toEqual([])\n expect(equals(match('o', 'foo'), [ 'o' ])).toBeTrue()\n})\n\ntest('throwing', () => {\n expect(() => {\n match(/a./g, null)\n }).toThrowErrorMatchingInlineSnapshot('\"Cannot read properties of null (reading \\'match\\')\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {match} from 'rambda'\n\nconst str = 'foo bar'\n\ndescribe('R.match', () => {\n it('happy', () => {\n const result = match(/foo/, str)\n result // $ExpectType string[]\n })\n it('curried', () => {\n const result = match(/foo/)(str)\n result // $ExpectType string[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#match)\n\n### mathMod\n\n`R.mathMod` behaves like the modulo operator should mathematically, unlike the `%` operator (and by extension, `R.modulo`). So while `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`.\n\nTry this R.mathMod example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mathMod)\n\n### max\n\nIt returns the greater value between `x` and `y`.\n\nTry this R.max example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#max)\n\n### maxBy\n\nIt returns the greater value between `x` and `y` according to `compareFn` function.\n\nTry this R.maxBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#maxBy)\n\n### mean\n\n```typescript\n\nmean(list: number[]): number\n```\n\nIt returns the mean value of `list` input.\n\nTry this R.mean example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmean(list: number[]): number;\n```\n\n
\n\n
\n\nR.mean source\n\n```javascript\nimport { sum } from './sum.js'\n\nexport function mean(list){\n return sum(list) / list.length\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { mean } from './mean.js'\n\ntest('happy', () => {\n expect(mean([ 2, 7 ])).toBe(4.5)\n})\n\ntest('with NaN', () => {\n expect(mean([])).toBeNaN()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {mean} from 'rambda'\n\ndescribe('R.mean', () => {\n it('happy', () => {\n const result = mean([1, 2, 3])\n\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mean)\n\n### median\n\n```typescript\n\nmedian(list: number[]): number\n```\n\nIt returns the median value of `list` input.\n\nTry this R.median example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmedian(list: number[]): number;\n```\n\n
\n\n
\n\nR.median source\n\n```javascript\nimport { mean } from './mean.js'\n\nexport function median(list){\n const len = list.length\n if (len === 0) return NaN\n const width = 2 - len % 2\n const idx = (len - width) / 2\n\n return mean(Array.prototype.slice\n .call(list, 0)\n .sort((a, b) => {\n if (a === b) return 0\n\n return a < b ? -1 : 1\n })\n .slice(idx, idx + width))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { median } from './median.js'\n\ntest('happy', () => {\n expect(median([ 2 ])).toBe(2)\n expect(median([ 7, 2, 10, 2, 9 ])).toBe(7)\n})\n\ntest('with empty array', () => {\n expect(median([])).toBeNaN()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {median} from 'rambda'\n\ndescribe('R.median', () => {\n it('happy', () => {\n const result = median([1, 2, 3])\n\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#median)\n\n### merge\n\nSame as `R.mergeRight`.\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#merge)\n\n### mergeAll\n\n```typescript\n\nmergeAll(list: object[]): T\n```\n\nIt merges all objects of `list` array sequentially and returns the result.\n\nTry this R.mergeAll example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmergeAll(list: object[]): T;\nmergeAll(list: object[]): object;\n```\n\n
\n\n
\n\nR.mergeAll source\n\n```javascript\nimport { map } from './map.js'\nimport { mergeRight } from './mergeRight.js'\n\nexport function mergeAll(arr){\n let willReturn = {}\n map(val => {\n willReturn = mergeRight(willReturn, val)\n }, arr)\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { mergeAll } from './mergeAll.js'\n\ntest('case 1', () => {\n const arr = [ { a : 1 }, { b : 2 }, { c : 3 } ]\n const expectedResult = {\n a : 1,\n b : 2,\n c : 3,\n }\n expect(mergeAll(arr)).toEqual(expectedResult)\n})\n\ntest('case 2', () => {\n expect(mergeAll([ { foo : 1 }, { bar : 2 }, { baz : 3 } ])).toEqual({\n foo : 1,\n bar : 2,\n baz : 3,\n })\n})\n\ndescribe('acts as if nil values are simply empty objects', () => {\n it('if the first object is nil', () => {\n expect(mergeAll([ null, { foo : 1 }, { foo : 2 }, { bar : 2 } ])).toEqual({\n foo : 2,\n bar : 2,\n })\n })\n\n it('if the last object is nil', () => {\n expect(mergeAll([ { foo : 1 }, { foo : 2 }, { bar : 2 }, undefined ])).toEqual({\n foo : 2,\n bar : 2,\n })\n })\n\n it('if an intermediate object is nil', () => {\n expect(mergeAll([ { foo : 1 }, { foo : 2 }, null, { bar : 2 } ])).toEqual({\n foo : 2,\n bar : 2,\n })\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {mergeAll} from 'rambda'\n\ndescribe('R.mergeAll', () => {\n it('with passing type', () => {\n interface Output {\n foo: number,\n bar: number,\n }\n const result = mergeAll([{foo: 1}, {bar: 2}])\n result.foo // $ExpectType number\n result.bar // $ExpectType number\n })\n\n it('without passing type', () => {\n const result = mergeAll([{foo: 1}, {bar: 2}])\n result // $ExpectType unknown\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mergeAll)\n\n### mergeDeepLeft\n\nTry this R.mergeDeepLeft example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mergeDeepLeft)\n\n### mergeDeepRight\n\n```typescript\n\nmergeDeepRight(target: object, newProps: object): Output\n```\n\nCreates a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects:\n\n - and both values are objects, the two values will be recursively merged\n - otherwise the value from the second object will be used.\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmergeDeepRight(target: object, newProps: object): Output;\nmergeDeepRight(target: object): (newProps: object) => Output;\n```\n\n
\n\n
\n\nR.mergeDeepRight source\n\n```javascript\nimport { clone } from './clone.js'\nimport { type } from './type.js'\n\nexport function mergeDeepRight(target, source){\n if (arguments.length === 1){\n return sourceHolder => mergeDeepRight(target, sourceHolder)\n }\n\n const willReturn = clone(target)\n\n Object.keys(source).forEach(key => {\n if (type(source[ key ]) === 'Object'){\n if (type(target[ key ]) === 'Object'){\n willReturn[ key ] = mergeDeepRight(target[ key ], source[ key ])\n } else {\n willReturn[ key ] = source[ key ]\n }\n } else {\n willReturn[ key ] = source[ key ]\n }\n })\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { mergeDeepRight } from './mergeDeepRight.js'\n\nconst student = {\n name : 'foo',\n age : 10,\n contact : {\n a : 1,\n email : 'foo@example.com',\n },\n}\nconst teacher = {\n age : 40,\n contact : { email : 'baz@example.com' },\n songs : { title : 'Remains the same' },\n}\n\ntest('when merging object with lists inside them', () => {\n const a = {\n a : [ 1, 2, 3 ],\n b : [ 4, 5, 6 ],\n }\n const b = {\n a : [ 7, 8, 9 ],\n b : [ 10, 11, 12 ],\n }\n const result = mergeDeepRight(a, b)\n const expected = {\n a : [ 7, 8, 9 ],\n b : [ 10, 11, 12 ],\n }\n expect(result).toEqual(expected)\n})\n\ntest('happy', () => {\n const result = mergeDeepRight(student, teacher)\n const curryResult = mergeDeepRight(student)(teacher)\n const expected = {\n age : 40,\n name : 'foo',\n contact : {\n a : 1,\n email : 'baz@example.com',\n },\n songs : { title : 'Remains the same' },\n }\n\n expect(result).toEqual(expected)\n expect(curryResult).toEqual(expected)\n})\n\ntest('issue 650', () => {\n expect(Object.keys(mergeDeepRight({ a : () => {} }, { b : () => {} }))).toEqual([\n 'a',\n 'b',\n ])\n})\n\ntest('ramda compatible test 1', () => {\n const a = {\n w : 1,\n x : 2,\n y : { z : 3 },\n }\n const b = {\n a : 4,\n b : 5,\n c : { d : 6 },\n }\n const result = mergeDeepRight(a, b)\n const expected = {\n w : 1,\n x : 2,\n y : { z : 3 },\n a : 4,\n b : 5,\n c : { d : 6 },\n }\n\n expect(result).toEqual(expected)\n})\n\ntest('ramda compatible test 2', () => {\n const a = {\n a : {\n b : 1,\n c : 2,\n },\n y : 0,\n }\n const b = {\n a : {\n b : 3,\n d : 4,\n },\n z : 0,\n }\n const result = mergeDeepRight(a, b)\n const expected = {\n a : {\n b : 3,\n c : 2,\n d : 4,\n },\n y : 0,\n z : 0,\n }\n\n expect(result).toEqual(expected)\n})\n\ntest('ramda compatible test 3', () => {\n const a = {\n w : 1,\n x : { y : 2 },\n }\n const result = mergeDeepRight(a, { x : { y : 3 } })\n const expected = {\n w : 1,\n x : { y : 3 },\n }\n expect(result).toEqual(expected)\n})\n\ntest('functions are not discarded', () => {\n const obj = { foo : () => {} }\n expect(typeof mergeDeepRight(obj, {}).foo).toBe('function')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {mergeDeepRight} from 'rambda'\n\ninterface Output {\n foo: {\n bar: number,\n },\n}\n\ndescribe('R.mergeDeepRight', () => {\n const result = mergeDeepRight({foo: {bar: 1}}, {foo: {bar: 2}})\n result.foo.bar // $ExpectType number\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mergeDeepRight)\n\n### mergeLeft\n\n```typescript\n\nmergeLeft(newProps: object, target: object): Output\n```\n\nSame as `R.merge`, but in opposite direction.\n\nTry this R.mergeLeft example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmergeLeft(newProps: object, target: object): Output;\nmergeLeft(newProps: object): (target: object) => Output;\n```\n\n
\n\n
\n\nR.mergeLeft source\n\n```javascript\nimport { mergeRight } from './mergeRight.js'\n\nexport function mergeLeft(x, y){\n if (arguments.length === 1) return _y => mergeLeft(x, _y)\n\n return mergeRight(y, x)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { mergeLeft } from './mergeLeft.js'\n\nconst obj = {\n foo : 1,\n bar : 2,\n}\n\ntest('happy', () => {\n expect(mergeLeft({ bar : 20 }, obj)).toEqual({\n foo : 1,\n bar : 20,\n })\n})\n\ntest('curry', () => {\n expect(mergeLeft({ baz : 3 })(obj)).toEqual({\n foo : 1,\n bar : 2,\n baz : 3,\n })\n})\n\ntest('when undefined or null instead of object', () => {\n expect(mergeLeft(null, undefined)).toEqual({})\n expect(mergeLeft(obj, null)).toEqual(obj)\n expect(mergeLeft(obj, undefined)).toEqual(obj)\n expect(mergeLeft(undefined, obj)).toEqual(obj)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {mergeLeft} from 'rambda'\n\ninterface Output {\n foo: number,\n bar: number,\n}\n\ndescribe('R.mergeLeft', () => {\n const result = mergeLeft({foo: 1}, {bar: 2})\n const curriedResult = mergeLeft({foo: 1})({bar: 2})\n\n result.foo // $ExpectType number\n result.bar // $ExpectType number\n curriedResult.bar // $ExpectType number\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mergeLeft)\n\n### mergeRight\n\nIt creates a copy of `target` object with overwritten `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.\n\nTry this R.mergeRight example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mergeRight)\n\n### mergeWith\n\n```typescript\n\nmergeWith(fn: (x: any, z: any) => any, a: Record, b: Record): Record\n```\n\nIt takes two objects and a function, which will be used when there is an overlap between the keys.\n\nTry this R.mergeWith example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmergeWith(fn: (x: any, z: any) => any, a: Record, b: Record): Record;\nmergeWith(fn: (x: any, z: any) => any, a: Record, b: Record): Output;\nmergeWith(fn: (x: any, z: any) => any, a: Record): (b: Record) => Record;\nmergeWith(fn: (x: any, z: any) => any, a: Record): (b: Record) => Output;\nmergeWith(fn: (x: any, z: any) => any): (a: U, b: V) => Record;\nmergeWith(fn: (x: any, z: any) => any): (a: U, b: V) => Output;\n```\n\n
\n\n
\n\nR.mergeWith source\n\n```javascript\nimport { curry } from './curry.js'\n\nexport function mergeWithFn(\n mergeFn, aInput, bInput\n){\n const a = aInput ?? {}\n const b = bInput ?? {}\n const willReturn = {}\n\n Object.keys(a).forEach(key => {\n if (b[ key ] === undefined) willReturn[ key ] = a[ key ]\n else willReturn[ key ] = mergeFn(a[ key ], b[ key ])\n })\n\n Object.keys(b).forEach(key => {\n if (willReturn[ key ] !== undefined) return\n\n if (a[ key ] === undefined) willReturn[ key ] = b[ key ]\n else willReturn[ key ] = mergeFn(a[ key ], b[ key ])\n })\n\n return willReturn\n}\n\nexport const mergeWith = curry(mergeWithFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { concat } from './concat.js'\nimport { mergeWithFn } from './mergeWith.js'\n\ntest('happy', () => {\n const result = mergeWithFn(\n concat,\n {\n a : true,\n values : [ 10, 20 ],\n },\n {\n b : true,\n values : [ 15, 35 ],\n }\n )\n const expected = {\n a : true,\n b : true,\n values : [ 10, 20, 15, 35 ],\n }\n expect(result).toEqual(expected)\n})\n\n// https://github.com/ramda/ramda/pull/3222/files#diff-d925d9188b478d2f1d4b26012c6dddac374f9e9d7a336604d654b9a113bfc857\ndescribe('acts as if nil values are simply empty objects', () => {\n it('if the first object is nil and the second empty', () => {\n expect(mergeWithFn(\n concat, undefined, {}\n )).toEqual({})\n })\n\n it('if the first object is empty and the second nil', () => {\n expect(mergeWithFn(\n concat, {}, null\n )).toEqual({})\n })\n\n it('if both objects are nil', () => {\n expect(mergeWithFn(\n concat, undefined, null\n )).toEqual({})\n })\n\n it('if the first object is not empty and the second is nil', () => {\n expect(mergeWithFn(\n concat, { a : 'a' }, null\n )).toEqual({ a : 'a' })\n })\n\n it('if the first object is nil and the second is not empty', () => {\n expect(mergeWithFn(\n concat, undefined, { a : 'a' }\n )).toEqual({ a : 'a' })\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {concat, mergeWith} from 'rambda'\n\ninterface Output {\n a: boolean,\n b: boolean,\n values: number[],\n}\nconst A = {\n a: true,\n values: [10, 20],\n}\nconst B = {\n b: true,\n values: [15, 35],\n}\n\ndescribe('R.mergeWith', () => {\n test('no curry | without explicit types', () => {\n const result = mergeWith(concat, A, B)\n result // $ExpectType Record\n })\n test('no curry | with explicit types', () => {\n const result = mergeWith(concat, A, B)\n result // $ExpectType Output\n })\n test('curry 1 | without explicit types', () => {\n const result = mergeWith(concat, A)(B)\n result // $ExpectType Record\n })\n test('curry 1 | with explicit types', () => {\n const result = mergeWith(concat, A)(B)\n result // $ExpectType Output\n })\n test('curry 2 | without explicit types', () => {\n const result = mergeWith(concat)(A, B)\n result // $ExpectType Record\n })\n test('curry 2 | with explicit types', () => {\n const result = mergeWith(concat)(A, B)\n result // $ExpectType Output\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#mergeWith)\n\n### min\n\nIt returns the lesser value between `x` and `y`.\n\nTry this R.min example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#min)\n\n### minBy\n\nIt returns the lesser value between `x` and `y` according to `compareFn` function.\n\nTry this R.minBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#minBy)\n\n### modify\n\n```typescript\n\nmodify(prop: K, fn: (value: T) => T): >(object: U) => U\n```\n\nTry this R.modify example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nmodify(prop: K, fn: (value: T) => T): >(object: U) => U;\nmodify(prop: K, fn: (value: U[K]) => U[K], object: U): U;\nmodify(prop: K): {\n (fn: (value: T) => T): >(object: U) => U;\n >(fn: (value: T) => T, object: U): U;\n};\n```\n\n
\n\n
\n\nR.modify source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { isIterable } from './_internals/isIterable.js'\nimport { curry } from './curry.js'\nimport { updateFn } from './update.js'\n\nfunction modifyFn(\n property, fn, iterable\n){\n if (!isIterable(iterable)) return iterable\n if (iterable[ property ] === undefined) return iterable\n if (isArray(iterable)){\n return updateFn(\n property, fn(iterable[ property ]), iterable\n )\n }\n\n return {\n ...iterable,\n [ property ] : fn(iterable[ property ]),\n }\n}\n\nexport const modify = curry(modifyFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { modify as modifyRamda } from 'ramda'\n\nimport { compareCombinations, FALSY_VALUES } from './_internals/testUtils.js'\nimport { add } from './add.js'\nimport { compose } from './compose.js'\nimport { modify } from './modify.js'\n\nconst person = {\n name : 'foo',\n age : 20,\n}\n\ntest('happy', () => {\n expect(modify(\n 'age', x => x + 1, person\n )).toEqual({\n name : 'foo',\n age : 21,\n })\n})\n\ntest('property is missing', () => {\n expect(modify(\n 'foo', x => x + 1, person\n )).toEqual(person)\n})\n\ntest('adjust if `array` at the given key with the `transformation` function', () => {\n expect(modify(\n 1, add(1), [ 100, 1400 ]\n )).toEqual([ 100, 1401 ])\n})\n\ndescribe('ignores transformations if the input value is not Array and Object', () => {\n ;[ 42, undefined, null, '' ].forEach(value => {\n it(`${ value }`, () => {\n expect(modify(\n 'a', add(1), value\n )).toEqual(value)\n })\n })\n})\n\nconst possibleProperties = [ ...FALSY_VALUES, 'foo', 0 ]\nconst possibleTransformers = [\n ...FALSY_VALUES,\n add(1),\n add('foo'),\n compose,\n String,\n]\nconst possibleObjects = [\n ...FALSY_VALUES,\n {},\n [ 1, 2, 3 ],\n {\n a : 1,\n foo : 2,\n },\n {\n a : 1,\n foo : [ 1 ],\n },\n {\n a : 1,\n foo : 'bar',\n },\n]\n\ndescribe('brute force', () => {\n compareCombinations({\n fn : modify,\n fnRamda : modifyRamda,\n firstInput : possibleProperties,\n secondInput : possibleTransformers,\n thirdInput : possibleObjects,\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n {\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 0,\n \"RESULTS_MISMATCH\": 0,\n \"SHOULD_NOT_THROW\": 0,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 630,\n }\n `)\n },\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport { add, identity, map, modify, pipe, toUpper } from 'rambda';\n\ntype Obj = {\n\tfoo: string;\n\tbar: number;\n};\n\ndescribe('R.modify', () => {\n\tit('ramda tests', () => {\n\t\tconst result1 = modify('foo', toUpper, {} as Obj);\n\t\tresult1; // $ExpectType Obj\n\n\t\tconst result2 = modify('bar', add(1), {} as Obj);\n\t\tresult2; // $ExpectType Obj\n\n\t\tconst result3 = modify('foo', toUpper)({} as Obj);\n\t\tresult3; // $ExpectType Obj\n\n\t\tconst result4 = modify('bar', add(1))({} as Obj);\n\t\tresult4; // $ExpectType Obj\n\n\t\tconst result5 = modify('foo')(toUpper)({} as Obj);\n\t\tresult5; // $ExpectType Obj\n\n\t\tconst result6 = modify('bar')(add(1))({} as Obj);\n\t\tresult6; // $ExpectType Obj\n\n\t\tconst result7 = modify('foo')(toUpper, {} as Obj);\n\t\tresult7; // $ExpectType Obj\n\n\t\tconst result8 = modify('bar')(add(1), {} as Obj);\n\t\tresult8; // $ExpectType Obj\n\n\t\tconst result9 = modify('foo', identity, {} as Obj);\n\t\tresult9; // $ExpectType Obj\n\n\t\t// @ts-expect-error\n\t\tmodify('foo', add(1), {} as Obj);\n\t\t// @ts-expect-error\n\t\tmodify('bar', toUpper, {} as Obj);\n\n\t\tconst f = pipe(map(modify('foo', toUpper)));\n\n\t\tf([] as Obj[]); // $ExpectType Obj[]\n\t});\n});\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#modify)\n\n### modifyPath\n\nIt changes a property of object on the base of provided path and transformer function.\n\nTry this R.modifyPath example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#modifyPath)\n\n### modulo\n\nCurried version of `x%y`.\n\nTry this R.modulo example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#modulo)\n\n### move\n\nIt returns a copy of `list` with exchanged `fromIndex` and `toIndex` elements.\n\nTry this R.move example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#move)\n\n### multiply\n\nCurried version of `x*y`.\n\nTry this R.multiply example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#multiply)\n\n### negate\n\nTry this R.negate example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#negate)\n\n### none\n\n```typescript\n\nnone(predicate: (x: T) => boolean, list: T[]): boolean\n```\n\nIt returns `true`, if all members of array `list` returns `false`, when applied as argument to `predicate` function.\n\nTry this R.none example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nnone(predicate: (x: T) => boolean, list: T[]): boolean;\nnone(predicate: (x: T) => boolean): (list: T[]) => boolean;\n```\n\n
\n\n
\n\nR.none source\n\n```javascript\nexport function none(predicate, list){\n if (arguments.length === 1) return _list => none(predicate, _list)\n\n for (let i = 0; i < list.length; i++){\n if (predicate(list[ i ])) return false\n }\n\n return true\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { none } from './none.js'\n\nconst isEven = n => n % 2 === 0\n\ntest('when true', () => {\n expect(none(isEven, [ 1, 3, 5, 7 ])).toBeTrue()\n})\n\ntest('when false curried', () => {\n expect(none(input => input > 1, [ 1, 2, 3 ])).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {none} from 'rambda'\n\ndescribe('R.none', () => {\n it('happy', () => {\n const result = none(\n x => {\n x // $ExpectType number\n return x > 0\n },\n [1, 2, 3]\n )\n result // $ExpectType boolean\n })\n it('curried needs a type', () => {\n const result = none(x => {\n x // $ExpectType number\n return x > 0\n })([1, 2, 3])\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#none)\n\n### not\n\n```typescript\n\nnot(input: any): boolean\n```\n\nIt returns a boolean negated version of `input`.\n\nTry this R.not example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nnot(input: any): boolean;\n```\n\n
\n\n
\n\nR.not source\n\n```javascript\nexport function not(input){\n return !input\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { not } from './not.js'\n\ntest('not', () => {\n expect(not(false)).toBeTrue()\n expect(not(true)).toBeFalse()\n expect(not(0)).toBeTrue()\n expect(not(1)).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {not} from 'rambda'\n\ndescribe('R.not', () => {\n it('happy', () => {\n const result = not(4)\n\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#not)\n\n### nth\n\n```typescript\n\nnth(index: number, input: string): string\n```\n\nCurried version of `input[index]`.\n\nTry this R.nth example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nnth(index: number, input: string): string;\t\nnth(index: number, input: T[]): T | undefined;\t\nnth(n: number): {\n (input: T[]): T | undefined;\n (input: string): string;\n};\n```\n\n
\n\n
\n\nR.nth source\n\n```javascript\nexport function nth(index, input){\n if (arguments.length === 1) return _input => nth(index, _input)\n\n const idx = index < 0 ? input.length + index : index\n\n return Object.prototype.toString.call(input) === '[object String]' ?\n input.charAt(idx) :\n input[ idx ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { nth } from './nth.js'\n\ntest('happy', () => {\n expect(nth(2, [ 1, 2, 3, 4 ])).toBe(3)\n})\n\ntest('with curry', () => {\n expect(nth(2)([ 1, 2, 3, 4 ])).toBe(3)\n})\n\ntest('with string and correct index', () => {\n expect(nth(2)('foo')).toBe('o')\n})\n\ntest('with string and invalid index', () => {\n expect(nth(20)('foo')).toBe('')\n})\n\ntest('with negative index', () => {\n expect(nth(-3)([ 1, 2, 3, 4 ])).toBe(2)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {nth} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.nth', () => {\n it('happy', () => {\n const result = nth(4, list)\n\n result // $ExpectType number | undefined\n })\n it('curried', () => {\n const result = nth(1)(list)\n\n result // $ExpectType number | undefined\n })\n})\n\ndescribe('R.nth - string', () => {\n const str = 'abc'\n it('happy', () => {\n const result = nth(4, str)\n\n result // $ExpectType string\n })\n it('curried', () => {\n const result = nth(1)(str)\n\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#nth)\n\n### objOf\n\nIt creates an object with a single key-value pair.\n\nTry this R.objOf example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#objOf)\n\n### of\n\n```typescript\n\nof(x: T): T[]\n```\n\nTry this R.of example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nof(x: T): T[];\n```\n\n
\n\n
\n\nR.of source\n\n```javascript\nexport function of(value){\n return [ value ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { of } from './of.js'\n\ntest('happy', () => {\n expect(of(3)).toEqual([ 3 ])\n\n expect(of(null)).toEqual([ null ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {of} from 'rambda'\n\nconst list = [1, 2, 3]\n\ndescribe('R.of', () => {\n it('happy', () => {\n const result = of(4)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = of(list)\n\n result // $ExpectType number[][]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#of)\n\n### omit\n\n```typescript\n\nomit(propsToOmit: K[], obj: T): Omit\n```\n\nIt returns a partial copy of an `obj` without `propsToOmit` properties.\n\nTry this R.omit example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nomit(propsToOmit: K[], obj: T): Omit;\nomit(propsToOmit: K[]): (obj: T) => Omit;\nomit(propsToOmit: string, obj: T): U;\nomit(propsToOmit: string): (obj: T) => U;\nomit(propsToOmit: string, obj: object): T;\nomit(propsToOmit: string): (obj: object) => T;\n```\n\n
\n\n
\n\nR.omit source\n\n```javascript\nimport { createPath } from './_internals/createPath.js'\nimport { includes } from './_internals/includes.js'\n\nexport function omit(propsToOmit, obj){\n if (arguments.length === 1) return _obj => omit(propsToOmit, _obj)\n\n if (obj === null || obj === undefined)\n return undefined\n\n const propsToOmitValue = createPath(propsToOmit, ',')\n const willReturn = {}\n\n for (const key in obj)\n if (!includes(key, propsToOmitValue))\n willReturn[ key ] = obj[ key ]\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { omit } from './omit.js'\n\ntest('with string as condition', () => {\n const obj = {\n a : 1,\n b : 2,\n c : 3,\n }\n const result = omit('a,c', obj)\n const resultCurry = omit('a,c')(obj)\n const expectedResult = { b : 2 }\n\n expect(result).toEqual(expectedResult)\n expect(resultCurry).toEqual(expectedResult)\n})\n\ntest.only('with number as property to omit', () => {\n const obj = {\n 1 : 1,\n b : 2,\n }\n const result = omit([ 1 ], obj)\n expect(result).toEqual({ b : 2 })\n})\n\ntest('with null', () => {\n expect(omit('a,b', null)).toBeUndefined()\n})\n\ntest('happy', () => {\n expect(omit([ 'a', 'c' ])({\n a : 'foo',\n b : 'bar',\n c : 'baz',\n })).toEqual({ b : 'bar' })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {omit} from 'rambda'\n\ndescribe('R.omit with array as props input', () => {\n it('allow Typescript to infer object type', () => {\n const input = {a: 'foo', b: 2, c: 3, d: 4}\n const result = omit(['b,c'], input)\n\n result.a // $ExpectType string\n result.d // $ExpectType number\n\n const curriedResult = omit(['a,c'], input)\n\n curriedResult.a // $ExpectType string\n curriedResult.d // $ExpectType number\n })\n\n it('declare type of input object', () => {\n interface Input {\n a: string,\n b: number,\n c: number,\n d: number,\n }\n const input: Input = {a: 'foo', b: 2, c: 3, d: 4}\n const result = omit(['b,c'], input)\n result // $ExpectType Omit\n\n result.a // $ExpectType string\n result.d // $ExpectType number\n\n const curriedResult = omit(['a,c'], input)\n\n curriedResult.a // $ExpectType string\n curriedResult.d // $ExpectType number\n })\n})\n\ndescribe('R.omit with string as props input', () => {\n interface Output {\n b: number,\n d: number,\n }\n\n it('explicitly declare output', () => {\n const result = omit('a,c', {a: 1, b: 2, c: 3, d: 4})\n result // $ExpectType Output\n result.b // $ExpectType number\n\n const curriedResult = omit('a,c')({a: 1, b: 2, c: 3, d: 4})\n\n curriedResult.b // $ExpectType number\n })\n\n it('explicitly declare input and output', () => {\n interface Input {\n a: number,\n b: number,\n c: number,\n d: number,\n }\n const result = omit('a,c', {a: 1, b: 2, c: 3, d: 4})\n result // $ExpectType Output\n result.b // $ExpectType number\n\n const curriedResult = omit('a,c')({\n a: 1,\n b: 2,\n c: 3,\n d: 4,\n })\n\n curriedResult.b // $ExpectType number\n })\n\n it('without passing type', () => {\n const result = omit('a,c', {a: 1, b: 2, c: 3, d: 4})\n result // $ExpectType unknown\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#omit)\n\n### on\n\nIt passes the two inputs through `unaryFn` and then the results are passed as inputs the the `binaryFn` to receive the final result(`binaryFn(unaryFn(FIRST_INPUT), unaryFn(SECOND_INPUT))`). \n\nThis method is also known as P combinator.\n\nTry this R.on example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#on)\n\n### once\n\n```typescript\n\nonce(fn: T, context?: C): T\n```\n\nIt returns a function, which invokes only once `fn` function.\n\nTry this R.once example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nonce(fn: T, context?: C): T;\n```\n\n
\n\n
\n\nR.once source\n\n```javascript\nimport { curry } from './curry.js'\n\nfunction onceFn(fn, context){\n let result\n\n return function (){\n if (fn){\n result = fn.apply(context || this, arguments)\n fn = null\n }\n\n return result\n }\n}\n\nexport function once(fn, context){\n if (arguments.length === 1){\n const wrap = onceFn(fn, context)\n\n return curry(wrap)\n }\n\n return onceFn(fn, context)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { once } from './once.js'\n\ntest('with counter', () => {\n let counter = 0\n const runOnce = once(x => {\n counter++\n\n return x + 2\n })\n expect(runOnce(1)).toBe(3)\n runOnce(1)\n runOnce(1)\n runOnce(1)\n expect(counter).toBe(1)\n})\n\ntest('happy path', () => {\n const addOneOnce = once((\n a, b, c\n ) => a + b + c, 1)\n\n expect(addOneOnce(\n 10, 20, 30\n )).toBe(60)\n expect(addOneOnce(40)).toBe(60)\n})\n\ntest('with context', () => {\n const context = { name: 'fris' }\n const getNameOnce = once(function (){\n return this.name\n }, context)\n\n expect(getNameOnce()).toBe('fris')\n expect(getNameOnce()).toBe('fris')\n expect(getNameOnce()).toBe('fris')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {once} from 'rambda'\n\ndescribe('R.once', () => {\n it('happy', () => {\n const runOnce = once((x: number) => {\n return x + 2\n })\n\n const result = runOnce(1)\n result // $ExpectType number\n })\n it('with context', () => {\n const runOnce = once(function (this: any, x: number) {\n return x + 2\n })\n\n const result = runOnce.call({}, 1)\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#once)\n\n### or\n\nLogical OR\n\nTry this R.or example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#or)\n\n### over\n\n```typescript\n\nover(lens: Lens): {\n (fn: (a: A) => A): (value: S) => S\n```\n\nIt returns a copied **Object** or **Array** with modified value received by applying function `fn` to `lens` focus.\n\nTry this R.over example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nover(lens: Lens): {\n (fn: (a: A) => A): (value: S) => S;\n (fn: (a: A) => A, value: S): S;\n};\nover(lens: Lens, fn: (a: A) => A): (value: S) => S;\nover(lens: Lens, fn: (a: A) => A, value: S): S;\n```\n\n
\n\n
\n\nR.over source\n\n```javascript\nimport { curry } from './curry.js'\n\nconst Identity = x => ({\n x,\n map : fn => Identity(fn(x)),\n})\n\nfunction overFn(\n lens, fn, object\n){\n return lens(x => Identity(fn(x)))(object).x\n}\n\nexport const over = curry(overFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { assoc } from './assoc.js'\nimport { lens } from './lens.js'\nimport { lensIndex } from './lensIndex.js'\nimport { lensPath } from './lensPath.js'\nimport { over } from './over.js'\nimport { prop } from './prop.js'\nimport { toUpper } from './toUpper.js'\n\nconst testObject = {\n foo : 'bar',\n baz : {\n a : 'x',\n b : 'y',\n },\n}\n\ntest('assoc lens', () => {\n const assocLens = lens(prop('foo'), assoc('foo'))\n const result = over(\n assocLens, toUpper, testObject\n )\n const expected = {\n ...testObject,\n foo : 'BAR',\n }\n expect(result).toEqual(expected)\n})\n\ntest('path lens', () => {\n const pathLens = lensPath('baz.a')\n const result = over(\n pathLens, toUpper, testObject\n )\n const expected = {\n ...testObject,\n baz : {\n a : 'X',\n b : 'y',\n },\n }\n expect(result).toEqual(expected)\n})\n\ntest('index lens', () => {\n const indexLens = lensIndex(0)\n const result = over(indexLens, toUpper)([ 'foo', 'bar' ])\n expect(result).toEqual([ 'FOO', 'bar' ])\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#over)\n\n### partial\n\n```typescript\n\npartial(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T\n```\n\nIt is very similar to `R.curry`, but you can pass initial arguments when you create the curried function.\n\n`R.partial` will keep returning a function until all the arguments that the function `fn` expects are passed.\nThe name comes from the fact that you partially inject the inputs.\n\nTry this R.partial example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npartial(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T;\npartial(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T;\npartial(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T;\npartial(\n fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,\n args: [V0, V1, V2],\n): (x2: V3) => T;\npartial(\n fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,\n args: [V0, V1],\n): (x2: V2, x3: V3) => T;\npartial(\n fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,\n args: [V0],\n): (x1: V1, x2: V2, x3: V3) => T;\npartial(fn: (...a: any[]) => T, args: any[]): (...a: any[]) => T;\n```\n\n
\n\n
\n\nR.partial source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function partial(fn, ...args){\n const len = fn.length\n\n // If a single array argument is given, those are the args (a la Ramda).\n // Otherwise, the variadic arguments are the args.\n const argList = args.length === 1 && isArray(args[0]) ? args[0] : args\n\n return (...rest) => {\n if (argList.length + rest.length >= len){\n return fn(...argList, ...rest)\n }\n\n return partial(fn, ...[ ...argList, ...rest ])\n }\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { partial } from './partial.js'\nimport { type } from './type.js'\n\nconst greet = (\n salutation, title, firstName, lastName\n) =>\n [salutation, title, firstName, lastName]\n\ntest('happy', () => {\n const canPassAnyNumberOfArguments = partial(\n greet, 'Hello', 'Ms.'\n )\n const fn = canPassAnyNumberOfArguments('foo')\n const sayHello = partial(greet, [ 'Hello' ])\n const sayHelloRamda = partial(sayHello, [ 'Ms.' ])\n\n expect(type(fn)).toBe('Function')\n\n expect(fn('bar')).toStrictEqual(['Hello', 'Ms.', 'foo', 'bar'])\n expect(sayHelloRamda('foo', 'bar')).toStrictEqual(['Hello', 'Ms.', 'foo', 'bar'])\n})\n\ntest('extra arguments are ignored', () => {\n const canPassAnyNumberOfArguments = partial(\n greet, 'Hello', 'Ms.'\n )\n const fn = canPassAnyNumberOfArguments('foo')\n\n expect(type(fn)).toBe('Function')\n\n expect(fn(\n 'bar', 1, 2\n )).toStrictEqual(['Hello', 'Ms.', 'foo', 'bar'])\n})\n\ntest('when array is input', () => {\n const fooFn = (\n a, b, c, d\n ) => ({\n a,\n b,\n c,\n d,\n })\n const barFn = partial(\n fooFn, [ 1, 2 ], []\n )\n\n expect(barFn(1, 2)).toEqual({\n a : [ 1, 2 ],\n b : [],\n c : 1,\n d : 2,\n })\n})\n\ntest('ramda spec', () => {\n const sayHello = partial(greet, 'Hello')\n const sayHelloToMs = partial(sayHello, 'Ms.')\n\n expect(sayHelloToMs('Jane', 'Jones')).toStrictEqual(['Hello', 'Ms.', 'Jane', 'Jones'])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {partial} from 'rambda'\n\ndescribe('R.partial', () => {\n it('happy', () => {\n function fn(\n aString: string,\n aNumber: number,\n aBoolean: boolean,\n aNull: null\n ) {\n return {aString, aNumber, aBoolean, aNull}\n }\n\n // @ts-expect-error\n partial(fn, 1)\n\n const fn1 = partial(fn, ['a'])\n partial(fn1, ['b'])\n\n const fn2 = partial(fn1, [2])\n const result = fn2(true, null)\n result // $ExpectType { aString: string; aNumber: number; aBoolean: boolean; aNull: null; }\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#partial)\n\n### partialObject\n\n```typescript\n\npartialObject(\n fn: (input: Input) => Output, \n partialInput: PartialInput,\n): (input: Pick>) => Output\n```\n\n`R.partialObject` is a curry helper designed specifically for functions accepting object as a single argument.\n\nInitially the function knows only a part from the whole input object and then `R.partialObject` helps in preparing the function for the second part, when it receives the rest of the input.\n\nTry this R.partialObject example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npartialObject(\n fn: (input: Input) => Output, \n partialInput: PartialInput,\n): (input: Pick>) => Output;\n```\n\n
\n\n
\n\nR.partialObject source\n\n```javascript\nimport { mergeDeepRight } from './mergeDeepRight.js'\n\nexport function partialObject(fn, input){\n return nextInput => fn(mergeDeepRight(nextInput, input))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { delay } from './delay.js'\nimport { partialObject } from './partialObject.js'\nimport { type } from './type.js'\n\ntest('with plain function', () => {\n const fn = ({ a, b, c }) => a + b + c\n const curried = partialObject(fn, { a : 1 })\n\n expect(type(curried)).toBe('Function')\n expect(curried({\n b : 2,\n c : 3,\n })).toBe(6)\n})\n\ntest('with function that throws an error', () => {\n const fn = ({ a, b, c }) => {\n throw new Error('foo')\n }\n const curried = partialObject(fn, { a : 1 })\n\n expect(type(curried)).toBe('Function')\n expect(() =>\n curried({\n b : 2,\n c : 3,\n })).toThrowErrorMatchingInlineSnapshot('\"foo\"')\n})\n\ntest('with async', async () => {\n const fn = async ({ a, b, c }) => {\n await delay(100)\n\n return a + b + c\n }\n\n const curried = partialObject(fn, { a : 1 })\n\n const result = await curried({\n b : 2,\n c : 3,\n })\n\n expect(result).toBe(6)\n})\n\ntest('async function throwing an error', async () => {\n const fn = async ({ a, b, c }) => {\n await delay(100)\n throw new Error('foo')\n }\n\n const curried = partialObject(fn, { a : 1 })\n\n try {\n await curried({\n b : 2,\n c : 3,\n })\n expect(true).toBeFalsy()\n } catch (e){\n expect(e.message).toBe('foo')\n }\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {partialObject, delay} from 'rambda'\n\ndescribe('R.partialObject', () => {\n it('happy', () => {\n interface Input {\n a: number,\n b: number,\n c: string,\n }\n const fn = ({a, b, c}: Input) => a + b + c\n const curried = partialObject(fn, {a: 1})\n const result = curried({\n b: 2,\n c: 'foo',\n })\n result // $ExpectType string\n })\n it('asynchronous', async() => {\n interface Input {\n a: number,\n b: number,\n c: string,\n }\n const fn = async({a, b, c}: Input) => {\n await delay(100)\n return a + b + c\n }\n const curried = partialObject(fn, {a: 1})\n const result = await curried({\n b: 2,\n c: 'foo',\n })\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#partialObject)\n\n### partition\n\n```typescript\n\npartition(\n predicate: Predicate,\n input: T[]\n): [T[], T[]]\n```\n\nIt will return array of two objects/arrays according to `predicate` function. The first member holds all instances of `input` that pass the `predicate` function, while the second member - those who doesn't.\n\nTry this R.partition example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npartition(\n predicate: Predicate,\n input: T[]\n): [T[], T[]];\npartition(\n predicate: Predicate\n): (input: T[]) => [T[], T[]];\npartition(\n predicate: (x: T, prop?: string) => boolean,\n input: { [key: string]: T}\n): [{ [key: string]: T}, { [key: string]: T}];\npartition(\n predicate: (x: T, prop?: string) => boolean\n): (input: { [key: string]: T}) => [{ [key: string]: T}, { [key: string]: T}];\n```\n\n
\n\n
\n\nR.partition source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function partitionObject(predicate, iterable){\n const yes = {}\n const no = {}\n Object.entries(iterable).forEach(([ prop, value ]) => {\n if (predicate(value, prop)){\n yes[ prop ] = value\n } else {\n no[ prop ] = value\n }\n })\n\n return [ yes, no ]\n}\n\nexport function partitionArray(\n predicate, list, indexed = false\n){\n const yes = []\n const no = []\n let counter = -1\n\n while (counter++ < list.length - 1){\n if (\n indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])\n ){\n yes.push(list[ counter ])\n } else {\n no.push(list[ counter ])\n }\n }\n\n return [ yes, no ]\n}\n\nexport function partition(predicate, iterable){\n if (arguments.length === 1){\n return listHolder => partition(predicate, listHolder)\n }\n if (!isArray(iterable)) return partitionObject(predicate, iterable)\n\n return partitionArray(predicate, iterable)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { partition } from './partition.js'\n\ntest('with array', () => {\n const predicate = x => x > 2\n const list = [ 1, 2, 3, 4 ]\n\n const result = partition(predicate, list)\n const expectedResult = [\n [ 3, 4 ],\n [ 1, 2 ],\n ]\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('with object', () => {\n const predicate = (value, prop) => {\n expect(typeof prop).toBe('string')\n\n return value > 2\n }\n const hash = {\n a : 1,\n b : 2,\n c : 3,\n d : 4,\n }\n\n const result = partition(predicate)(hash)\n const expectedResult = [\n {\n c : 3,\n d : 4,\n },\n {\n a : 1,\n b : 2,\n },\n ]\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('readme example', () => {\n const list = [ 1, 2, 3 ]\n const obj = {\n a : 1,\n b : 2,\n c : 3,\n }\n const predicate = x => x > 2\n\n const result = [ partition(predicate, list), partition(predicate, obj) ]\n const expected = [\n [ [ 3 ], [ 1, 2 ] ],\n [\n { c : 3 },\n {\n a : 1,\n b : 2,\n },\n ],\n ]\n expect(result).toEqual(expected)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {partition} from 'rambda'\n\ndescribe('R.partition', () => {\n it('with array', () => {\n const predicate = (x: number) => {\n return x > 2\n }\n const list = [1, 2, 3, 4]\n\n const result = partition(predicate, list)\n const curriedResult = partition(predicate)(list)\n result // $ExpectType [number[], number[]]\n curriedResult // $ExpectType [number[], number[]]\n })\n\n /*\n revert to old version of `dtslint` and `R.partition` typing\n as there is diff between VSCode types(correct) and dtslint(incorrect)\n \n it('with object', () => {\n const predicate = (value: number, prop?: string) => {\n return value > 2\n }\n const hash = {\n a: 1,\n b: 2,\n c: 3,\n d: 4,\n }\n \n const result = partition(predicate, hash)\n const curriedResult = partition(predicate)(hash)\n result[0] // $xExpectType { [key: string]: number; }\n result[1] // $xExpectType { [key: string]: number; }\n curriedResult[0] // $xExpectType { [key: string]: number; }\n curriedResult[1] // $xExpectType { [key: string]: number; }\n })\n */\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#partition)\n\n### path\n\n```typescript\n\npath(path: [K0], obj: S): S[K0]\n```\n\nIf `pathToSearch` is `'a.b'` then it will return `1` if `obj` is `{a:{b:1}}`.\n\nIt will return `undefined`, if such path is not found.\n\nTry this R.path example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npath(path: [K0], obj: S): S[K0];\npath(path: [K0, K1], obj: S): S[K0][K1];\npath<\n S,\n K0 extends keyof S = keyof S,\n K1 extends keyof S[K0] = keyof S[K0],\n K2 extends keyof S[K0][K1] = keyof S[K0][K1]\n>(path: [K0, K1, K2], obj: S): S[K0][K1][K2];\npath<\n S,\n K0 extends keyof S = keyof S,\n K1 extends keyof S[K0] = keyof S[K0],\n K2 extends keyof S[K0][K1] = keyof S[K0][K1],\n K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],\n>(path: [K0, K1, K2, K3], obj: S): S[K0][K1][K2][K3];\npath<\n S,\n K0 extends keyof S = keyof S,\n K1 extends keyof S[K0] = keyof S[K0],\n K2 extends keyof S[K0][K1] = keyof S[K0][K1],\n K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],\n K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],\n>(path: [K0, K1, K2, K3, K4], obj: S): S[K0][K1][K2][K3][K4];\npath<\n S,\n K0 extends keyof S = keyof S,\n K1 extends keyof S[K0] = keyof S[K0],\n K2 extends keyof S[K0][K1] = keyof S[K0][K1],\n K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],\n K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],\n K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4],\n>(path: [K0, K1, K2, K3, K4, K5], obj: S): S[K0][K1][K2][K3][K4][K5];\npath(pathToSearch: string, obj: any): T | undefined;\npath(pathToSearch: string): (obj: any) => T | undefined;\npath(pathToSearch: RamdaPath): (obj: any) => T | undefined;\npath(pathToSearch: RamdaPath, obj: any): T | undefined;\n```\n\n
\n\n
\n\nR.path source\n\n```javascript\nimport { createPath } from './_internals/createPath.js'\n\nexport function pathFn(pathInput, obj){\n let willReturn = obj\n let counter = 0\n\n const pathArrValue = createPath(pathInput)\n\n while (counter < pathArrValue.length){\n if (willReturn === null || willReturn === undefined){\n return undefined\n }\n if (willReturn[ pathArrValue[ counter ] ] === null) return undefined\n\n willReturn = willReturn[ pathArrValue[ counter ] ]\n counter++\n }\n\n return willReturn\n}\n\nexport function path(pathInput, obj){\n if (arguments.length === 1) return _obj => path(pathInput, _obj)\n\n if (obj === null || obj === undefined){\n return undefined\n }\n\n return pathFn(pathInput, obj)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { path } from './path.js'\n\ntest('with array inside object', () => {\n const obj = { a : { b : [ 1, { c : 1 } ] } }\n\n expect(path('a.b.1.c', obj)).toBe(1)\n})\n\ntest('works with undefined', () => {\n const obj = { a : { b : { c : 1 } } }\n\n expect(path('a.b.c.d.f', obj)).toBeUndefined()\n expect(path('foo.babaz', undefined)).toBeUndefined()\n expect(path('foo.babaz')(undefined)).toBeUndefined()\n})\n\ntest('works with string instead of array', () => {\n expect(path('foo.bar.baz')({ foo : { bar : { baz : 'yes' } } })).toBe('yes')\n})\n\ntest('path', () => {\n expect(path([ 'foo', 'bar', 'baz' ])({ foo : { bar : { baz : 'yes' } } })).toBe('yes')\n expect(path([ 'foo', 'bar', 'baz' ])(null)).toBeUndefined()\n expect(path([ 'foo', 'bar', 'baz' ])({ foo : { bar : 'baz' } })).toBeUndefined()\n})\n\ntest('with number string in between', () => {\n\texpect(path(['a','1','b'], {a: [{b: 1}, {b: 2}]})).toBe(2)\n})\n\ntest('null is not a valid path', () => {\n expect(path('audio_tracks', {\n a : 1,\n audio_tracks : null,\n })).toBeUndefined()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {path} from 'rambda'\n\nconst input = {a: {b: {c: true}}}\n\ndescribe('R.path with string as path', () => {\n it('without specified output type', () => {\n // $ExpectType unknown\n path('a.b.c', input)\n // $ExpectType unknown\n path('a.b.c')(input)\n })\n it('with specified output type', () => {\n // $ExpectType boolean | undefined\n path('a.b.c', input)\n // $ExpectType boolean | undefined\n path('a.b.c')(input)\n })\n})\n\ndescribe('R.path with list as path', () => {\n it('with array as path', () => {\n // $ExpectType boolean\n path(['a', 'b', 'c'], input)\n // $ExpectType unknown\n path(['a', 'b', 'c'])(input)\n })\n test('shallow property', () => {\n // $ExpectType number\n path(['a'], {a: 1})\n\n // $ExpectType unknown\n path(['b'], {a: 1})\n })\n test('deep property', () => {\n const testObject = {a: {b: {c: {d: {e: {f: 1}}}}}}\n const result = path(['a', 'b', 'c', 'd', 'e', 'f'], testObject)\n // $ExpectType number\n result\n const curriedResult = path(['a', 'b', 'c', 'd', 'e', 'f'])(testObject)\n // $ExpectType unknown\n curriedResult\n })\n test('issue #668 - path is not correct', () => {\n const object = {\n is: {\n a: 'path',\n },\n }\n const result = path(['is', 'not', 'a'], object)\n // $ExpectType unknown\n result\n const curriedResult = path(['is', 'not', 'a'])(object)\n // $ExpectType unknown\n curriedResult\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#path)\n\n### pathEq\n\n```typescript\n\npathEq(pathToSearch: Path, target: any, input: any): boolean\n```\n\nIt returns `true` if `pathToSearch` of `input` object is equal to `target` value.\n\n`pathToSearch` is passed to `R.path`, which means that it can be either a string or an array. Also equality between `target` and the found value is determined by `R.equals`.\n\nTry this R.pathEq example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npathEq(pathToSearch: Path, target: any, input: any): boolean;\npathEq(pathToSearch: Path, target: any): (input: any) => boolean;\npathEq(pathToSearch: Path): (target: any) => (input: any) => boolean;\n```\n\n
\n\n
\n\nR.pathEq source\n\n```javascript\nimport { curry } from './curry.js'\nimport { equals } from './equals.js'\nimport { path } from './path.js'\n\nfunction pathEqFn(\n pathToSearch, target, input\n){\n return equals(path(pathToSearch, input), target)\n}\n\nexport const pathEq = curry(pathEqFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { pathEq } from './pathEq.js'\n\ntest('when true', () => {\n const path = 'a.b'\n const obj = { a : { b : { c : 1 } } }\n const target = { c : 1 }\n\n expect(pathEq(\n path, target, obj\n )).toBeTrue()\n})\n\ntest('when false', () => {\n const path = 'a.b'\n const obj = { a : { b : 1 } }\n const target = 2\n\n expect(pathEq(path, target)(obj)).toBeFalse()\n})\n\ntest('when wrong path', () => {\n const path = 'foo.bar'\n const obj = { a : { b : 1 } }\n const target = 2\n\n expect(pathEq(\n path, target, obj\n )).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {pathEq} from 'rambda'\n\ndescribe('R.pathEq', () => {\n it('with string path', () => {\n const pathToSearch = 'a.b.c'\n const input = {a: {b: {c: 1}}}\n const target = {c: 1}\n\n const result = pathEq(pathToSearch, input, target)\n const curriedResult = pathEq(pathToSearch, input, target)\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n\n it('with array path', () => {\n const pathToSearch = ['a', 'b', 'c']\n const input = {a: {b: {c: 1}}}\n const target = {c: 1}\n\n const result = pathEq(pathToSearch, input, target)\n const curriedResult = pathEq(pathToSearch, input, target)\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n})\n\ndescribe('with ramda specs', () => {\n const testPath = ['x', 0, 'y']\n const testObj = {\n x: [\n {y: 2, z: 3},\n {y: 4, z: 5},\n ],\n }\n\n const result1 = pathEq(testPath, 2, testObj)\n const result2 = pathEq(testPath, 2)(testObj)\n const result3 = pathEq(testPath)(2)(testObj)\n result1 // $ExpectType boolean\n result2 // $ExpectType boolean\n result3 // $ExpectType boolean\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pathEq)\n\n### pathOr\n\n```typescript\n\npathOr(defaultValue: T, pathToSearch: Path, obj: any): T\n```\n\nIt reads `obj` input and returns either `R.path(pathToSearch, Record)` result or `defaultValue` input.\n\nTry this R.pathOr example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npathOr(defaultValue: T, pathToSearch: Path, obj: any): T;\npathOr(defaultValue: T, pathToSearch: Path): (obj: any) => T;\npathOr(defaultValue: T): (pathToSearch: Path) => (obj: any) => T;\n```\n\n
\n\n
\n\nR.pathOr source\n\n```javascript\nimport { curry } from './curry.js'\nimport { defaultTo } from './defaultTo.js'\nimport { path } from './path.js'\n\nfunction pathOrFn(\n defaultValue, pathInput, obj\n){\n return defaultTo(defaultValue, path(pathInput, obj))\n}\n\nexport const pathOr = curry(pathOrFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { pathOr } from './pathOr.js'\n\ntest('with undefined', () => {\n const result = pathOr(\n 'foo', 'x.y', { x : { y : 1 } }\n )\n\n expect(result).toBe(1)\n})\n\ntest('with null', () => {\n const result = pathOr(\n 'foo', 'x.y', null\n )\n\n expect(result).toBe('foo')\n})\n\ntest('with NaN', () => {\n const result = pathOr(\n 'foo', 'x.y', NaN\n )\n\n expect(result).toBe('foo')\n})\n\ntest('curry case (x)(y)(z)', () => {\n const result = pathOr('foo')('x.y.z')({ x : { y : { a : 1 } } })\n\n expect(result).toBe('foo')\n})\n\ntest('curry case (x)(y,z)', () => {\n const result = pathOr('foo', 'x.y.z')({ x : { y : { a : 1 } } })\n\n expect(result).toBe('foo')\n})\n\ntest('curry case (x,y)(z)', () => {\n const result = pathOr('foo')('x.y.z', { x : { y : { a : 1 } } })\n\n expect(result).toBe('foo')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {pathOr} from 'rambda'\n\ndescribe('R.pathOr', () => {\n it('with string path', () => {\n const x = pathOr('foo', 'x.y', {x: {y: 'bar'}})\n x // $ExpectType string\n })\n it('with array path', () => {\n const x = pathOr('foo', ['x', 'y'], {x: {y: 'bar'}})\n x // $ExpectType string\n })\n it('without passing type looks bad', () => {\n const x = pathOr('foo', 'x.y', {x: {y: 'bar'}})\n x // $ExpectType \"foo\"\n })\n it('curried', () => {\n const x = pathOr('foo', 'x.y')({x: {y: 'bar'}})\n x // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pathOr)\n\n### paths\n\n```typescript\n\npaths(pathsToSearch: Path[], obj: Input): (T | undefined)[]\n```\n\nIt loops over members of `pathsToSearch` as `singlePath` and returns the array produced by `R.path(singlePath, Record)`.\n\nBecause it calls `R.path`, then `singlePath` can be either string or a list.\n\nTry this R.paths example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npaths(pathsToSearch: Path[], obj: Input): (T | undefined)[];\npaths(pathsToSearch: Path[]): (obj: Input) => (T | undefined)[];\npaths(pathsToSearch: Path[], obj: any): (T | undefined)[];\npaths(pathsToSearch: Path[]): (obj: any) => (T | undefined)[];\n```\n\n
\n\n
\n\nR.paths source\n\n```javascript\nimport { path } from './path.js'\n\nexport function paths(pathsToSearch, obj){\n if (arguments.length === 1){\n return _obj => paths(pathsToSearch, _obj)\n }\n\n return pathsToSearch.map(singlePath => path(singlePath, obj))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { paths } from './paths.js'\n\nconst obj = {\n a : {\n b : {\n c : 1,\n d : 2,\n },\n },\n p : [ { q : 3 } ],\n x : {\n y : 'FOO',\n z : [ [ {} ] ],\n },\n}\n\ntest('with string path + curry', () => {\n const pathsInput = [ 'a.b.d', 'p.q' ]\n const expected = [ 2, undefined ]\n const result = paths(pathsInput, obj)\n const curriedResult = paths(pathsInput)(obj)\n\n expect(result).toEqual(expected)\n expect(curriedResult).toEqual(expected)\n})\n\ntest('with array path', () => {\n const result = paths([\n [ 'a', 'b', 'c' ],\n [ 'x', 'y' ],\n ],\n obj)\n\n expect(result).toEqual([ 1, 'FOO' ])\n})\n\ntest('takes a paths that contains indices into arrays', () => {\n expect(paths([\n [ 'p', 0, 'q' ],\n [ 'x', 'z', 0, 0 ],\n ],\n obj)).toEqual([ 3, {} ])\n expect(paths([\n [ 'p', 0, 'q' ],\n [ 'x', 'z', 2, 1 ],\n ],\n obj)).toEqual([ 3, undefined ])\n})\n\ntest('gets a deep property\\'s value from objects', () => {\n expect(paths([ [ 'a', 'b' ] ], obj)).toEqual([ obj.a.b ])\n expect(paths([ [ 'p', 0 ] ], obj)).toEqual([ obj.p[ 0 ] ])\n})\n\ntest('returns undefined for items not found', () => {\n expect(paths([ [ 'a', 'x', 'y' ] ], obj)).toEqual([ undefined ])\n expect(paths([ [ 'p', 2 ] ], obj)).toEqual([ undefined ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {paths} from 'rambda'\n\ninterface Input {\n a: number,\n b: number,\n c: number,\n}\n\nconst input: Input = {a: 1, b: 2, c: 3}\n\ndescribe('R.paths', () => {\n it('with dot notation', () => {\n const result = paths(['a.b.c', 'foo.bar'], input)\n result // $ExpectType (number | undefined)[]\n })\n\n it('without type', () => {\n const result = paths(['a.b.c', 'foo.bar'], input)\n result // $ExpectType unknown[]\n })\n\n it('with array as path', () => {\n const result = paths([['a', 'b', 'c'], ['foo.bar']], input)\n result // $ExpectType (number | undefined)[]\n })\n\n it('curried', () => {\n const result = paths([['a', 'b', 'c'], ['foo.bar']])(input)\n result // $ExpectType (number | undefined)[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#paths)\n\n### pathSatisfies\n\nTry this R.pathSatisfies example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pathSatisfies)\n\n### pick\n\n```typescript\n\npick(propsToPick: K[], input: T): Pick>>\n```\n\nIt returns a partial copy of an `input` containing only `propsToPick` properties.\n\n`input` can be either an object or an array.\n\nString annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.\n\nTry this R.pick example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npick(propsToPick: K[], input: T): Pick>>;\npick(propsToPick: K[]): (input: T) => Pick>>;\npick(propsToPick: string, input: T): U;\npick(propsToPick: string): (input: T) => U;\npick(propsToPick: string, input: object): T;\npick(propsToPick: string): (input: object) => T;\n```\n\n
\n\n
\n\nR.pick source\n\n```javascript\nimport { createPath } from './_internals/createPath.js'\n\nexport function pick(propsToPick, input){\n if (arguments.length === 1) return _input => pick(propsToPick, _input)\n\n if (input === null || input === undefined){\n return undefined\n }\n const keys = createPath(propsToPick, ',')\n const willReturn = {}\n let counter = 0\n\n while (counter < keys.length){\n if (keys[ counter ] in input){\n willReturn[ keys[ counter ] ] = input[ keys[ counter ] ]\n }\n counter++\n }\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { pick } from './pick.js'\n\nconst obj = {\n a : 1,\n b : 2,\n c : 3,\n}\n\ntest('props to pick is a string', () => {\n const result = pick('a,c', obj)\n const resultCurry = pick('a,c')(obj)\n const expectedResult = {\n a : 1,\n c : 3,\n }\n\n expect(result).toEqual(expectedResult)\n expect(resultCurry).toEqual(expectedResult)\n})\n\ntest('when prop is missing', () => {\n const result = pick('a,d,f', obj)\n expect(result).toEqual({ a : 1 })\n})\n\ntest('with list indexes as props', () => {\n const list = [ 1, 2, 3 ]\n const expected = {\n 0 : 1,\n 2 : 3,\n }\n expect(pick([ 0, 2, 3 ], list)).toEqual(expected)\n expect(pick('0,2,3', list)).toEqual(expected)\n})\n\ntest('props to pick is an array', () => {\n expect(pick([ 'a', 'c' ])({\n a : 'foo',\n b : 'bar',\n c : 'baz',\n })).toEqual({\n a : 'foo',\n c : 'baz',\n })\n\n expect(pick([ 'a', 'd', 'e', 'f' ])({\n a : 'foo',\n b : 'bar',\n c : 'baz',\n })).toEqual({ a : 'foo' })\n\n expect(pick('a,d,e,f')(null)).toBeUndefined()\n})\n\ntest('works with list as input and number as props - props to pick is an array', () => {\n const result = pick([ 1, 2 ], [ 'a', 'b', 'c', 'd' ])\n expect(result).toEqual({\n 1 : 'b',\n 2 : 'c',\n })\n})\n\ntest('works with list as input and number as props - props to pick is a string', () => {\n const result = pick('1,2', [ 'a', 'b', 'c', 'd' ])\n expect(result).toEqual({\n 1 : 'b',\n 2 : 'c',\n })\n})\n\ntest('with symbol', () => {\n const symbolProp = Symbol('s')\n expect(pick([ symbolProp ], { [ symbolProp ] : 'a' })).toMatchInlineSnapshot(`\n{\n Symbol(s): \"a\",\n}\n`)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {pick} from 'rambda'\n\nconst input = {a: 'foo', b: 2, c: 3, d: 4}\n\ndescribe('R.pick with array as props input', () => {\n it('without passing type', () => {\n const result = pick(['a', 'c'], input)\n result.a // $ExpectType string\n result.c // $ExpectType number\n })\n})\n\ndescribe('R.pick with string as props input', () => {\n interface Input {\n a: string,\n b: number,\n c: number,\n d: number,\n }\n interface Output {\n a: string,\n c: number,\n }\n it('explicitly declare output', () => {\n const result = pick('a,c', input)\n result // $ExpectType Output\n result.a // $ExpectType string\n result.c // $ExpectType number\n\n const curriedResult = pick('a,c')(input)\n\n curriedResult.a // $ExpectType string\n })\n\n it('explicitly declare input and output', () => {\n const result = pick('a,c', input)\n result // $ExpectType Output\n result.a // $ExpectType string\n\n const curriedResult = pick('a,c')(input)\n\n curriedResult.a // $ExpectType string\n })\n\n it('without passing type', () => {\n const result = pick('a,c', input)\n result // $ExpectType unknown\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pick)\n\n### pickAll\n\n```typescript\n\npickAll(propsToPicks: K[], input: T): Pick\n```\n\nSame as `R.pick` but it won't skip the missing props, i.e. it will assign them to `undefined`.\n\nTry this R.pickAll example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npickAll(propsToPicks: K[], input: T): Pick;\npickAll(propsToPicks: string[], input: T): U;\npickAll(propsToPicks: string[]): (input: T) => U;\npickAll(propsToPick: string, input: T): U;\npickAll(propsToPick: string): (input: T) => U;\n```\n\n
\n\n
\n\nR.pickAll source\n\n```javascript\nimport { createPath } from './_internals/createPath.js'\n\nexport function pickAll(propsToPick, obj){\n if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj)\n\n if (obj === null || obj === undefined){\n return undefined\n }\n const keysValue = createPath(propsToPick, ',')\n const willReturn = {}\n let counter = 0\n\n while (counter < keysValue.length){\n if (keysValue[ counter ] in obj){\n willReturn[ keysValue[ counter ] ] = obj[ keysValue[ counter ] ]\n } else {\n willReturn[ keysValue[ counter ] ] = undefined\n }\n counter++\n }\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { pickAll } from './pickAll.js'\n\ntest('when input is undefined or null', () => {\n expect(pickAll('a', null)).toBeUndefined()\n expect(pickAll('a', undefined)).toBeUndefined()\n})\n\ntest('with string as condition', () => {\n const obj = {\n a : 1,\n b : 2,\n c : 3,\n }\n const result = pickAll('a,c', obj)\n const resultCurry = pickAll('a,c')(obj)\n const expectedResult = {\n a : 1,\n b : undefined,\n c : 3,\n }\n\n expect(result).toEqual(expectedResult)\n expect(resultCurry).toEqual(expectedResult)\n})\n\ntest('with array as condition', () => {\n expect(pickAll([ 'a', 'b', 'c' ], {\n a : 'foo',\n c : 'baz',\n })).toEqual({\n a : 'foo',\n b : undefined,\n c : 'baz',\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {pickAll} from 'rambda'\n\ninterface Input {\n a: string,\n b: number,\n c: number,\n d: number,\n}\ninterface Output {\n a?: string,\n c?: number,\n}\nconst input = {a: 'foo', b: 2, c: 3, d: 4}\n\ndescribe('R.pickAll with array as props input', () => {\n it('without passing type', () => {\n const result = pickAll(['a', 'c'], input)\n result.a // $ExpectType string\n result.c // $ExpectType number\n })\n it('without passing type + curry', () => {\n const result = pickAll(['a', 'c'])(input)\n result // $ExpectType unknown\n })\n it('explicitly passing types', () => {\n const result = pickAll(['a', 'c'], input)\n result.a // $ExpectType string | undefined\n result.c // $ExpectType number | undefined\n })\n})\n\ndescribe('R.pickAll with string as props input', () => {\n it('without passing type', () => {\n const result = pickAll('a,c', input)\n result // $ExpectType unknown\n })\n it('without passing type + curry', () => {\n const result = pickAll('a,c')(input)\n result // $ExpectType unknown\n })\n it('explicitly passing types', () => {\n const result = pickAll('a,c', input)\n result.a // $ExpectType string | undefined\n result.c // $ExpectType number | undefined\n })\n it('explicitly passing types + curry', () => {\n const result = pickAll('a,c')(input)\n result.a // $ExpectType string | undefined\n result.c // $ExpectType number | undefined\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pickAll)\n\n### pickBy\n\nTry this R.pickBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pickBy)\n\n### pipe\n\nIt performs left-to-right function composition.\n\nTry this R.pipe example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pipe)\n\n### pluck\n\n```typescript\n\npluck(property: K, list: T[]): T[K][]\n```\n\nIt returns list of the values of `property` taken from the all objects inside `list`.\n\nTry this R.pluck example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npluck(property: K, list: T[]): T[K][];\npluck(property: number, list: { [k: number]: T }[]): T[];\npluck

(property: P): (list: Record[]) => T[];\npluck(property: number): (list: { [k: number]: T }[]) => T[];\n```\n\n

\n\n
\n\nR.pluck source\n\n```javascript\nimport { map } from './map.js'\n\nexport function pluck(property, list){\n if (arguments.length === 1) return _list => pluck(property, _list)\n\n const willReturn = []\n\n map(x => {\n if (x[ property ] !== undefined){\n willReturn.push(x[ property ])\n }\n }, list)\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { pluck } from './pluck.js'\n\ntest('happy', () => {\n expect(pluck('a')([ { a : 1 }, { a : 2 }, { b : 1 } ])).toEqual([ 1, 2 ])\n})\n\ntest('with undefined', () => {\n expect(pluck(undefined)([ { a : 1 }, { a : 2 }, { b : 1 } ])).toEqual([ ])\n})\n\ntest('with number', () => {\n const input = [\n [ 1, 2 ],\n [ 3, 4 ],\n ]\n\n expect(pluck(0, input)).toEqual([ 1, 3 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {pluck} from 'rambda'\n\ndescribe('R.pluck', () => {\n it('with object', () => {\n interface ListMember {\n a: number,\n b: string,\n }\n const input: ListMember[] = [\n {a: 1, b: 'foo'},\n {a: 2, b: 'bar'},\n ]\n const resultA = pluck('a', input)\n const resultB = pluck('b')(input)\n resultA // $ExpectType number[]\n resultB // $ExpectType string[]\n })\n\n it('with array', () => {\n const input = [\n [1, 2],\n [3, 4],\n [5, 6],\n ]\n const result = pluck(0, input)\n const resultCurry = pluck(0)(input)\n result // $ExpectType number[]\n resultCurry // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#pluck)\n\n### prepend\n\n```typescript\n\nprepend(xToPrepend: T, iterable: T[]): T[]\n```\n\nIt adds element `x` at the beginning of `list`.\n\nTry this R.prepend example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nprepend(xToPrepend: T, iterable: T[]): T[];\nprepend(xToPrepend: T, iterable: IsFirstSubtypeOfSecond[]) : U[];\nprepend(xToPrepend: T): (iterable: IsFirstSubtypeOfSecond[]) => U[];\nprepend(xToPrepend: T): (iterable: T[]) => T[];\n```\n\n
\n\n
\n\nR.prepend source\n\n```javascript\nexport function prepend(x, input){\n if (arguments.length === 1) return _input => prepend(x, _input)\n\n if (typeof input === 'string') return [ x ].concat(input.split(''))\n\n return [ x ].concat(input)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { prepend } from './prepend.js'\n\ntest('happy', () => {\n expect(prepend('yes', [ 'foo', 'bar', 'baz' ])).toEqual([\n 'yes',\n 'foo',\n 'bar',\n 'baz',\n ])\n})\n\ntest('with empty list', () => {\n expect(prepend('foo')([])).toEqual([ 'foo' ])\n})\n\ntest('with string instead of array', () => {\n expect(prepend('foo')('bar')).toEqual([ 'foo', 'b', 'a', 'r' ])\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#prepend)\n\n### product\n\n```typescript\n\nproduct(list: number[]): number\n```\n\nTry this R.product example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nproduct(list: number[]): number;\n```\n\n
\n\n
\n\nR.product source\n\n```javascript\nimport { multiply } from './multiply.js'\nimport { reduce } from './reduce.js'\n\nexport const product = reduce(multiply, 1)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { product } from './product.js'\n\ntest('happy', () => {\n expect(product([ 2, 3, 4 ])).toBe(24)\n})\n\ntest('bad input', () => {\n expect(product([ null ])).toBe(0)\n expect(product([])).toBe(1)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {product} from 'rambda'\n\ndescribe('R.product', () => {\n it('happy', () => {\n const result = product([1, 2, 3])\n\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#product)\n\n### prop\n\n```typescript\n\nprop<_, P extends keyof never, T>(p: P, value: T): Prop\n```\n\nIt returns the value of property `propToFind` in `obj`.\n\nIf there is no such property, it returns `undefined`.\n\nTry this R.prop example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nprop<_, P extends keyof never, T>(p: P, value: T): Prop;\nprop(p: keyof never, value: unknown): V;\nprop<_, P extends keyof never>(p: P): (value: T) => Prop;\nprop(p: keyof never): (value: unknown) => V;\n```\n\n
\n\n
\n\nR.prop source\n\n```javascript\nexport function propFn(searchProperty, obj){\n if (!obj) return undefined\n\n return obj[ searchProperty ]\n}\n\nexport function prop(searchProperty, obj){\n if (arguments.length === 1) return _obj => prop(searchProperty, _obj)\n\n return propFn(searchProperty, obj)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { prop } from './prop.js'\n\ntest('prop', () => {\n expect(prop('foo')({ foo : 'baz' })).toBe('baz')\n\n expect(prop('bar')({ foo : 'baz' })).toBeUndefined()\n\n expect(prop('bar')(null)).toBeUndefined()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {prop} from 'rambda'\n\ndescribe('R.prop', () => {\n interface Foo {\n a: number,\n b: string,\n c?: number,\n }\n const obj: Foo = {a: 1, b: 'foo'}\n\n it('issue #553', () => {\n const result = {\n a: prop('a', obj),\n b: prop('b', obj),\n c: prop('c', obj),\n }\n const curriedResult = {\n a: prop('a')(obj),\n b: prop('b')(obj),\n c: prop('c')(obj),\n }\n\n result // $ExpectType { a: number; b: string; c: number | undefined; }\n curriedResult // $ExpectType { a: number; b: string; c: number | undefined; }\n })\n})\n\ndescribe('with number as prop', () => {\n const list = [1, 2, 3]\n const index = 1\n it('happy', () => {\n const result = prop(index, list)\n\n result // $ExpectType number\n })\n it('curried require explicit type', () => {\n const result = prop(index)(list)\n\n result // $ExpectType number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#prop)\n\n### propEq\n\n```typescript\n\npropEq(valueToMatch: any, propToFind: K, obj: Record): boolean\n```\n\nIt returns true if `obj` has property `propToFind` and its value is equal to `valueToMatch`.\n\nTry this R.propEq example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npropEq(valueToMatch: any, propToFind: K, obj: Record): boolean;\npropEq(valueToMatch: any, propToFind: K): (obj: Record) => boolean;\npropEq(valueToMatch: any): {\n (propToFind: K, obj: Record): boolean;\n (propToFind: K): (obj: Record) => boolean;\n};\n```\n\n
\n\n
\n\nR.propEq source\n\n```javascript\nimport { curry } from './curry.js'\nimport { equals } from './equals.js'\nimport { prop } from './prop.js'\n\nfunction propEqFn(\n valueToMatch, propToFind, obj\n){\n if (!obj) return false\n\n return equals(valueToMatch, prop(propToFind, obj))\n}\n\nexport const propEq = curry(propEqFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { BAR, FOO } from './_internals/testUtils.js'\nimport { propEq } from './propEq.js'\n\ntest('happy', () => {\n const obj = { [ FOO ] : BAR }\n expect(propEq(BAR, FOO)(obj)).toBeTrue()\n expect(propEq(1, FOO)(obj)).toBeFalse()\n expect(propEq(1)(FOO)(obj)).toBeFalse()\n expect(propEq(\n 1, 1, null\n )).toBeFalse()\n})\n\ntest('returns false if called with a null or undefined object', () => {\n expect(propEq(\n 'name', 'Abby', null\n )).toBeFalse()\n expect(propEq(\n 'name', 'Abby', undefined\n )).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {propEq} from 'rambda'\n\nconst property = 'foo'\nconst numberProperty = 1\nconst value = 'bar'\nconst obj = {[property]: value}\nconst objWithNumberIndex = {[numberProperty]: value}\n\ndescribe('R.propEq', () => {\n it('happy', () => {\n const result = propEq(value, property, obj)\n result // $ExpectType boolean\n })\n\n it('number is property', () => {\n const result = propEq(value, 1, objWithNumberIndex)\n result // $ExpectType boolean\n })\n\n it('with optional property', () => {\n interface MyType {\n optional?: string | number,\n }\n\n const myObject: MyType = {}\n const valueToFind = '1111'\n // @ts-expect-error\n propEq(valueToFind, 'optional', myObject)\n })\n\n it('imported from @types/ramda', () => {\n interface A {\n foo: string | null,\n }\n const obj: A = {\n foo: 'bar',\n }\n const value = ''\n const result = propEq(value, 'foo')(obj)\n result // $ExpectType boolean\n\n // @ts-expect-error\n propEq(value, 'bar')(obj)\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#propEq)\n\n### propIs\n\n```typescript\n\npropIs(type: C, name: K, obj: any): obj is Record>\n```\n\nIt returns `true` if `property` of `obj` is from `target` type.\n\nTry this R.propIs example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npropIs(type: C, name: K, obj: any): obj is Record>;\npropIs(type: C, name: K, obj: any): obj is Record>;\npropIs(type: C, name: K): (obj: any) => obj is Record>;\npropIs(type: C, name: K): (obj: any) => obj is Record>;\npropIs(type: C): {\n (name: K, obj: any): obj is Record>;\n (name: K): (obj: any) => obj is Record>;\n};\n```\n\n
\n\n
\n\nR.propIs source\n\n```javascript\nimport { curry } from './curry.js'\nimport { is } from './is.js'\n\nfunction propIsFn(\n targetPrototype, property, obj\n){\n return is(targetPrototype, obj[ property ])\n}\n\nexport const propIs = curry(propIsFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { propIs } from './propIs.js'\n\nconst obj = {\n a : 1,\n b : 'foo',\n}\n\ntest('when true', () => {\n expect(propIs(\n Number, 'a', obj\n )).toBeTrue()\n expect(propIs(\n String, 'b', obj\n )).toBeTrue()\n})\n\ntest('when false', () => {\n expect(propIs(\n String, 'a', obj\n )).toBeFalse()\n expect(propIs(\n Number, 'b', obj\n )).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {propIs} from 'rambda'\n\nconst property = 'a'\nconst obj = {a: 1}\n\ndescribe('R.propIs', () => {\n it('happy', () => {\n const result = propIs(Number, property, obj)\n result // $ExpectType boolean\n })\n\n it('curried', () => {\n const result = propIs(Number, property)(obj)\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#propIs)\n\n### propOr\n\n```typescript\n\npropOr(defaultValue: T, property: P, obj: Partial> | undefined): T\n```\n\nIt returns either `defaultValue` or the value of `property` in `obj`.\n\nTry this R.propOr example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npropOr(defaultValue: T, property: P, obj: Partial> | undefined): T;\npropOr(defaultValue: T, property: P): (obj: Partial> | undefined) => T;\npropOr(defaultValue: T): {\n

(property: P, obj: Partial> | undefined): T;\n

(property: P): (obj: Partial> | undefined) => T;\n}\n```\n\n

\n\n
\n\nR.propOr source\n\n```javascript\nimport { curry } from './curry.js'\nimport { defaultTo } from './defaultTo.js'\n\nfunction propOrFn(\n defaultValue, property, obj\n){\n if (!obj) return defaultValue\n\n return defaultTo(defaultValue, obj[ property ])\n}\n\nexport const propOr = curry(propOrFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { propOr } from './propOr.js'\n\ntest('propOr (result)', () => {\n const obj = { a : 1 }\n expect(propOr(\n 'default', 'a', obj\n )).toBe(1)\n expect(propOr(\n 'default', 'notExist', obj\n )).toBe('default')\n expect(propOr(\n 'default', 'notExist', null\n )).toBe('default')\n})\n\ntest('propOr (currying)', () => {\n const obj = { a : 1 }\n expect(propOr('default')('a', obj)).toBe(1)\n expect(propOr('default', 'a')(obj)).toBe(1)\n expect(propOr('default')('notExist', obj)).toBe('default')\n expect(propOr('default', 'notExist')(obj)).toBe('default')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {propOr} from 'rambda'\n\nconst obj = {foo: 'bar'}\nconst property = 'foo'\nconst fallback = 'fallback'\n\ndescribe('R.propOr', () => {\n it('happy', () => {\n const result = propOr(fallback, property, obj)\n result // $ExpectType string\n })\n it('curry 1', () => {\n const result = propOr(fallback)(property, obj)\n result // $ExpectType string\n })\n it('curry 2', () => {\n const result = propOr(fallback, property)(obj)\n result // $ExpectType string\n })\n it('curry 3', () => {\n const result = propOr(fallback)(property)(obj)\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#propOr)\n\n### props\n\n```typescript\n\nprops

(propsToPick: P[], obj: Record): T[]\n```\n\nIt takes list with properties `propsToPick` and returns a list with property values in `obj`.\n\nTry this R.props example in Rambda REPL\n\n

\n\nAll TypeScript definitions\n\n```typescript\nprops

(propsToPick: P[], obj: Record): T[];\nprops

(propsToPick: P[]): (obj: Record) => T[];\nprops

(propsToPick: P[]): (obj: Record) => T[];\n```\n\n

\n\n
\n\nR.props source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { mapArray } from './map.js'\n\nexport function props(propsToPick, obj){\n if (arguments.length === 1){\n return _obj => props(propsToPick, _obj)\n }\n if (!isArray(propsToPick)){\n throw new Error('propsToPick is not a list')\n }\n\n return mapArray(prop => obj[ prop ], propsToPick)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { props } from './props.js'\n\nconst obj = {\n a : 1,\n b : 2,\n}\nconst propsToPick = [ 'a', 'c' ]\n\ntest('happy', () => {\n const result = props(propsToPick, obj)\n expect(result).toEqual([ 1, undefined ])\n})\n\ntest('curried', () => {\n const result = props(propsToPick)(obj)\n expect(result).toEqual([ 1, undefined ])\n})\n\ntest('wrong input', () => {\n expect(() => props(null)(obj)).toThrowErrorMatchingInlineSnapshot('\"propsToPick is not a list\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {props} from 'rambda'\n\nconst obj = {a: 1, b: 2}\n\ndescribe('R.props', () => {\n it('happy', () => {\n const result = props(['a', 'b'], obj)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = props(['a', 'b'])(obj)\n\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#props)\n\n### propSatisfies\n\n```typescript\n\npropSatisfies(predicate: Predicate, property: string, obj: Record): boolean\n```\n\nIt returns `true` if the object property satisfies a given predicate.\n\nTry this R.propSatisfies example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\npropSatisfies(predicate: Predicate, property: string, obj: Record): boolean;\npropSatisfies(predicate: Predicate, property: string): (obj: Record) => boolean;\n```\n\n
\n\n
\n\nR.propSatisfies source\n\n```javascript\nimport { curry } from './curry.js'\nimport { prop } from './prop.js'\n\nfunction propSatisfiesFn(\n predicate, property, obj\n){\n return predicate(prop(property, obj))\n}\n\nexport const propSatisfies = curry(propSatisfiesFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { propSatisfies } from './propSatisfies.js'\n\nconst obj = { a : 1 }\n\ntest('when true', () => {\n expect(propSatisfies(\n x => x > 0, 'a', obj\n )).toBeTrue()\n})\n\ntest('when false', () => {\n expect(propSatisfies(x => x < 0, 'a')(obj)).toBeFalse()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {propSatisfies} from 'rambda'\n\nconst obj = {a: 1}\n\ndescribe('R.propSatisfies', () => {\n it('happy', () => {\n const result = propSatisfies(x => x > 0, 'a', obj)\n\n result // $ExpectType boolean\n })\n it('curried requires explicit type', () => {\n const result = propSatisfies(x => x > 0, 'a')(obj)\n\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#propSatisfies)\n\n### range\n\n```typescript\n\nrange(startInclusive: number, endExclusive: number): number[]\n```\n\nIt returns list of numbers between `startInclusive` to `endExclusive` markers.\n\nTry this R.range example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nrange(startInclusive: number, endExclusive: number): number[];\nrange(startInclusive: number): (endExclusive: number) => number[];\n```\n\n
\n\n
\n\nR.range source\n\n```javascript\nexport function range(start, end){\n if (arguments.length === 1) return _end => range(start, _end)\n\n if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))){\n throw new TypeError('Both arguments to range must be numbers')\n }\n\n if (end < start) return []\n\n const len = end - start\n const willReturn = Array(len)\n\n for (let i = 0; i < len; i++){\n willReturn[ i ] = start + i\n }\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { range } from './range.js'\n\ntest('happy', () => {\n expect(range(0, 10)).toEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ])\n})\n\ntest('end range is bigger than start range', () => {\n expect(range(7, 3)).toEqual([])\n expect(range(5, 5)).toEqual([])\n})\n\ntest('with bad input', () => {\n const throwMessage = 'Both arguments to range must be numbers'\n expect(() => range('a', 6)).toThrowWithMessage(Error, throwMessage)\n expect(() => range(6, 'z')).toThrowWithMessage(Error, throwMessage)\n})\n\ntest('curry', () => {\n expect(range(0)(10)).toEqual([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {range} from 'rambda'\n\ndescribe('R.range', () => {\n it('happy', () => {\n const result = range(1, 4)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = range(1)(4)\n\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#range)\n\n### reduce\n\nTry this R.reduce example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#reduce)\n\n### reduceBy\n\nTry this R.reduceBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#reduceBy)\n\n### reject\n\n```typescript\n\nreject(predicate: Predicate, list: T[]): T[]\n```\n\nIt has the opposite effect of `R.filter`.\n\nTry this R.reject example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nreject(predicate: Predicate, list: T[]): T[];\nreject(predicate: Predicate): (list: T[]) => T[];\nreject(predicate: Predicate, obj: Dictionary): Dictionary;\nreject(predicate: Predicate): (obj: Dictionary) => Dictionary;\n```\n\n
\n\n
\n\nR.reject source\n\n```javascript\nimport { filter } from './filter.js'\n\nexport function reject(predicate, list){\n if (arguments.length === 1) return _list => reject(predicate, _list)\n\n return filter(x => !predicate(x), list)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { reject } from './reject.js'\n\nconst isOdd = n => n % 2 === 1\n\ntest('with array', () => {\n expect(reject(isOdd)([ 1, 2, 3, 4 ])).toEqual([ 2, 4 ])\n})\n\ntest('with object', () => {\n const obj = {\n a : 1,\n b : 2,\n c : 3,\n d : 4,\n }\n expect(reject(isOdd, obj)).toEqual({\n b : 2,\n d : 4,\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {reject} from 'rambda'\n\ndescribe('R.reject with array', () => {\n it('happy', () => {\n const result = reject(\n x => {\n x // $ExpectType number\n return x > 1\n },\n [1, 2, 3]\n )\n result // $ExpectType number[]\n })\n it('curried require explicit type', () => {\n const result = reject(x => {\n x // $ExpectType number\n return x > 1\n })([1, 2, 3])\n result // $ExpectType number[]\n })\n})\n\ndescribe('R.reject with objects', () => {\n it('happy', () => {\n const result = reject(\n x => {\n x // $ExpectType number\n\n return x > 1\n },\n {a: 1, b: 2}\n )\n result // $ExpectType Dictionary\n })\n it('curried require dummy type', () => {\n const result = reject(x => {\n return x > 1\n })({a: 1, b: 2})\n result // $ExpectType Dictionary\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#reject)\n\n### removeIndex\n\n```typescript\n\nremoveIndex(index: number, list: T[]): T[]\n```\n\nIt returns a copy of `list` input with removed `index`.\n\nTry this R.removeIndex example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nremoveIndex(index: number, list: T[]): T[];\nremoveIndex(index: number): (list: T[]) => T[];\n```\n\n
\n\n
\n\nR.removeIndex source\n\n```javascript\nexport function removeIndex(index, list){\n if (arguments.length === 1) return _list => removeIndex(index, _list)\n if (index <= 0) return list.slice(1)\n if (index >= list.length - 1) return list.slice(0, list.length - 1)\n\n return [ ...list.slice(0, index), ...list.slice(index + 1) ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { removeIndex } from './removeIndex.js'\n\nconst list = [ 1, 2, 3, 4 ]\n\ntest('first or before first index', () => {\n expect(removeIndex(-2, list)).toEqual([ 2, 3, 4 ])\n expect(removeIndex(-2)(list)).toEqual([ 2, 3, 4 ])\n})\n\ntest('last or after last index', () => {\n expect(removeIndex(4, list)).toEqual([ 1, 2, 3 ])\n expect(removeIndex(10, list)).toEqual([ 1, 2, 3 ])\n})\n\ntest('middle index', () => {\n expect(removeIndex(1, list)).toEqual([ 1, 3, 4 ])\n expect(removeIndex(2, list)).toEqual([ 1, 2, 4 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {removeIndex} from 'rambda'\n\ndescribe('R.removeIndex', () => {\n it('happy', () => {\n const result = removeIndex(1, [1, 2, 3])\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = removeIndex(1)([1, 2, 3])\n\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#removeIndex)\n\n### repeat\n\n```typescript\n\nrepeat(x: T): (timesToRepeat: number) => T[]\n```\n\nTry this R.repeat example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nrepeat(x: T): (timesToRepeat: number) => T[];\nrepeat(x: T, timesToRepeat: number): T[];\n```\n\n
\n\n
\n\nR.repeat source\n\n```javascript\nexport function repeat(x, timesToRepeat){\n if (arguments.length === 1){\n return _timesToRepeat => repeat(x, _timesToRepeat)\n }\n\n return Array(timesToRepeat).fill(x)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { repeat } from './repeat.js'\n\ntest('repeat', () => {\n expect(repeat('')(3)).toEqual([ '', '', '' ])\n expect(repeat('foo', 3)).toEqual([ 'foo', 'foo', 'foo' ])\n\n const obj = {}\n const arr = repeat(obj, 3)\n\n expect(arr).toEqual([ {}, {}, {} ])\n\n expect(arr[ 0 ] === arr[ 1 ]).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {repeat} from 'rambda'\n\ndescribe('R.repeat', () => {\n it('happy', () => {\n const result = repeat(4, 7)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = repeat(4)(7)\n\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#repeat)\n\n### replace\n\n```typescript\n\nreplace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string\n```\n\nIt replaces `strOrRegex` found in `str` with `replacer`.\n\nTry this R.replace example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nreplace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string;\nreplace(strOrRegex: RegExp | string, replacer: RegExpReplacer): (str: string) => string;\nreplace(strOrRegex: RegExp | string): (replacer: RegExpReplacer) => (str: string) => string;\n```\n\n
\n\n
\n\nR.replace source\n\n```javascript\nimport { curry } from './curry.js'\n\nfunction replaceFn(\n pattern, replacer, str\n){\n return str.replace(pattern, replacer)\n}\n\nexport const replace = curry(replaceFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { replace } from './replace.js'\n\ntest('happy', () => {\n expect(replace(\n /\\s/g, '|', 'foo bar baz'\n )).toBe('foo|bar|baz')\n})\n\ntest('with function as replacer input', () => {\n expect(replace(\n /\\s/g,\n (\n match, offset, str\n ) => {\n expect(match).toBe(' ')\n expect([ 3, 7 ].includes(offset)).toBeTrue()\n expect(str).toBe('foo bar baz')\n\n return '|'\n },\n 'foo bar baz'\n )).toBe('foo|bar|baz')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {replace} from 'rambda'\n\nconst str = 'foo bar foo'\nconst replacer = 'bar'\n\ndescribe('R.replace', () => {\n it('happy', () => {\n const result = replace(/foo/g, replacer, str)\n\n result // $ExpectType string\n })\n it('with string as search pattern', () => {\n const result = replace('foo', replacer, str)\n\n result // $ExpectType string\n })\n it('with function as replacer', () => {\n const result = replace('f(o)o', (m: string, p1: string, offset: number) => {\n m // $ExpectType string\n p1 // $ExpectType string\n offset // $ExpectType number\n return p1\n }, str)\n\n result // $ExpectType string\n })\n})\n\ndescribe('R.replace - curried', () => {\n it('happy', () => {\n const result = replace(/foo/g, replacer)(str)\n\n result // $ExpectType string\n })\n it('with string as search pattern', () => {\n const result = replace('foo', replacer)(str)\n\n result // $ExpectType string\n })\n it('with function as replacer', () => {\n const result = replace('f(o)o')((m: string, p1: string, offset: number) => {\n m // $ExpectType string\n p1 // $ExpectType string\n offset // $ExpectType number\n return p1\n })(str)\n\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#replace)\n\n### reverse\n\n```typescript\n\nreverse(input: T[]): T[]\n```\n\nIt returns a reversed copy of list or string `input`.\n\nTry this R.reverse example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nreverse(input: T[]): T[];\nreverse(input: string): string;\n```\n\n
\n\n
\n\nR.reverse source\n\n```javascript\nexport function reverse(listOrString) {\n if (typeof listOrString === 'string') {\n return listOrString.split('').reverse().join('')\n }\n\n const clone = listOrString.slice()\n\n return clone.reverse()\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport {reverse} from './reverse.js'\n\ntest('happy', () => {\n expect(reverse([1, 2, 3])).toEqual([3, 2, 1])\n})\n\ntest('with string', () => {\n expect(reverse('baz')).toBe('zab')\n})\n\ntest(\"it doesn't mutate\", () => {\n const arr = [1, 2, 3]\n\n expect(reverse(arr)).toEqual([3, 2, 1])\n\n expect(arr).toEqual([1, 2, 3])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {reverse} from 'rambda'\n\nconst list = [1, 2, 3, 4, 5]\n\ndescribe('R.reverse', () => {\n it('happy', () => {\n const result = reverse(list)\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#reverse)\n\n### set\n\n```typescript\n\nset(lens: Lens): {\n (a: A): (obj: S) => S\n (a: A, obj: S): S\n}\n```\n\nIt returns a copied **Object** or **Array** with modified `lens` focus set to `replacer` value.\n\nTry this R.set example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nset(lens: Lens): {\n (a: A): (obj: S) => S\n (a: A, obj: S): S\n};\nset(lens: Lens, a: A): (obj: S) => S;\nset(lens: Lens, a: A, obj: S): S;\n```\n\n
\n\n
\n\nR.set source\n\n```javascript\nimport {always} from './always.js'\nimport {curry} from './curry.js'\nimport {over} from './over.js'\n\nfunction setFn(lens, replacer, x) {\n return over(lens, always(replacer), x)\n}\n\nexport const set = curry(setFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport {assoc} from './assoc.js'\nimport {lens} from './lens.js'\nimport {lensIndex} from './lensIndex.js'\nimport {lensPath} from './lensPath.js'\nimport {prop} from './prop.js'\nimport {set} from './set.js'\n\nconst testObject = {\n foo: 'bar',\n baz: {\n a: 'x',\n b: 'y',\n },\n}\n\ntest('assoc lens', () => {\n const assocLens = lens(prop('foo'), assoc('foo'))\n const result = set(assocLens, 'FOO', testObject)\n const expected = {\n ...testObject,\n foo: 'FOO',\n }\n expect(result).toEqual(expected)\n})\n\ntest('path lens', () => {\n const pathLens = lensPath('baz.a')\n const result = set(pathLens, 'z', testObject)\n const expected = {\n ...testObject,\n baz: {\n a: 'z',\n b: 'y',\n },\n }\n expect(result).toEqual(expected)\n})\n\ntest('index lens', () => {\n const indexLens = lensIndex(0)\n\n const result = set(indexLens, 3, [1, 2])\n expect(result).toEqual([3, 2])\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#set)\n\n### slice\n\n```typescript\n\nslice(from: number, to: number, input: string): string\n```\n\nTry this R.slice example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nslice(from: number, to: number, input: string): string;\nslice(from: number, to: number, input: T[]): T[];\nslice(from: number, to: number): {\n (input: string): string;\n (input: T[]): T[];\n};\nslice(from: number): {\n (to: number, input: string): string;\n (to: number, input: T[]): T[];\n};\n```\n\n
\n\n
\n\nR.slice source\n\n```javascript\nimport { curry } from './curry.js'\n\nfunction sliceFn(\n from, to, list\n){\n return list.slice(from, to)\n}\n\nexport const slice = curry(sliceFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { slice } from './slice.js'\n\ntest('slice', () => {\n expect(slice(\n 1, 3, [ 'a', 'b', 'c', 'd' ]\n )).toEqual([ 'b', 'c' ])\n expect(slice(\n 1, Infinity, [ 'a', 'b', 'c', 'd' ]\n )).toEqual([ 'b', 'c', 'd' ])\n expect(slice(\n 0, -1, [ 'a', 'b', 'c', 'd' ]\n )).toEqual([ 'a', 'b', 'c' ])\n expect(slice(\n -3, -1, [ 'a', 'b', 'c', 'd' ]\n )).toEqual([ 'b', 'c' ])\n expect(slice(\n 0, 3, 'ramda'\n )).toBe('ram')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {slice} from 'rambda'\n\nconst list = [1, 2, 3, 4, 5]\n\ndescribe('R.slice', () => {\n it('happy', () => {\n const result = slice(1, 3, list)\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = slice(1, 3)(list)\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#slice)\n\n### sort\n\n```typescript\n\nsort(sortFn: (a: T, b: T) => number, list: T[]): T[]\n```\n\nIt returns copy of `list` sorted by `sortFn` function, where `sortFn` needs to return only `-1`, `0` or `1`.\n\nTry this R.sort example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsort(sortFn: (a: T, b: T) => number, list: T[]): T[];\nsort(sortFn: (a: T, b: T) => number): (list: T[]) => T[];\n```\n\n
\n\n
\n\nR.sort source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\n\nexport function sort(sortFn, list){\n if (arguments.length === 1) return _list => sort(sortFn, _list)\n\n return cloneList(list).sort(sortFn)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { sort } from './sort.js'\n\nconst fn = (a, b) => a > b ? 1 : -1\n\ntest('sort', () => {\n expect(sort((a, b) => a - b)([ 2, 3, 1 ])).toEqual([ 1, 2, 3 ])\n})\n\ntest('it doesn\\'t mutate', () => {\n const list = [ 'foo', 'bar', 'baz' ]\n\n expect(sort(fn, list)).toEqual([ 'bar', 'baz', 'foo' ])\n\n expect(list[ 0 ]).toBe('foo')\n expect(list[ 1 ]).toBe('bar')\n expect(list[ 2 ]).toBe('baz')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {sort} from 'rambda'\n\nconst list = [3, 0, 5, 2, 1]\n\nfunction sortFn(a: number, b: number): number {\n return a > b ? 1 : -1\n}\n\ndescribe('R.sort', () => {\n it('happy', () => {\n const result = sort(sortFn, list)\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = sort(sortFn)(list)\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#sort)\n\n### sortBy\n\n```typescript\n\nsortBy(sortFn: (a: T) => Ord, list: T[]): T[]\n```\n\nIt returns copy of `list` sorted by `sortFn` function, where `sortFn` function returns a value to compare, i.e. it doesn't need to return only `-1`, `0` or `1`.\n\nTry this R.sortBy example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsortBy(sortFn: (a: T) => Ord, list: T[]): T[];\nsortBy(sortFn: (a: T) => Ord): (list: T[]) => T[];\nsortBy(sortFn: (a: any) => Ord): (list: T[]) => T[];\n```\n\n
\n\n
\n\nR.sortBy source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\n\nexport function sortBy(sortFn, list){\n if (arguments.length === 1) return _list => sortBy(sortFn, _list)\n\n const clone = cloneList(list)\n\n return clone.sort((a, b) => {\n const aSortResult = sortFn(a)\n const bSortResult = sortFn(b)\n\n if (aSortResult === bSortResult) return 0\n\n return aSortResult < bSortResult ? -1 : 1\n })\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { compose } from './compose.js'\nimport { prop } from './prop.js'\nimport { sortBy } from './sortBy.js'\nimport { toLower } from './toLower.js'\n\ntest('happy', () => {\n const input = [ { a : 2 }, { a : 1 }, { a : 1 }, { a : 3 } ]\n const expected = [ { a : 1 }, { a : 1 }, { a : 2 }, { a : 3 } ]\n\n const result = sortBy(x => x.a)(input)\n expect(result).toEqual(expected)\n})\n\ntest('with compose', () => {\n const alice = {\n name : 'ALICE',\n age : 101,\n }\n const bob = {\n name : 'Bob',\n age : -10,\n }\n const clara = {\n name : 'clara',\n age : 314.159,\n }\n const people = [ clara, bob, alice ]\n const sortByNameCaseInsensitive = sortBy(compose(toLower, prop('name')))\n\n expect(sortByNameCaseInsensitive(people)).toEqual([ alice, bob, clara ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {sortBy, pipe} from 'rambda'\n\ninterface Input {\n a: number,\n}\n\ndescribe('R.sortBy', () => {\n it('passing type to sort function', () => {\n function fn(x: any): number {\n return x.a\n }\n function fn2(x: Input): number {\n return x.a\n }\n\n const input = [{a: 2}, {a: 1}, {a: 0}]\n const result = sortBy(fn, input)\n const curriedResult = sortBy(fn2)(input)\n\n result // $ExpectType { a: number; }[]\n curriedResult // $ExpectType Input[]\n result[0].a // $ExpectType number\n curriedResult[0].a // $ExpectType number\n })\n it('passing type to sort function and list', () => {\n function fn(x: Input): number {\n return x.a\n }\n\n const input: Input[] = [{a: 2}, {a: 1}, {a: 0}]\n const result = sortBy(fn, input)\n const curriedResult = sortBy(fn)(input)\n\n result // $ExpectType Input[]\n curriedResult // $ExpectType Input[]\n result[0].a // $ExpectType number\n })\n it('with R.pipe', () => {\n interface Obj {\n value: number,\n }\n const fn = pipe(sortBy(x => x.value))\n\n const result = fn([{value: 1}, {value: 2}])\n result // $ExpectType Obj[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#sortBy)\n\n### sortWith\n\nTry this R.sortWith example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#sortWith)\n\n### split\n\n```typescript\n\nsplit(separator: string | RegExp): (str: string) => string[]\n```\n\nCurried version of `String.prototype.split`\n\nTry this R.split example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsplit(separator: string | RegExp): (str: string) => string[];\nsplit(separator: string | RegExp, str: string): string[];\n```\n\n
\n\n
\n\nR.split source\n\n```javascript\nexport function split(separator, str){\n if (arguments.length === 1) return _str => split(separator, _str)\n\n return str.split(separator)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { split } from './split.js'\n\nconst str = 'foo|bar|baz'\nconst splitChar = '|'\nconst expected = [ 'foo', 'bar', 'baz' ]\n\ntest('happy', () => {\n expect(split(splitChar, str)).toEqual(expected)\n})\n\ntest('curried', () => {\n expect(split(splitChar)(str)).toEqual(expected)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {split} from 'rambda'\n\nconst str = 'foo|bar|baz'\nconst splitChar = '|'\n\ndescribe('R.split', () => {\n it('happy', () => {\n const result = split(splitChar, str)\n\n result // $ExpectType string[]\n })\n it('curried', () => {\n const result = split(splitChar)(str)\n\n result // $ExpectType string[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#split)\n\n### splitAt\n\n```typescript\n\nsplitAt(index: number, input: T[]): [T[], T[]]\n```\n\nIt splits string or array at a given index.\n\nTry this R.splitAt example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsplitAt(index: number, input: T[]): [T[], T[]];\nsplitAt(index: number, input: string): [string, string];\nsplitAt(index: number): {\n (input: T[]): [T[], T[]];\n (input: string): [string, string];\n};\n```\n\n
\n\n
\n\nR.splitAt source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { drop } from './drop.js'\nimport { maybe } from './maybe.js'\nimport { take } from './take.js'\n\nexport function splitAt(index, input){\n if (arguments.length === 1){\n return _list => splitAt(index, _list)\n }\n if (!input) throw new TypeError(`Cannot read property 'slice' of ${ input }`)\n\n if (!isArray(input) && typeof input !== 'string') return [ [], [] ]\n\n const correctIndex = maybe(\n index < 0,\n input.length + index < 0 ? 0 : input.length + index,\n index\n )\n\n return [ take(correctIndex, input), drop(correctIndex, input) ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { splitAt as splitAtRamda } from 'ramda'\n\nimport { splitAt } from './splitAt.js'\n\nconst list = [ 1, 2, 3 ]\nconst str = 'foo bar'\n\ntest('with array', () => {\n const result = splitAt(2, list)\n expect(result).toEqual([ [ 1, 2 ], [ 3 ] ])\n})\n\ntest('with array - index is negative number', () => {\n const result = splitAt(-6, list)\n expect(result).toEqual([ [], list ])\n})\n\ntest('with array - index is out of scope', () => {\n const result = splitAt(4, list)\n expect(result).toEqual([ [ 1, 2, 3 ], [] ])\n})\n\ntest('with string', () => {\n const result = splitAt(4, str)\n expect(result).toEqual([ 'foo ', 'bar' ])\n})\n\ntest('with string - index is negative number', () => {\n const result = splitAt(-2, str)\n expect(result).toEqual([ 'foo b', 'ar' ])\n})\n\ntest('with string - index is out of scope', () => {\n const result = splitAt(10, str)\n expect(result).toEqual([ str, '' ])\n})\n\ntest('with array - index is out of scope', () => {\n const result = splitAt(4)(list)\n expect(result).toEqual([ [ 1, 2, 3 ], [] ])\n})\n\nconst badInputs = [ 1, true, /foo/g, {} ]\nconst throwingBadInputs = [ null, undefined ]\n\ntest('with bad inputs', () => {\n throwingBadInputs.forEach(badInput => {\n expect(() => splitAt(1, badInput)).toThrowWithMessage(TypeError,\n `Cannot read property 'slice' of ${ badInput }`)\n expect(() => splitAtRamda(1, badInput)).toThrowWithMessage(TypeError,\n `Cannot read properties of ${ badInput } (reading 'slice')`)\n })\n\n badInputs.forEach(badInput => {\n const result = splitAt(1, badInput)\n const ramdaResult = splitAtRamda(1, badInput)\n expect(result).toEqual(ramdaResult)\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {splitAt} from 'rambda'\n\nconst index = 1\nconst str = 'foo'\nconst list = [1, 2, 3]\n\ndescribe('R.splitAt with array', () => {\n it('happy', () => {\n const result = splitAt(index, list)\n\n result // $ExpectType [number[], number[]]\n })\n it('curried', () => {\n const result = splitAt(index)(list)\n\n result // $ExpectType [number[], number[]]\n })\n})\n\ndescribe('R.splitAt with string', () => {\n it('happy', () => {\n const result = splitAt(index, str)\n\n result // $ExpectType [string, string]\n })\n it('curried', () => {\n const result = splitAt(index)(str)\n\n result // $ExpectType [string, string]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#splitAt)\n\n### splitEvery\n\n```typescript\n\nsplitEvery(sliceLength: number, input: T[]): (T[])[]\n```\n\nIt splits `input` into slices of `sliceLength`.\n\nTry this R.splitEvery example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsplitEvery(sliceLength: number, input: T[]): (T[])[];\nsplitEvery(sliceLength: number, input: string): string[];\nsplitEvery(sliceLength: number): {\n (input: string): string[];\n (input: T[]): (T[])[];\n};\n```\n\n
\n\n
\n\nR.splitEvery source\n\n```javascript\nexport function splitEvery(sliceLength, listOrString){\n if (arguments.length === 1){\n return _listOrString => splitEvery(sliceLength, _listOrString)\n }\n\n if (sliceLength < 1){\n throw new Error('First argument to splitEvery must be a positive integer')\n }\n\n const willReturn = []\n let counter = 0\n\n while (counter < listOrString.length){\n willReturn.push(listOrString.slice(counter, counter += sliceLength))\n }\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { splitEvery } from './splitEvery.js'\n\ntest('happy', () => {\n expect(splitEvery(3, [ 1, 2, 3, 4, 5, 6, 7 ])).toEqual([\n [ 1, 2, 3 ],\n [ 4, 5, 6 ],\n [ 7 ],\n ])\n\n expect(splitEvery(3)('foobarbaz')).toEqual([ 'foo', 'bar', 'baz' ])\n})\n\ntest('with bad input', () => {\n expect(() =>\n expect(splitEvery(0)('foo')).toEqual([ 'f', 'o', 'o' ])).toThrowErrorMatchingInlineSnapshot('\"First argument to splitEvery must be a positive integer\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {splitEvery} from 'rambda'\n\nconst list = [1, 2, 3, 4, 5, 6, 7]\n\ndescribe('R.splitEvery', () => {\n it('happy', () => {\n const result = splitEvery(3, list)\n\n result // $ExpectType number[][]\n })\n it('curried', () => {\n const result = splitEvery(3)(list)\n\n result // $ExpectType number[][]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#splitEvery)\n\n### splitWhen\n\n```typescript\n\nsplitWhen(predicate: Predicate, list: U[]): (U[])[]\n```\n\nIt splits `list` to two arrays according to a `predicate` function. \n\nThe first array contains all members of `list` before `predicate` returns `true`.\n\nTry this R.splitWhen example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsplitWhen(predicate: Predicate, list: U[]): (U[])[];\nsplitWhen(predicate: Predicate): (list: U[]) => (U[])[];\n```\n\n
\n\n
\n\nR.splitWhen source\n\n```javascript\nexport function splitWhen(predicate, input){\n if (arguments.length === 1){\n return _input => splitWhen(predicate, _input)\n }\n if (!input)\n throw new TypeError(`Cannot read property 'length' of ${ input }`)\n\n const preFound = []\n const postFound = []\n let found = false\n let counter = -1\n\n while (counter++ < input.length - 1){\n if (found){\n postFound.push(input[ counter ])\n } else if (predicate(input[ counter ])){\n postFound.push(input[ counter ])\n found = true\n } else {\n preFound.push(input[ counter ])\n }\n }\n\n return [ preFound, postFound ]\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { splitWhen as splitWhenRamda } from 'ramda'\n\nimport { equals } from './equals.js'\nimport { splitWhen } from './splitWhen.js'\n\nconst list = [ 1, 2, 1, 2 ]\n\ntest('happy', () => {\n const result = splitWhen(equals(2), list)\n expect(result).toEqual([ [ 1 ], [ 2, 1, 2 ] ])\n})\n\ntest('when predicate returns false', () => {\n const result = splitWhen(equals(3))(list)\n expect(result).toEqual([ list, [] ])\n})\n\nconst badInputs = [ 1, true, /foo/g, {} ]\nconst throwingBadInputs = [ null, undefined ]\n\ntest('with bad inputs', () => {\n throwingBadInputs.forEach(badInput => {\n expect(() => splitWhen(equals(2), badInput)).toThrowWithMessage(TypeError,\n `Cannot read property 'length' of ${ badInput }`)\n expect(() => splitWhenRamda(equals(2), badInput)).toThrowWithMessage(TypeError,\n `Cannot read properties of ${ badInput } (reading 'length')`)\n })\n\n badInputs.forEach(badInput => {\n const result = splitWhen(equals(2), badInput)\n const ramdaResult = splitWhenRamda(equals(2), badInput)\n expect(result).toEqual(ramdaResult)\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {splitWhen} from 'rambda'\n\nconst list = [1, 2, 1, 2]\nconst predicate = (x: number) => x === 2\n\ndescribe('R.splitWhen', () => {\n it('happy', () => {\n const result = splitWhen(predicate, list)\n\n result // $ExpectType number[][]\n })\n it('curried', () => {\n const result = splitWhen(predicate)(list)\n\n result // $ExpectType number[][]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#splitWhen)\n\n### startsWith\n\n```typescript\n\nstartsWith(question: T, input: string): boolean\n```\n\nWhen iterable is a string, then it behaves as `String.prototype.startsWith`.\nWhen iterable is a list, then it uses R.equals to determine if the target list starts in the same way as the given target.\n\nTry this R.startsWith example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nstartsWith(question: T, input: string): boolean;\nstartsWith(question: T): (input: string) => boolean;\nstartsWith(question: T[], input: T[]): boolean;\nstartsWith(question: T[]): (input: T[]) => boolean;\n```\n\n
\n\n
\n\nR.startsWith source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\nimport { equals } from './equals.js'\n\nexport function startsWith(question, iterable){\n if (arguments.length === 1)\n return _iterable => startsWith(question, _iterable)\n\n if (typeof iterable === 'string'){\n return iterable.startsWith(question)\n }\n if (!isArray(question)) return false\n\n let correct = true\n const filtered = question.filter((x, index) => {\n if (!correct) return false\n const result = equals(x, iterable[ index ])\n if (!result) correct = false\n\n return result\n })\n\n return filtered.length === question.length\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { startsWith as startsWithRamda } from 'ramda'\n\nimport { compareCombinations } from './_internals/testUtils.js'\nimport { possibleIterables, possibleTargets } from './endsWith.spec.js'\nimport { startsWith } from './startsWith.js'\n\ntest('with string', () => {\n expect(startsWith('foo', 'foo-bar')).toBeTrue()\n expect(startsWith('baz')('foo-bar')).toBeFalse()\n})\n\ntest('use R.equals with array', () => {\n const list = [ { a : 1 }, { a : 2 }, { a : 3 } ]\n expect(startsWith({ a : 1 }, list)).toBeFalse()\n expect(startsWith([ { a : 1 } ], list)).toBeTrue()\n expect(startsWith([ { a : 1 }, { a : 2 } ], list)).toBeTrue()\n expect(startsWith(list, list)).toBeTrue()\n expect(startsWith([ { a : 2 } ], list)).toBeFalse()\n})\n\ndescribe('brute force', () => {\n compareCombinations({\n fn : startsWith,\n fnRamda : startsWithRamda,\n firstInput : possibleTargets,\n secondInput : possibleIterables,\n callback : errorsCounters => {\n expect(errorsCounters).toMatchInlineSnapshot(`\n {\n \"ERRORS_MESSAGE_MISMATCH\": 0,\n \"ERRORS_TYPE_MISMATCH\": 0,\n \"RESULTS_MISMATCH\": 0,\n \"SHOULD_NOT_THROW\": 0,\n \"SHOULD_THROW\": 0,\n \"TOTAL_TESTS\": 32,\n }\n `)\n },\n })\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {startsWith} from 'rambda'\n\ndescribe('R.startsWith - array', () => {\n const question = [{a: 1}]\n const iterable = [{a: 1}, {a: 2}]\n it('happy', () => {\n const result = startsWith(question, iterable)\n result // $ExpectType boolean\n })\n it('curried', () => {\n const result = startsWith(question)(iterable)\n result // $ExpectType boolean\n })\n})\n\ndescribe('R.startsWith - string', () => {\n const question = 'foo'\n const iterable = 'foo bar'\n it('happy', () => {\n const result = startsWith(question, iterable)\n result // $ExpectType boolean\n })\n it('curried', () => {\n const result = startsWith(question)(iterable)\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#startsWith)\n\n### subtract\n\nCurried version of `x - y`\n\nTry this R.subtract example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#subtract)\n\n### sum\n\n```typescript\n\nsum(list: number[]): number\n```\n\nTry this R.sum example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsum(list: number[]): number;\n```\n\n
\n\n
\n\nR.sum source\n\n```javascript\nexport function sum(list){\n return list.reduce((prev, current) => prev + current, 0)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { sum } from './sum.js'\n\ntest('happy', () => {\n expect(sum([ 1, 2, 3, 4, 5 ])).toBe(15)\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#sum)\n\n### swap\n\nTry this R.swap example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#swap)\n\n### symmetricDifference\n\n```typescript\n\nsymmetricDifference(x: T[], y: T[]): T[]\n```\n\nIt returns a merged list of `x` and `y` with all equal elements removed.\n\n`R.equals` is used to determine equality.\n\nTry this R.symmetricDifference example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nsymmetricDifference(x: T[], y: T[]): T[];\nsymmetricDifference(x: T[]): (y: T[]) => T[];\n```\n\n
\n\n
\n\nR.symmetricDifference source\n\n```javascript\nimport { concat } from './concat.js'\nimport { filter } from './filter.js'\nimport { includes } from './includes.js'\n\nexport function symmetricDifference(x, y){\n if (arguments.length === 1){\n return _y => symmetricDifference(x, _y)\n }\n\n return concat(filter(value => !includes(value, y), x),\n filter(value => !includes(value, x), y))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { symmetricDifference } from './symmetricDifference.js'\n\ntest('symmetricDifference', () => {\n const list1 = [ 1, 2, 3, 4 ]\n const list2 = [ 3, 4, 5, 6 ]\n expect(symmetricDifference(list1)(list2)).toEqual([ 1, 2, 5, 6 ])\n\n expect(symmetricDifference([], [])).toEqual([])\n})\n\ntest('symmetricDifference with objects', () => {\n const list1 = [ { id : 1 }, { id : 2 }, { id : 3 }, { id : 4 } ]\n const list2 = [ { id : 3 }, { id : 4 }, { id : 5 }, { id : 6 } ]\n expect(symmetricDifference(list1)(list2)).toEqual([\n { id : 1 },\n { id : 2 },\n { id : 5 },\n { id : 6 },\n ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {symmetricDifference} from 'rambda'\n\ndescribe('R.symmetricDifference', () => {\n it('happy', () => {\n const list1 = [1, 2, 3, 4]\n const list2 = [3, 4, 5, 6]\n const result = symmetricDifference(list1, list2)\n\n result // $ExpectType number[]\n })\n\n it('curried', () => {\n const list1 = [{id: 1}, {id: 2}, {id: 3}, {id: 4}]\n const list2 = [{id: 3}, {id: 4}, {id: 5}, {id: 6}]\n const result = symmetricDifference(list1)(list2)\n\n result // $ExpectType { id: number; }[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#symmetricDifference)\n\n### T\n\n```typescript\n\nT(): boolean\n```\n\nTry this R.T example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nT(): boolean;\n```\n\n
\n\n
\n\nR.T source\n\n```javascript\nexport function T(){\n return true\n}\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#T)\n\n### tail\n\n```typescript\n\ntail(input: T): T extends [any, ...infer U] ? U : [...T]\n```\n\nIt returns all but the first element of `input`.\n\nTry this R.tail example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntail(input: T): T extends [any, ...infer U] ? U : [...T];\ntail(input: string): string;\n```\n\n
\n\n
\n\nR.tail source\n\n```javascript\nimport { drop } from './drop.js'\n\nexport function tail(listOrString){\n return drop(1, listOrString)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { tail } from './tail.js'\n\ntest('tail', () => {\n expect(tail([ 1, 2, 3 ])).toEqual([ 2, 3 ])\n expect(tail([ 1, 2 ])).toEqual([ 2 ])\n expect(tail([ 1 ])).toEqual([])\n expect(tail([])).toEqual([])\n\n expect(tail('abc')).toBe('bc')\n expect(tail('ab')).toBe('b')\n expect(tail('a')).toBe('')\n expect(tail('')).toBe('')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {tail} from 'rambda'\n\ndescribe('R.tail', () => {\n it('with string', () => {\n const result = tail('foo')\n\n result // $ExpectType string\n })\n it('with list - one type', () => {\n const result = tail([1, 2, 3])\n\n result // $ExpectType number[]\n })\n it('with list - mixed types', () => {\n const result = tail(['foo', 'bar', 1, 2, 3])\n\n result // $ExpectType (string | number)[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#tail)\n\n### take\n\n```typescript\n\ntake(howMany: number, input: T): T extends string ? string : T\n```\n\nIt returns the first `howMany` elements of `input`.\n\nTry this R.take example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntake(howMany: number, input: T): T extends string ? string : T;\ntake(howMany: number) : (input: T) => T extends string ? string : T;\n```\n\n
\n\n
\n\nR.take source\n\n```javascript\nimport baseSlice from './_internals/baseSlice.js'\n\nexport function take(howMany, listOrString){\n if (arguments.length === 1)\n return _listOrString => take(howMany, _listOrString)\n if (howMany < 0) return listOrString.slice()\n if (typeof listOrString === 'string') return listOrString.slice(0, howMany)\n\n return baseSlice(\n listOrString, 0, howMany\n )\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { take } from './take.js'\n\ntest('happy', () => {\n const arr = [ 'foo', 'bar', 'baz' ]\n\n expect(take(1, arr)).toEqual([ 'foo' ])\n\n expect(arr).toEqual([ 'foo', 'bar', 'baz' ])\n\n expect(take(2)([ 'foo', 'bar', 'baz' ])).toEqual([ 'foo', 'bar' ])\n expect(take(3, [ 'foo', 'bar', 'baz' ])).toEqual([ 'foo', 'bar', 'baz' ])\n expect(take(4, [ 'foo', 'bar', 'baz' ])).toEqual([ 'foo', 'bar', 'baz' ])\n expect(take(3)('rambda')).toBe('ram')\n})\n\ntest('with negative index', () => {\n expect(take(-1, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n expect(take(-Infinity, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n})\n\ntest('with zero index', () => {\n expect(take(0, [ 1, 2, 3 ])).toEqual([])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {take} from 'rambda'\n\nconst list = [1, 2, 3, 4]\nconst str = 'foobar'\nconst howMany = 2\n\ndescribe('R.take - array', () => {\n it('happy', () => {\n const result = take(howMany, list)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = take(howMany)(list)\n\n result // $ExpectType number[]\n })\n})\n\ndescribe('R.take - string', () => {\n it('happy', () => {\n const result = take(howMany, str)\n\n result // $ExpectType string\n })\n it('curried', () => {\n const result = take(howMany)(str)\n\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#take)\n\n### takeLast\n\n```typescript\n\ntakeLast(howMany: number, input: T): T extends string ? string : T\n```\n\nIt returns the last `howMany` elements of `input`.\n\nTry this R.takeLast example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntakeLast(howMany: number, input: T): T extends string ? string : T;\ntakeLast(howMany: number) : (input: T) => T extends string ? string : T;\n```\n\n
\n\n
\n\nR.takeLast source\n\n```javascript\nimport baseSlice from './_internals/baseSlice.js'\n\nexport function takeLast(howMany, listOrString){\n if (arguments.length === 1)\n return _listOrString => takeLast(howMany, _listOrString)\n\n const len = listOrString.length\n if (howMany < 0) return listOrString.slice()\n let numValue = howMany > len ? len : howMany\n\n if (typeof listOrString === 'string')\n return listOrString.slice(len - numValue)\n\n numValue = len - numValue\n\n return baseSlice(\n listOrString, numValue, len\n )\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { takeLast } from './takeLast.js'\n\ntest('with arrays', () => {\n expect(takeLast(1, [ 'foo', 'bar', 'baz' ])).toEqual([ 'baz' ])\n\n expect(takeLast(2)([ 'foo', 'bar', 'baz' ])).toEqual([ 'bar', 'baz' ])\n\n expect(takeLast(3, [ 'foo', 'bar', 'baz' ])).toEqual([ 'foo', 'bar', 'baz' ])\n\n expect(takeLast(4, [ 'foo', 'bar', 'baz' ])).toEqual([ 'foo', 'bar', 'baz' ])\n\n expect(takeLast(10, [ 'foo', 'bar', 'baz' ])).toEqual([ 'foo', 'bar', 'baz' ])\n})\n\ntest('with strings', () => {\n expect(takeLast(3, 'rambda')).toBe('bda')\n\n expect(takeLast(7, 'rambda')).toBe('rambda')\n})\n\ntest('with negative index', () => {\n expect(takeLast(-1, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n expect(takeLast(-Infinity, [ 1, 2, 3 ])).toEqual([ 1, 2, 3 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {filter, piped, takeLast} from 'rambda'\n\nconst list = [1, 2, 3, 4]\nconst str = 'foobar'\nconst howMany = 2\n\ndescribe('R.takeLast - array', () => {\n it('happy', () => {\n const result = takeLast(howMany, list)\n\n result // $ExpectType number[]\n })\n it('curried', () => {\n const result = takeLast(howMany)(list)\n\n result // $ExpectType number[]\n })\n\tit('real case', () => {\n\t\tconst data = ['foo', 'bar', 'baz', 'qux']\n\t\tconst result = piped(\n\t\t\tdata,\n\t\t\tfilter(\n\t\t\t\tx => x.length >= 100\n\t\t\t),\n\t\t\ttakeLast(2),\n\t\t)\n\t\tresult // $ExpectType string[]\n\t})\n})\n\ndescribe('R.takeLast - string', () => {\n it('happy', () => {\n const result = takeLast(howMany, str)\n\n result // $ExpectType string\n })\n it('curried', () => {\n const result = takeLast(howMany)(str)\n\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#takeLast)\n\n### takeLastWhile\n\n```typescript\n\ntakeLastWhile(predicate: (x: string) => boolean, input: string): string\n```\n\nTry this R.takeLastWhile example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntakeLastWhile(predicate: (x: string) => boolean, input: string): string;\ntakeLastWhile(predicate: (x: string) => boolean): (input: string) => string;\ntakeLastWhile(predicate: (x: T) => boolean, input: T[]): T[];\ntakeLastWhile(predicate: (x: T) => boolean): (input: T[]) => T[];\n```\n\n
\n\n
\n\nR.takeLastWhile source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function takeLastWhile(predicate, input){\n if (arguments.length === 1){\n return _input => takeLastWhile(predicate, _input)\n }\n if (input.length === 0) return input\n\n const toReturn = []\n let counter = input.length\n\n while (counter){\n const item = input[ --counter ]\n if (!predicate(item)){\n break\n }\n toReturn.push(item)\n }\n\n return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('')\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { takeLastWhile } from './takeLastWhile.js'\nconst assert = require('assert')\n\nconst list = [ 1, 2, 3, 4 ]\n\ntest('happy', () => {\n const predicate = x => x > 2\n const result = takeLastWhile(predicate, list)\n expect(result).toEqual([ 3, 4 ])\n})\n\ntest('predicate is always true', () => {\n const predicate = () => true\n const result = takeLastWhile(predicate)(list)\n expect(result).toEqual(list)\n})\n\ntest('predicate is always false', () => {\n const predicate = () => false\n const result = takeLastWhile(predicate, list)\n expect(result).toEqual([])\n})\n\ntest('with string', () => {\n const result = takeLastWhile(x => x !== 'F', 'FOOBAR')\n expect(result).toBe('OOBAR')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {takeLastWhile} from 'rambda'\n\nconst list = [1, 2, 3]\nconst str = 'FOO'\n\ndescribe('R.takeLastWhile', () => {\n it('with array', () => {\n const result = takeLastWhile(x => x > 1, list)\n\n result // $ExpectType number[]\n })\n it('with array - curried', () => {\n const result = takeLastWhile(x => x > 1, list)\n\n result // $ExpectType number[]\n })\n it('with string', () => {\n const result = takeLastWhile(x => x !== 'F', str)\n\n result // $ExpectType string\n })\n it('with string - curried', () => {\n const result = takeLastWhile(x => x !== 'F')(str)\n\n result // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#takeLastWhile)\n\n### takeWhile\n\nTry this R.takeWhile example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#takeWhile)\n\n### tap\n\n```typescript\n\ntap(fn: (x: T) => void, input: T): T\n```\n\nIt applies function `fn` to input `x` and returns `x`. \n\nOne use case is debugging in the middle of `R.compose`.\n\nTry this R.tap example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntap(fn: (x: T) => void, input: T): T;\ntap(fn: (x: T) => void): (input: T) => T;\n```\n\n
\n\n
\n\nR.tap source\n\n```javascript\nexport function tap(fn, x){\n if (arguments.length === 1) return _x => tap(fn, _x)\n\n fn(x)\n\n return x\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { tap } from './tap.js'\n\ntest('tap', () => {\n let a = 1\n const sayX = x => a = x\n\n expect(tap(sayX, 100)).toBe(100)\n expect(tap(sayX)(100)).toBe(100)\n expect(a).toBe(100)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {tap, pipe} from 'rambda'\n\ndescribe('R.tap', () => {\n it('happy', () => {\n pipe(\n tap(x => {\n x // $ExpectType number[]\n }),\n (x: number[]) => x.length\n )([1, 2])\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#tap)\n\n### test\n\n```typescript\n\ntest(regExpression: RegExp): (str: string) => boolean\n```\n\nIt determines whether `str` matches `regExpression`.\n\nTry this R.test example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntest(regExpression: RegExp): (str: string) => boolean;\ntest(regExpression: RegExp, str: string): boolean;\n```\n\n
\n\n
\n\nR.test source\n\n```javascript\nexport function test(pattern, str){\n if (arguments.length === 1) return _str => test(pattern, _str)\n\n if (typeof pattern === 'string'){\n throw new TypeError(`R.test requires a value of type RegExp as its first argument; received \"${ pattern }\"`)\n }\n\n return str.search(pattern) !== -1\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { test as testMethod } from './test.js'\n\ntest('happy', () => {\n expect(testMethod(/^x/, 'xyz')).toBeTrue()\n\n expect(testMethod(/^y/)('xyz')).toBeFalse()\n})\n\ntest('throws if first argument is not regex', () => {\n expect(() => testMethod('foo', 'bar')).toThrowErrorMatchingInlineSnapshot('\"R.test requires a value of type RegExp as its first argument; received \"foo\"\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {test} from 'rambda'\n\nconst input = 'foo '\nconst regex = /foo/\n\ndescribe('R.test', () => {\n it('happy', () => {\n const result = test(regex, input)\n\n result // $ExpectType boolean\n })\n it('curried', () => {\n const result = test(regex)(input)\n\n result // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#test)\n\n### times\n\n```typescript\n\ntimes(fn: (i: number) => T, howMany: number): T[]\n```\n\nIt returns the result of applying function `fn` over members of range array.\n\nThe range array includes numbers between `0` and `howMany`(exclusive).\n\nTry this R.times example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntimes(fn: (i: number) => T, howMany: number): T[];\ntimes(fn: (i: number) => T): (howMany: number) => T[];\n```\n\n
\n\n
\n\nR.times source\n\n```javascript\nimport { isInteger } from './_internals/isInteger.js'\nimport { map } from './map.js'\nimport { range } from './range.js'\n\nexport function times(fn, howMany){\n if (arguments.length === 1) return _howMany => times(fn, _howMany)\n if (!isInteger(howMany) || howMany < 0){\n throw new RangeError('n must be an integer')\n }\n\n return map(fn, range(0, howMany))\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport assert from 'assert'\n\nimport { identity } from './identity.js'\nimport { times } from './times.js'\n\ntest('happy', () => {\n const result = times(identity, 5)\n\n expect(result).toEqual([ 0, 1, 2, 3, 4 ])\n})\n\ntest('with bad input', () => {\n assert.throws(() => {\n times(3)('cheers!')\n }, RangeError)\n assert.throws(() => {\n times(identity, -1)\n }, RangeError)\n})\n\ntest('curry', () => {\n const result = times(identity)(5)\n\n expect(result).toEqual([ 0, 1, 2, 3, 4 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {times, identity} from 'rambda'\n\ndescribe('R.times', () => {\n it('happy', () => {\n const result = times(identity, 5)\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#times)\n\n### toLower\n\n```typescript\n\ntoLower(str: S): Lowercase\n```\n\nTry this R.toLower example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntoLower(str: S): Lowercase;\ntoLower(str: string): string;\n```\n\n
\n\n
\n\nR.toLower source\n\n```javascript\nexport function toLower(str){\n return str.toLowerCase()\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { toLower } from './toLower.js'\n\ntest('toLower', () => {\n expect(toLower('FOO|BAR|BAZ')).toBe('foo|bar|baz')\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#toLower)\n\n### toPairs\n\n```typescript\n\ntoPairs>(obj: O): Array<{ [key in K]: [`${key}`, O[key]] }[K]>\n```\n\nIt transforms an object to a list.\n\nTry this R.toPairs example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntoPairs>(obj: O): Array<{ [key in K]: [`${key}`, O[key]] }[K]>;\ntoPairs(obj: Record): Array<[string, S]>;\n```\n\n
\n\n
\n\nR.toPairs source\n\n```javascript\nexport function toPairs(obj){\n return Object.entries(obj)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { toPairs } from './toPairs.js'\n\nconst obj = {\n a : 1,\n b : 2,\n c : [ 3, 4 ],\n}\nconst expected = [\n [ 'a', 1 ],\n [ 'b', 2 ],\n [ 'c', [ 3, 4 ] ],\n]\n\ntest('happy', () => {\n expect(toPairs(obj)).toEqual(expected)\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#toPairs)\n\n### toString\n\n```typescript\n\ntoString(x: unknown): string\n```\n\nTry this R.toString example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntoString(x: unknown): string;\n```\n\n
\n\n
\n\nR.toString source\n\n```javascript\nexport function toString(x){\n return x.toString()\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { toString } from './toString.js'\n\ntest('happy', () => {\n expect(toString([ 1, 2, 3 ])).toBe('1,2,3')\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#toString)\n\n### toUpper\n\n```typescript\n\ntoUpper(str: S): Uppercase\n```\n\nTry this R.toUpper example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntoUpper(str: S): Uppercase;\ntoUpper(str: string): string;\n```\n\n
\n\n
\n\nR.toUpper source\n\n```javascript\nexport function toUpper(str){\n return str.toUpperCase()\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { toUpper } from './toUpper.js'\n\ntest('toUpper', () => {\n expect(toUpper('foo|bar|baz')).toBe('FOO|BAR|BAZ')\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#toUpper)\n\n### transpose\n\n```typescript\n\ntranspose(list: (T[])[]): (T[])[]\n```\n\nTry this R.transpose example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntranspose(list: (T[])[]): (T[])[];\n```\n\n
\n\n
\n\nR.transpose source\n\n```javascript\nimport { isArray } from './_internals/isArray.js'\n\nexport function transpose(array){\n return array.reduce((acc, el) => {\n el.forEach((nestedEl, i) =>\n isArray(acc[ i ]) ? acc[ i ].push(nestedEl) : acc.push([ nestedEl ]))\n\n return acc\n }, [])\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { transpose } from './transpose.js'\n\ntest('happy', () => {\n const input = [\n [ 'a', 1 ],\n [ 'b', 2 ],\n [ 'c', 3 ],\n ]\n\n expect(transpose(input)).toEqual([\n [ 'a', 'b', 'c' ],\n [ 1, 2, 3 ],\n ])\n})\n\ntest('when rows are shorter', () => {\n const actual = transpose([ [ 10, 11 ], [ 20 ], [], [ 30, 31, 32 ] ])\n const expected = [ [ 10, 20, 30 ], [ 11, 31 ], [ 32 ] ]\n expect(actual).toEqual(expected)\n})\n\ntest('with empty array', () => {\n expect(transpose([])).toEqual([])\n})\n\ntest('array with falsy values', () => {\n const actual = transpose([\n [ true, false, undefined, null ],\n [ null, undefined, false, true ],\n ])\n const expected = [\n [ true, null ],\n [ false, undefined ],\n [ undefined, false ],\n [ null, true ],\n ]\n expect(actual).toEqual(expected)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {transpose} from 'rambda'\n\nconst input = [\n ['a', 1],\n ['b', 2],\n ['c', 3],\n]\n\ndescribe('R.transpose', () => {\n it('happy', () => {\n const result = transpose(input)\n\n result // $ExpectType (string | number)[][]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#transpose)\n\n### trim\n\n```typescript\n\ntrim(str: string): string\n```\n\nTry this R.trim example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\ntrim(str: string): string;\n```\n\n
\n\n
\n\nR.trim source\n\n```javascript\nexport function trim(str){\n return str.trim()\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { trim } from './trim.js'\n\ntest('trim', () => {\n expect(trim(' foo ')).toBe('foo')\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#trim)\n\n### tryCatch\n\nIt returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result. Note that `fn` can be value or asynchronous/synchronous function(unlike `Ramda` where fallback can only be a synchronous function).\n\nTry this R.tryCatch example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#tryCatch)\n\n### type\n\nIt accepts any input and it returns its type.\n\nTry this R.type example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#type)\n\n### unapply\n\n```typescript\n\nunapply(fn: (args: any[]) => T): (...args: any[]) => T\n```\n\nIt calls a function `fn` with the list of values of the returned function. \n\n`R.unapply` is the opposite of `R.apply` method.\n\nTry this R.unapply example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nunapply(fn: (args: any[]) => T): (...args: any[]) => T;\n```\n\n
\n\n
\n\nR.unapply source\n\n```javascript\nexport function unapply(fn){\n return function (...args){\n return fn.call(this, args)\n }\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { apply } from './apply.js'\nimport { converge } from './converge.js'\nimport { identity } from './identity.js'\nimport { prop } from './prop.js'\nimport { sum } from './sum.js'\nimport { unapply } from './unapply.js'\n\ntest('happy', () => {\n const fn = unapply(identity)\n expect(fn(\n 1, 2, 3\n )).toEqual([ 1, 2, 3 ])\n expect(fn()).toEqual([])\n})\n\ntest('returns a function which is always passed one argument', () => {\n const fn = unapply(function (){\n return arguments.length\n })\n expect(fn('x')).toBe(1)\n expect(fn('x', 'y')).toBe(1)\n expect(fn(\n 'x', 'y', 'z'\n )).toBe(1)\n})\n\ntest('forwards arguments to decorated function as an array', () => {\n const fn = unapply(xs => '[' + xs + ']')\n expect(fn(2)).toBe('[2]')\n expect(fn(2, 4)).toBe('[2,4]')\n expect(fn(\n 2, 4, 6\n )).toBe('[2,4,6]')\n})\n\ntest('returns a function with length 0', () => {\n const fn = unapply(identity)\n expect(fn).toHaveLength(0)\n})\n\ntest('is the inverse of R.apply', () => {\n let a, b, c, d, e, f, g, n\n const rand = function (){\n return Math.floor(200 * Math.random()) - 100\n }\n\n f = Math.max\n g = unapply(apply(f))\n n = 1\n while (n <= 100){\n a = rand()\n b = rand()\n c = rand()\n d = rand()\n e = rand()\n expect(f(\n a, b, c, d, e\n )).toEqual(g(\n a, b, c, d, e\n ))\n n += 1\n }\n\n f = function (xs){\n return '[' + xs + ']'\n }\n g = apply(unapply(f))\n n = 1\n while (n <= 100){\n a = rand()\n b = rand()\n c = rand()\n d = rand()\n e = rand()\n expect(f([ a, b, c, d, e ])).toEqual(g([ a, b, c, d, e ]))\n n += 1\n }\n})\n\ntest('it works with converge', () => {\n const fn = unapply(sum)\n const convergeFn = converge(fn, [ prop('a'), prop('b'), prop('c') ])\n const obj = {\n a : 1337,\n b : 42,\n c : 1,\n }\n const expected = 1337 + 42 + 1\n expect(convergeFn(obj)).toEqual(expected)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {join, unapply, sum} from 'rambda'\n\ndescribe('R.unapply', () => {\n it('happy', () => {\n const fn = unapply(sum)\n\n fn(1, 2, 3) // $ExpectType number\n })\n\n it('joins a string', () => {\n const fn = unapply(join(''))\n\n fn('s', 't', 'r', 'i', 'n', 'g') // $ExpectType string\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#unapply)\n\n### union\n\n```typescript\n\nunion(x: T[], y: T[]): T[]\n```\n\nIt takes two lists and return a new list containing a merger of both list with removed duplicates. \n\n`R.equals` is used to compare for duplication.\n\nTry this R.union example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nunion(x: T[], y: T[]): T[];\nunion(x: T[]): (y: T[]) => T[];\n```\n\n
\n\n
\n\nR.union source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\nimport { includes } from './includes.js'\n\nexport function union(x, y){\n if (arguments.length === 1) return _y => union(x, _y)\n\n const toReturn = cloneList(x)\n\n y.forEach(yInstance => {\n if (!includes(yInstance, x)) toReturn.push(yInstance)\n })\n\n return toReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { union } from './union.js'\n\ntest('happy', () => {\n expect(union([ 1, 2 ], [ 2, 3 ])).toEqual([ 1, 2, 3 ])\n})\n\ntest('with list of objects', () => {\n const list1 = [ { a : 1 }, { a : 2 } ]\n const list2 = [ { a : 2 }, { a : 3 } ]\n const result = union(list1)(list2)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {union} from 'rambda'\n\ndescribe('R.union', () => {\n it('happy', () => {\n const result = union([1, 2], [2, 3])\n\n result // $ExpectType number[]\n })\n it('with array of objects - case 1', () => {\n const list1 = [{a: 1}, {a: 2}]\n const list2 = [{a: 2}, {a: 3}]\n const result = union(list1, list2)\n result // $ExpectType { a: number; }[]\n })\n it('with array of objects - case 2', () => {\n const list1 = [{a: 1, b: 1}, {a: 2}]\n const list2 = [{a: 2}, {a: 3, b: 3}]\n const result = union(list1, list2)\n result[0].a // $ExpectType number\n result[0].b // $ExpectType number | undefined\n })\n})\n\ndescribe('R.union - curried', () => {\n it('happy', () => {\n const result = union([1, 2])([2, 3])\n\n result // $ExpectType number[]\n })\n it('with array of objects - case 1', () => {\n const list1 = [{a: 1}, {a: 2}]\n const list2 = [{a: 2}, {a: 3}]\n const result = union(list1)(list2)\n result // $ExpectType { a: number; }[]\n })\n it('with array of objects - case 2', () => {\n const list1 = [{a: 1, b: 1}, {a: 2}]\n const list2 = [{a: 2}, {a: 3, b: 3}]\n const result = union(list1)(list2)\n result[0].a // $ExpectType number\n result[0].b // $ExpectType number | undefined\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#union)\n\n### uniq\n\n```typescript\n\nuniq(list: T[]): T[]\n```\n\nIt returns a new array containing only one copy of each element of `list`.\n\n`R.equals` is used to determine equality.\n\nTry this R.uniq example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nuniq(list: T[]): T[];\n```\n\n
\n\n
\n\nR.uniq source\n\n```javascript\nimport { _Set } from './_internals/set.js'\n\nexport function uniq(list){\n const set = new _Set()\n const willReturn = []\n list.forEach(item => {\n if (set.checkUniqueness(item)){\n willReturn.push(item)\n }\n })\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { uniq } from './uniq.js'\n\ntest('happy', () => {\n const list = [ 1, 2, 3, 3, 3, 1, 2, 0 ]\n expect(uniq(list)).toEqual([ 1, 2, 3, 0 ])\n})\n\ntest('with object', () => {\n const list = [ { a : 1 }, { a : 2 }, { a : 1 }, { a : 2 } ]\n expect(uniq(list)).toEqual([ { a : 1 }, { a : 2 } ])\n})\n\ntest('with nested array', () => {\n expect(uniq([ [ 42 ], [ 42 ] ])).toEqual([ [ 42 ] ])\n})\n\ntest('with booleans', () => {\n expect(uniq([ [ false ], [ false ], [ true ] ])).toEqual([ [ false ], [ true ] ])\n})\n\ntest('with falsy values', () => {\n expect(uniq([ undefined, null ])).toEqual([ undefined, null ])\n})\n\ntest('can distinct between string and number', () => {\n expect(uniq([ 1, '1' ])).toEqual([ 1, '1' ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {uniq} from 'rambda'\n\ndescribe('R.uniq', () => {\n it('happy', () => {\n const result = uniq([1, 2, 3, 3, 3, 1, 2, 0])\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#uniq)\n\n### uniqBy\n\nIt applies uniqueness to input list based on function that defines what to be used for comparison between elements.\n\n`R.equals` is used to determine equality.\n\nTry this R.uniqBy example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#uniqBy)\n\n### uniqWith\n\n```typescript\n\nuniqWith(predicate: (x: T, y: T) => boolean, list: T[]): T[]\n```\n\nIt returns a new array containing only one copy of each element in `list` according to `predicate` function.\n\nThis predicate should return true, if two elements are equal.\n\nTry this R.uniqWith example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nuniqWith(predicate: (x: T, y: T) => boolean, list: T[]): T[];\nuniqWith(predicate: (x: T, y: T) => boolean): (list: T[]) => T[];\n```\n\n
\n\n
\n\nR.uniqWith source\n\n```javascript\nfunction includesWith(\n predicate, target, list\n){\n let willReturn = false\n let index = -1\n\n while (++index < list.length && !willReturn){\n const value = list[ index ]\n\n if (predicate(target, value)){\n willReturn = true\n }\n }\n\n return willReturn\n}\n\nexport function uniqWith(predicate, list){\n if (arguments.length === 1) return _list => uniqWith(predicate, _list)\n\n let index = -1\n const willReturn = []\n\n while (++index < list.length){\n const value = list[ index ]\n\n if (!includesWith(\n predicate, value, willReturn\n )){\n willReturn.push(value)\n }\n }\n\n return willReturn\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { uniqWith as uniqWithRamda } from 'ramda'\n\nimport { uniqWith } from './uniqWith.js'\n\nconst list = [ { a : 1 }, { a : 1 } ]\n\ntest('happy', () => {\n const fn = (x, y) => x.a === y.a\n\n const result = uniqWith(fn, list)\n expect(result).toEqual([ { a : 1 } ])\n})\n\ntest('with list of strings', () => {\n const fn = (x, y) => x.length === y.length\n const list = [ '0', '11', '222', '33', '4', '55' ]\n const result = uniqWith(fn)(list)\n const resultRamda = uniqWithRamda(fn, list)\n expect(result).toEqual([ '0', '11', '222' ])\n expect(resultRamda).toEqual([ '0', '11', '222' ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {uniqWith} from 'rambda'\n\ndescribe('R.uniqWith', () => {\n it('happy', () => {\n const list = [{a: 1}, {a: 1}]\n\n const fn = (x: any, y: any) => x.a === y.a\n\n const result = uniqWith(fn, list)\n result // $ExpectType { a: number; }[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#uniqWith)\n\n### unless\n\n```typescript\n\nunless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => U, x: T): T | U\n```\n\nThe method returns function that will be called with argument `input`.\n\nIf `predicate(input)` returns `false`, then the end result will be the outcome of `whenFalse(input)`.\n\nIn the other case, the final output will be the `input` itself.\n\nTry this R.unless example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nunless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => U, x: T): T | U;\nunless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => U): (x: T) => T | U;\nunless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T, x: T): T;\nunless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T): (x: T) => T;\n```\n\n
\n\n
\n\nR.unless source\n\n```javascript\nimport { curry } from './curry.js'\n\nfunction unlessFn(\n predicate, whenFalseFn, input\n){\n if (predicate(input)) return input\n\n return whenFalseFn(input)\n}\n\nexport const unless = curry(unlessFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { inc } from './inc.js'\nimport { isNil } from './isNil.js'\nimport { unless } from './unless.js'\n\ntest('happy', () => {\n const safeInc = unless(isNil, inc)\n expect(safeInc(null)).toBeNull()\n expect(safeInc(1)).toBe(2)\n})\n\ntest('curried', () => {\n const safeIncCurried = unless(isNil)(inc)\n expect(safeIncCurried(null)).toBeNull()\n})\n\ntest('with 3 inputs', () => {\n let result = unless(x => x.startsWith('/'), x=> x.concat('/'), '/api')\n expect(result).toBe('/api')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {unless, inc} from 'rambda'\n\ndescribe('R.unless', () => {\n it('happy', () => {\n const fn = unless(x => x > 5, inc)\n const result = fn(1)\n result // $ExpectType number\n })\n it('with one explicit type', () => {\n const result = unless(\n x => {\n x // $ExpectType number\n return x > 5\n },\n x => {\n x // $ExpectType number\n return x + 1\n },\n 1\n )\n result // $ExpectType number\n })\n it('with two different explicit types', () => {\n const result = unless(\n x => {\n x // $ExpectType number\n return x > 5\n },\n x => {\n x // $ExpectType number\n return `${x}-foo`\n },\n 1\n )\n result // $ExpectType string | number\n })\n})\n\ndescribe('R.unless - curried', () => {\n it('happy', () => {\n const fn = unless(x => x > 5, inc)\n const result = fn(1)\n result // $ExpectType number\n })\n it('with one explicit type', () => {\n const fn = unless(\n x => {\n x // $ExpectType number\n return x > 5\n },\n x => {\n x // $ExpectType number\n return x + 1\n }\n )\n const result = fn(1)\n result // $ExpectType number\n })\n it('with two different explicit types', () => {\n const fn = unless(\n x => {\n x // $ExpectType number\n return x > 5\n },\n x => {\n x // $ExpectType number\n return `${x}-foo`\n }\n )\n const result = fn(1)\n result // $ExpectType string | number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#unless)\n\n### unnest\n\nTry this R.unnest example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#unnest)\n\n### unwind\n\nTry this R.unwind example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#unwind)\n\n### update\n\n```typescript\n\nupdate(index: number, newValue: T, list: T[]): T[]\n```\n\nIt returns a copy of `list` with updated element at `index` with `newValue`.\n\nTry this R.update example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nupdate(index: number, newValue: T, list: T[]): T[];\nupdate(index: number, newValue: T): (list: T[]) => T[];\n```\n\n
\n\n
\n\nR.update source\n\n```javascript\nimport { cloneList } from './_internals/cloneList.js'\nimport { curry } from './curry.js'\n\nexport function updateFn(\n index, newValue, list\n){\n const clone = cloneList(list)\n if (index === -1) return clone.fill(newValue, index)\n\n return clone.fill(\n newValue, index, index + 1\n )\n}\n\nexport const update = curry(updateFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { update } from './update.js'\n\nconst list = [ 1, 2, 3 ]\n\ntest('happy', () => {\n const newValue = 8\n const index = 1\n const result = update(\n index, newValue, list\n )\n const curriedResult = update(index, newValue)(list)\n const tripleCurriedResult = update(index)(newValue)(list)\n\n const expected = [ 1, 8, 3 ]\n expect(result).toEqual(expected)\n expect(curriedResult).toEqual(expected)\n expect(tripleCurriedResult).toEqual(expected)\n})\n\ntest('list has no such index', () => {\n const newValue = 8\n const index = 10\n const result = update(\n index, newValue, list\n )\n\n expect(result).toEqual(list)\n})\n\ntest('with negative index', () => {\n expect(update(\n -1, 10, [ 1 ]\n )).toEqual([ 10 ])\n expect(update(\n -1, 10, []\n )).toEqual([])\n expect(update(\n -1, 10, list\n )).toEqual([ 1, 2, 10 ])\n expect(update(\n -2, 10, list\n )).toEqual([ 1, 10, 3 ])\n expect(update(\n -3, 10, list\n )).toEqual([ 10, 2, 3 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {update} from 'rambda'\n\ndescribe('R.update', () => {\n it('happy', () => {\n const result = update(1, 0, [1, 2, 3])\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#update)\n\n### values\n\n```typescript\n\nvalues(obj: T): T[K][]\n```\n\nWith correct input, this is nothing more than `Object.values(Record)`. If `obj` is not an object, then it returns an empty array.\n\nTry this R.values example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nvalues(obj: T): T[K][];\n```\n\n
\n\n
\n\nR.values source\n\n```javascript\nimport { type } from './type.js'\n\nexport function values(obj){\n if (type(obj) !== 'Object') return []\n return Object.values(obj)\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { values } from './values.js'\n\ntest('happy', () => {\n expect(values({\n a : 1,\n b : 2,\n c : 3,\n })).toEqual([ 1, 2, 3 ])\n})\n\ntest('with bad input', () => {\n expect(values(null)).toEqual([])\n expect(values(undefined)).toEqual([])\n expect(values(55)).toEqual([])\n expect(values('foo')).toEqual([])\n expect(values(true)).toEqual([])\n expect(values(false)).toEqual([])\n expect(values(NaN)).toEqual([])\n expect(values(Infinity)).toEqual([])\n expect(values([])).toEqual([])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {values} from 'rambda'\n\ndescribe('R.values', () => {\n it('happy', () => {\n const result = values({\n a: 1,\n b: 2,\n c: 3,\n })\n result // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#values)\n\n### view\n\n```typescript\n\nview(lens: Lens): (obj: S) => A\n```\n\nIt returns the value of `lens` focus over `target` object.\n\nTry this R.view example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nview(lens: Lens): (obj: S) => A;\nview(lens: Lens, obj: S): A;\n```\n\n
\n\n
\n\nR.view source\n\n```javascript\nconst Const = x => ({\n x,\n map : fn => Const(x),\n})\n\nexport function view(lens, target){\n if (arguments.length === 1) return _target => view(lens, _target)\n\n return lens(Const)(target).x\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { assoc } from './assoc.js'\nimport { lens } from './lens.js'\nimport { prop } from './prop.js'\nimport { view } from './view.js'\n\nconst testObject = { foo : 'Led Zeppelin' }\nconst assocLens = lens(prop('foo'), assoc('foo'))\n\ntest('happy', () => {\n expect(view(assocLens, testObject)).toBe('Led Zeppelin')\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#view)\n\n### when\n\n```typescript\n\nwhen(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U, input: T): T | U\n```\n\nIt pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`. \nIf the `predicate` returns `false`, then it will simply return `input`.\n\nTry this R.when example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nwhen(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U, input: T): T | U;\nwhen(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U): (input: T) => T | U;\nwhen(predicate: (x: T) => boolean): ((whenTrueFn: (a: T) => U) => (input: T) => T | U);\n```\n\n
\n\n
\n\nR.when source\n\n```javascript\nimport { curry } from './curry.js'\n\nfunction whenFn(\n predicate, whenTrueFn, input\n){\n if (!predicate(input)) return input\n\n return whenTrueFn(input)\n}\n\nexport const when = curry(whenFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { add } from './add.js'\nimport { when } from './when.js'\n\nconst predicate = x => typeof x === 'number'\n\ntest('happy', () => {\n const fn = when(predicate, add(11))\n expect(fn(11)).toBe(22)\n expect(fn('foo')).toBe('foo')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {when} from 'rambda'\n\nconst predicate = (x: number) => x > 2\nconst whenTrueFn = (x: number) => String(x)\n\ndescribe('R.when', () => {\n it('happy', () => {\n const result = when(predicate, whenTrueFn, 1)\n result // $ExpectType string | 1\n })\n\n it('curry 1', () => {\n const fn = when(predicate, whenTrueFn)\n const result = fn(1)\n result // $ExpectType string | number\n })\n\n it('curry 2 require explicit types', () => {\n const fn = when(predicate)(whenTrueFn)\n const result = fn(1)\n result // $ExpectType string | number\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#when)\n\n### where\n\n```typescript\n\nwhere(conditions: T, input: U): boolean\n```\n\nIt returns `true` if all each property in `conditions` returns `true` when applied to corresponding property in `input` object.\n\nTry this R.where example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nwhere(conditions: T, input: U): boolean;\nwhere(conditions: T): (input: U) => boolean;\nwhere(conditions: ObjFunc2, input: U): boolean;\nwhere(conditions: ObjFunc2): (input: U) => boolean;\n```\n\n
\n\n
\n\nR.where source\n\n```javascript\nexport function where(conditions, input){\n if (input === undefined){\n return _input => where(conditions, _input)\n }\n let flag = true\n for (const prop in conditions){\n if (!flag) continue\n const result = conditions[ prop ](input[ prop ])\n if (flag && result === false){\n flag = false\n }\n }\n\n return flag\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { equals } from './equals.js'\nimport { where } from './where.js'\n\ntest('when true', () => {\n const result = where({\n a : equals('foo'),\n b : equals('bar'),\n },\n {\n a : 'foo',\n b : 'bar',\n x : 11,\n y : 19,\n })\n\n expect(result).toBeTrue()\n})\n\ntest('when false | early exit', () => {\n let counter = 0\n const equalsFn = expected => input => {\n console.log(expected, 'expected')\n counter++\n\n return input === expected\n }\n const predicate = where({\n a : equalsFn('foo'),\n b : equalsFn('baz'),\n })\n expect(predicate({\n a : 'notfoo',\n b : 'notbar',\n })).toBeFalse()\n expect(counter).toBe(1)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {where, equals} from 'rambda'\n\ndescribe('R.where', () => {\n it('happy', () => {\n const input = {\n a: 'foo',\n b: 'bar',\n x: 11,\n y: 19,\n }\n const conditions = {\n a: equals('foo'),\n b: equals('bar'),\n }\n const result = where(conditions, input)\n const curriedResult = where(conditions)(input)\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#where)\n\n### whereAny\n\nSame as `R.where`, but it will return `true` if at least one condition check returns `true`.\n\nTry this R.whereAny example in Rambda REPL\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#whereAny)\n\n### whereEq\n\n```typescript\n\nwhereEq(condition: T, input: U): boolean\n```\n\nIt will return `true` if all of `input` object fully or partially include `rule` object.\n\n`R.equals` is used to determine equality.\n\nTry this R.whereEq example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nwhereEq(condition: T, input: U): boolean;\nwhereEq(condition: T): (input: U) => boolean;\n```\n\n
\n\n
\n\nR.whereEq source\n\n```javascript\nimport { equals } from './equals.js'\nimport { filter } from './filter.js'\n\nexport function whereEq(condition, input){\n if (arguments.length === 1){\n return _input => whereEq(condition, _input)\n }\n\n const result = filter((conditionValue, conditionProp) =>\n equals(conditionValue, input[ conditionProp ]),\n condition)\n\n return Object.keys(result).length === Object.keys(condition).length\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { whereEq } from './whereEq.js'\n\ntest('when true', () => {\n const condition = { a : 1 }\n const input = {\n a : 1,\n b : 2,\n }\n\n const result = whereEq(condition, input)\n const expectedResult = true\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('when false', () => {\n const condition = { a : 1 }\n const input = { b : 2 }\n\n const result = whereEq(condition, input)\n const expectedResult = false\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('with nested object', () => {\n const condition = { a : { b : 1 } }\n const input = {\n a : { b : 1 },\n c : 2,\n }\n\n const result = whereEq(condition)(input)\n const expectedResult = true\n\n expect(result).toEqual(expectedResult)\n})\n\ntest('with wrong input', () => {\n const condition = { a : { b : 1 } }\n\n expect(() => whereEq(condition, null)).toThrowErrorMatchingInlineSnapshot('\"Cannot read properties of null (reading \\'a\\')\"')\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {whereEq} from 'rambda'\n\ndescribe('R.whereEq', () => {\n it('happy', () => {\n const result = whereEq({a: {b: 2}}, {b: 2})\n const curriedResult = whereEq({a: {b: 2}})({b: 2})\n result // $ExpectType boolean\n curriedResult // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#whereEq)\n\n### without\n\n```typescript\n\nwithout(matchAgainst: T[], source: T[]): T[]\n```\n\nIt will return a new array, based on all members of `source` list that are not part of `matchAgainst` list.\n\n`R.equals` is used to determine equality.\n\nTry this R.without example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nwithout(matchAgainst: T[], source: T[]): T[];\nwithout(matchAgainst: T[]): (source: T[]) => T[];\n```\n\n
\n\n
\n\nR.without source\n\n```javascript\nimport { _indexOf } from './equals.js'\nimport { reduce } from './reduce.js'\n\nexport function without(matchAgainst, source){\n if (source === undefined){\n return _source => without(matchAgainst, _source)\n }\n\n return reduce(\n (prev, current) =>\n _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current),\n [],\n source\n )\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { without as withoutRamda } from 'ramda'\n\nimport { without } from './without.js'\n\ntest('should return a new list without values in the first argument', () => {\n const itemsToOmit = [ 'A', 'B', 'C' ]\n const collection = [ 'A', 'B', 'C', 'D', 'E', 'F' ]\n\n expect(without(itemsToOmit, collection)).toEqual([ 'D', 'E', 'F' ])\n expect(without(itemsToOmit)(collection)).toEqual([ 'D', 'E', 'F' ])\n})\n\ntest('with list of objects', () => {\n const itemsToOmit = [ { a : 1 }, { c : 3 } ]\n const collection = [ { a : 1 }, { b : 2 }, { c : 3 }, { d : 4 } ]\n const expected = [ { b : 2 }, { d : 4 } ]\n\n expect(without(itemsToOmit, collection)).toEqual(expected)\n expect(withoutRamda(itemsToOmit, collection)).toEqual(expected)\n})\n\ntest('ramda accepts string as target input while rambda throws', () => {\n expect(withoutRamda('0:1', [ '0', '0:1' ])).toEqual([ '0:1' ])\n expect(() =>\n without('0:1', [ '0', '0:1' ])).toThrowErrorMatchingInlineSnapshot('\"Cannot read property \\'indexOf\\' of 0:1\"')\n expect(without([ '0:1' ], [ '0', '0:1' ])).toEqual([ '0' ])\n})\n\ntest('ramda test', () => {\n expect(without([ 1, 2 ])([ 1, 2, 1, 3, 4 ])).toEqual([ 3, 4 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {without} from 'rambda'\n\nconst itemsToOmit = ['A', 'B', 'C']\nconst collection = ['A', 'B', 'C', 'D', 'E', 'F']\n\ndescribe('R.without', () => {\n it('happy', () => {\n const result = without(itemsToOmit, collection)\n\n result // $ExpectType string[]\n })\n it('curried', () => {\n const result = without(itemsToOmit)(collection)\n\n result // $ExpectType string[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#without)\n\n### xor\n\n```typescript\n\nxor(x: boolean, y: boolean): boolean\n```\n\nLogical XOR\n\nTry this R.xor example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nxor(x: boolean, y: boolean): boolean;\nxor(y: boolean): (y: boolean) => boolean;\n```\n\n
\n\n
\n\nR.xor source\n\n```javascript\nexport function xor(a, b){\n if (arguments.length === 1) return _b => xor(a, _b)\n\n return Boolean(a) && !b || Boolean(b) && !a\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { xor } from './xor.js'\n\ntest('compares two values with exclusive or', () => {\n expect(xor(true, true)).toBeFalse()\n expect(xor(true, false)).toBeTrue()\n expect(xor(false, true)).toBeTrue()\n expect(xor(false, false)).toBeFalse()\n})\n\ntest('when both values are truthy, it should return false', () => {\n expect(xor(true, 'foo')).toBeFalse()\n expect(xor(42, true)).toBeFalse()\n expect(xor('foo', 42)).toBeFalse()\n expect(xor({}, true)).toBeFalse()\n expect(xor(true, [])).toBeFalse()\n expect(xor([], {})).toBeFalse()\n expect(xor(new Date(), true)).toBeFalse()\n expect(xor(true, Infinity)).toBeFalse()\n expect(xor(Infinity, new Date())).toBeFalse()\n})\n\ntest('when both values are falsy, it should return false', () => {\n expect(xor(null, false)).toBeFalse()\n expect(xor(false, undefined)).toBeFalse()\n expect(xor(undefined, null)).toBeFalse()\n expect(xor(0, false)).toBeFalse()\n expect(xor(false, NaN)).toBeFalse()\n expect(xor(NaN, 0)).toBeFalse()\n expect(xor('', false)).toBeFalse()\n})\n\ntest('when one argument is truthy and the other is falsy, it should return true', () => {\n expect(xor('foo', null)).toBeTrue()\n expect(xor(null, 'foo')).toBeTrue()\n expect(xor(undefined, 42)).toBeTrue()\n expect(xor(42, undefined)).toBeTrue()\n expect(xor(Infinity, NaN)).toBeTrue()\n expect(xor(NaN, Infinity)).toBeTrue()\n expect(xor({}, '')).toBeTrue()\n expect(xor('', {})).toBeTrue()\n expect(xor(new Date(), 0)).toBeTrue()\n expect(xor(0, new Date())).toBeTrue()\n expect(xor([], null)).toBeTrue()\n expect(xor(undefined, [])).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {xor} from 'rambda'\n\ndescribe('R.xor', () => {\n it('happy', () => {\n xor(true, false) // $ExpectType boolean\n })\n it('curry', () => {\n xor(true)(false) // $ExpectType boolean\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#xor)\n\n### zip\n\n```typescript\n\nzip(x: K[], y: V[]): KeyValuePair[]\n```\n\nIt will return a new array containing tuples of equally positions items from both `x` and `y` lists. \n\nThe returned list will be truncated to match the length of the shortest supplied list.\n\nTry this R.zip example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nzip(x: K[], y: V[]): KeyValuePair[];\nzip(x: K[]): (y: V[]) => KeyValuePair[];\n```\n\n
\n\n
\n\nR.zip source\n\n```javascript\nexport function zip(left, right){\n if (arguments.length === 1) return _right => zip(left, _right)\n\n const result = []\n const length = Math.min(left.length, right.length)\n\n for (let i = 0; i < length; i++){\n result[ i ] = [ left[ i ], right[ i ] ]\n }\n\n return result\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { zip } from './zip.js'\n\nconst array1 = [ 1, 2, 3 ]\nconst array2 = [ 'A', 'B', 'C' ]\n\ntest('should return an array', () => {\n const actual = zip(array1)(array2)\n expect(actual).toBeInstanceOf(Array)\n})\n\ntest('should return and array or tuples', () => {\n const expected = [\n [ 1, 'A' ],\n [ 2, 'B' ],\n [ 3, 'C' ],\n ]\n const actual = zip(array1, array2)\n expect(actual).toEqual(expected)\n})\n\ntest('should truncate result to length of shorted input list', () => {\n const expectedA = [\n [ 1, 'A' ],\n [ 2, 'B' ],\n ]\n const actualA = zip([ 1, 2 ], array2)\n expect(actualA).toEqual(expectedA)\n\n const expectedB = [\n [ 1, 'A' ],\n [ 2, 'B' ],\n ]\n const actualB = zip(array1, [ 'A', 'B' ])\n expect(actualB).toEqual(expectedB)\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {zip} from 'rambda'\n\ndescribe('R.zip', () => {\n it('happy', () => {\n const array1 = [1, 2, 3]\n const array2 = ['A', 'B', 'C']\n\n const result = zip(array1)(array2)\n result // $ExpectType KeyValuePair[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#zip)\n\n### zipObj\n\n```typescript\n\nzipObj(keys: K[], values: T[]): { [P in K]: T }\n```\n\nIt will return a new object with keys of `keys` array and values of `values` array.\n\nTry this R.zipObj example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nzipObj(keys: K[], values: T[]): { [P in K]: T };\nzipObj(keys: K[]): (values: T[]) => { [P in K]: T };\nzipObj(keys: K[], values: T[]): { [P in K]: T };\nzipObj(keys: K[]): (values: T[]) => { [P in K]: T };\n```\n\n
\n\n
\n\nR.zipObj source\n\n```javascript\nimport { take } from './take.js'\n\nexport function zipObj(keys, values){\n if (arguments.length === 1) return yHolder => zipObj(keys, yHolder)\n\n return take(values.length, keys).reduce((\n prev, xInstance, i\n ) => {\n prev[ xInstance ] = values[ i ]\n\n return prev\n }, {})\n}\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { equals } from './equals.js'\nimport { zipObj } from './zipObj.js'\n\ntest('zipObj', () => {\n expect(zipObj([ 'a', 'b', 'c' ], [ 1, 2, 3 ])).toEqual({\n a : 1,\n b : 2,\n c : 3,\n })\n})\n\ntest('0', () => {\n expect(zipObj([ 'a', 'b' ])([ 1, 2, 3 ])).toEqual({\n a : 1,\n b : 2,\n })\n})\n\ntest('1', () => {\n expect(zipObj([ 'a', 'b', 'c' ])([ 1, 2 ])).toEqual({\n a : 1,\n b : 2,\n })\n})\n\ntest('ignore extra keys', () => {\n const result = zipObj([ 'a', 'b', 'c', 'd', 'e', 'f' ], [ 1, 2, 3 ])\n const expected = {\n a : 1,\n b : 2,\n c : 3,\n }\n\n expect(equals(result, expected)).toBeTrue()\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {zipObj} from 'rambda'\n\ndescribe('R.zipObj', () => {\n it('happy', () => {\n // this is wrong since 24.10.2020 `@types/ramda` changes\n const result = zipObj(['a', 'b', 'c', 'd'], [1, 2, 3])\n ;[result.a, result.b, result.c, result.d] // $ExpectType number[]\n })\n it('imported from @types/ramda', () => {\n const result = zipObj(['a', 'b', 'c'], [1, 2, 3])\n const curriedResult = zipObj(['a', 'b', 'c'])([1, 2, 3])\n ;[result.a, result.b, result.c] // $ExpectType number[]\n ;[curriedResult.a, curriedResult.b, curriedResult.c] // $ExpectType number[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#zipObj)\n\n### zipWith\n\n```typescript\n\nzipWith(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TResult[]\n```\n\nTry this R.zipWith example in Rambda REPL\n\n
\n\nAll TypeScript definitions\n\n```typescript\nzipWith(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TResult[];\nzipWith(fn: (x: T, y: U) => TResult, list1: T[]): (list2: U[]) => TResult[];\nzipWith(fn: (x: T, y: U) => TResult): (list1: T[], list2: U[]) => TResult[];\n```\n\n
\n\n
\n\nR.zipWith source\n\n```javascript\nimport { curry } from './curry.js'\nimport { take } from './take.js'\n\nfunction zipWithFn(\n fn, x, y\n){\n return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[ i ]))\n}\n\nexport const zipWith = curry(zipWithFn)\n```\n\n
\n\n
\n\nTests\n\n```javascript\nimport { add } from './add.js'\nimport { zipWith } from './zipWith.js'\n\nconst list1 = [ 1, 2, 3 ]\nconst list2 = [ 10, 20, 30, 40 ]\nconst list3 = [ 100, 200 ]\n\ntest('when second list is shorter', () => {\n const result = zipWith(\n add, list1, list3\n )\n expect(result).toEqual([ 101, 202 ])\n})\n\ntest('when second list is longer', () => {\n const result = zipWith(\n add, list1, list2\n )\n expect(result).toEqual([ 11, 22, 33 ])\n})\n```\n\n
\n\n
\n\nTypeScript test\n\n```typescript\nimport {zipWith} from 'rambda'\n\nconst list1 = [1, 2]\nconst list2 = [10, 20, 30]\n\ndescribe('R.zipWith', () => {\n it('happy', () => {\n const result = zipWith(\n (x, y) => {\n x // $ExpectType number\n y // $ExpectType number\n return `${x}-${y}`\n },\n list1,\n list2\n )\n\n result // $ExpectType string[]\n })\n it('curried', () => {\n const result = zipWith((x, y) => {\n x // $ExpectType unknown\n y // $ExpectType unknown\n return `${x}-${y}`\n })(list1, list2)\n\n result // $ExpectType string[]\n })\n})\n```\n\n
\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#zipWith)\n\n## ❯ CHANGELOG\n\n9.4.2 \n\n- Fix TS issue when `R.take` is used as part of `R.pipe`.\n\nMoving away from `Ramda` types which are problematic in this case:\n\n```typescript\nconst data = ['foo', 'bar', 'baz', 'qux']\nconst result = piped(\n\tdata,\n\tfilter(\n\t\tx => x.length >= 2\n\t),\n\ttakeLast(2),\n)\n```\n\n9.4.1\n\n- Fix bug with `R.differenceWith` when two arrays has same length - [Issue #750](https://github.com/selfrefactor/rambda/issues/757)\n\n- Allow path input to not be transformed when string numbers are there - [Issue #750](https://github.com/selfrefactor/rambda/issues/750)\n\n9.4.0\n\n- Fix `deno` release\n\n- Fix too strict `true` condition in `R.ifElse` - [Issue #750](https://github.com/selfrefactor/rambda/issues/750)\n\n- Change `R.groupBy` typings to match `@types/ramda` typings\n\n9.3.0\n\n- Breaking change in relation to TS typings of `R.assoc`, `R.dissoc` and `R.modify` - https://github.com/ramda/types/pull/37\n\n- Add `R.isNotEmpty` as it is new method in `Ramda`\n\n- Fix `R.head`/`R.last` TS definition - It returns `undefined` if array has length of 0. Before \n\n9.2.1\n\n- Broken `Deno` build - [Issue #731](https://github.com/selfrefactor/rambda/issues/731)\n\n9.2.0\n\n- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)\n\n- Fix implementation of `R.unless` function - https://github.com/selfrefactor/rambda/pull/726 \n\n9.1.1\n\n- Faster R.equals with Object.is short circuit - https://github.com/selfrefactor/rambda/pull/725\n\n- Fix R.cond transform is unary - https://github.com/selfrefactor/rambda/issues/720\n\n9.1.0\n\nAdd these methods\n\n- insert\n- insertAll\n- lt\n- lte\n- isNotNil\n- pickBy\n- pathSatisfies\n- swap\n- mergeDeepLeft\n\n9.0.1\n\n- Fix bad TS typings, due to missing declaration - [Issue #716](https://github.com/selfrefactor/rambda/issues/716)\n\n9.0.0\n\nBreaking change in TS definitions of `lenses` as now they are synced to `Ramda` types.\n\n- Add `R.sortWith` - [Issue #707](https://github.com/selfrefactor/rambda/issues/707)\n\n- Add `R.innerJoin`, `R.gt`, `R.gte`, `R.reduceBy`, `R.hasIn`\n\n8.6.0\n\n- Wrong typing for `R.dissocPath` - [Issue #709](https://github.com/selfrefactor/rambda/issues/709)\n\n- Update build dependencies\n\n8.5.0\n\n- Revert changes in `R.anyPass` introduced in `8.4.0` release. The reason is that the change was breaking the library older than `5.2.0` TypeScript.\n\n- Wrong `R.partial` TS definition - [Issue #705](https://github.com/selfrefactor/rambda/issues/705)\n\n- Add `R.dropRepeatsBy`\n\n- Add `R.empty`\n\n- Add `R.eqBy`\n\n- Add `R.forEachObjIndexed`\n\n8.4.0\n\n- Add `R.dissocPath`\n\n- Fix TS definitions of `R.head/R.last` and add missing handle of empty string\n\n- Add `R.removeIndex` - method was before only in `Rambdax`, but now since `R.dissocPath` is using it, it is added to main library.\n\n- Allow `R.omit` to pass numbers as part of properties to omit, i.e. `R.omit(['a', 1], {a: {1: 1, 2: 2}})`\n\n- R.keys always returns strings - [MR #700](https://github.com/selfrefactor/rambda/pull/700)\n\n- Improve `R.prepend/R.append` type interference - [MR #699](https://github.com/selfrefactor/rambda/pull/699)\n\n- Change `R.reduce` TS definitions so index is always received - [MR #696](https://github.com/selfrefactor/rambda/pull/696)\n\n- Functions as a type guard in `R.anyPass` TS definitions - [MR #695](https://github.com/selfrefactor/rambda/pull/695)\n\n- Fix R.append's curried type - [MR #694](https://github.com/selfrefactor/rambda/pull/694)\n\n- Fix cannot compare errors in `Deno` with `R.equals` - [Issue #704](https://github.com/selfrefactor/rambda/issues/704).\n\n- Fix cannot compare `BigInt` with `R.equals` \n\n8.3.0\n\nAdd the following methods:\n\n- binary\n- call\n- collectBy\n- comparator\n- composeWith\n\n8.2.0\n\nAdd the following methods:\n\n- addIndex\n- addIndexRight\n- ap\n- aperture\n- applyTo\n- ascend\n- descend\n\n8.1.0\n\n- Fix input order of TS definitions for `R.propEq` method - [Issue #688](https://github.com/selfrefactor/rambda/issues/688). The issue was due to 8.0.0 was shipped with TS definitions of `7.5.0` release.\n\n- Add `R.differenceWith` method - [Issue #91](https://github.com/selfrefactor/rambdax/issues/91)\n\n8.0.0\n\n- handle falsy values in merge methods - https://github.com/ramda/ramda/pull/3222\n\n- `R.head`/`R.last` don't return `undefined` for non-empty arrays\n\n- `R.type` supports dates in TS definition - `Rambda` already did support dates in JS.\n\n- Improve typings of `R.endsWith/startsWith` with regard to `string` input. - [PR #622](https://github.com/selfrefactor/rambda/pull/622)\n\n- Handle list as falsy value in `R.reduce` - [Ramda MR](https://github.com/ramda/ramda/pull/2997/files)\n\n- `R.nop` is removed - it will be moved to `Rambdax` as `R.noop`\n\n- `R.includes` is no longer using string literal in TypeScript definitions\n\n> Reason for breaking change - synchronize with Ramda `0.29.0` release:\n\n- change order of `R.propEq` - [Ramda MR](https://github.com/ramda/ramda/pull/2938/files)\n\n7.5.0\n\n- IMPORTANT: Remove `export` property in `package.json` in order to allow `Rambda` support for projects with `\"type\": \"module\"` in `package.json` - [Issue #667](https://github.com/selfrefactor/rambda/issues/657)\n\n- Add `R.unnest` - [Rambdax issue 89](https://github.com/selfrefactor/rambdax/issues/89)\n\n- `R.uniq` is not using `R.equals` as Ramda does - [Issue #88](https://github.com/selfrefactor/rambdax/issues/88)\n\n- Fix `R.path(['non','existing','path'], obj)` TS definition as 7.4.0 release caused TS errors - [Issue #668](https://github.com/selfrefactor/rambda/issues/668)\n\n7.4.0\n\n- Synchronize with `@types/ramda` - `R.prop`, `R.path`, `R.pickAll`\n\n- Remove `esm` Rollup output due to tree-shaking issues.\n\n- Upgrade all dev dependencies.\n\n7.3.0\n\n- Important - changing import declaration in `package.json` in order to fix tree-shaking issue - [Issue #647](https://github.com/selfrefactor/rambda/issues/647)\n\n- Add `R.modify`\n\n- Allow multiple inputs in TypeScript versions of `R.anyPass` and `R.allPass` - [Issue #642](https://github.com/selfrefactor/rambda/issues/604)\n\n- Using wrong clone of object in `R.mergeDeepRight` - [Issue #650](https://github.com/selfrefactor/rambda/issues/650)\n\n- Missing early return in `R.where` - [Issue #648](https://github.com/selfrefactor/rambda/issues/648)\n\n- `R.allPass` doesn't accept more than 1 parameters for function predicates- [Issue #604](https://github.com/selfrefactor/rambda/issues/604)\n\n7.2.1\n\n- Remove bad typings of `R.propIs` which caused the library to cannot be build with TypeScript. \n\n- Drop support for `Wallaby` as per [https://github.com/wallabyjs/public/issues/3037](https://github.com/wallabyjs/public/issues/3037)\n\n7.2.0\n\n- Wrong `R.update` if index is `-1` - [PR #593](https://github.com/selfrefactor/rambda/pull/593)\n\n- Wrong curried typings in `R.anyPass` - [Issue #642](https://github.com/selfrefactor/rambda/issues/642)\n\n- `R.modifyPath` not exported - [Issue #640](https://github.com/selfrefactor/rambda/issues/640)\n\n- Add new method `R.uniqBy`. Implementation is coming from [Ramda MR#2641](https://github.com/ramda/ramda/pull/2641)\n\n- Apply the following changes from `@types/rambda`:\n\n-- [https://github.com/DefinitelyTyped/DefinitelyTyped/commit/bab47272d52fc7bb81e85da36dbe9c905a04d067](add `AnyFunction` and `AnyConstructor`)\n\n-- Improve `R.ifElse` typings - https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59291\n\n-- Make `R.propEq` safe for `null/undefined` arguments - https://github.com/ramda/ramda/pull/2594/files\n\n7.1.4\n\n- `R.mergeRight` not found on `Deno` import - [Issue #633](https://github.com/selfrefactor/rambda/issues/633)\n\n7.1.0\n\n- Add `R.mergeRight` - introduced by Ramda's latest release. While Ramda renames `R.merge`, Rambda will keep `R.merge`.\n\n- Rambda's `pipe/compose` doesn't return proper length of composed function which leads to issue with `R.applySpec`. It was fixed by using Ramda's `pipe/compose` logic - [Issue #627](https://github.com/selfrefactor/rambda/issues/627)\n\n- Replace `Async` with `Promise` as return type of `R.type`.\n\n- Add new types as TypeScript output for `R.type` - \"Map\", \"WeakMap\", \"Generator\", \"GeneratorFunction\", \"BigInt\", \"ArrayBuffer\"\n\n- Add `R.juxt` method\n\n- Add `R.propSatisfies` method\n\n- Add new methods after `Ramda` version upgrade to `0.28.0`:\n\n-- R.count\n-- R.modifyPath\n-- R.on\n-- R.whereAny\n-- R.partialObject\n\n7.0.3\n\nRambda.none has wrong logic introduced in version `7.0.0` - [Issue #625](https://github.com/selfrefactor/rambda/issues/625)\n\n7.0.2\n\nRambda doesn't work with `pnpm` due to wrong export configuration - [Issue #619](https://github.com/selfrefactor/rambda/issues/619)\n\n7.0.1\n\n- Wrong ESM export configuration in `package.json` - [Issue #614](https://github.com/selfrefactor/rambda/issues/614)\n\n7.0.0\n\n- Breaking change - sync `R.compose`/`R.pipe` with `@types/ramda`. That is significant change so as safeguard, it will lead a major bump. Important - this lead to raising required TypeScript version to `4.2.2`. In other words, to use `Rambda` you'll need TypeScript version `4.2.2` or newer.\n\nRelated commit in `@types/ramda` - https://github.com/DefinitelyTyped/DefinitelyTyped/commit/286eff4f76d41eb8f091e7437eabd8a60d97fc1f#diff-4f74803fa83a81e47cb17a7d8a4e46a7e451f4d9e5ce2f1bd7a70a72d91f4bc1\n\nThere are several other changes in `@types/ramda` as stated in [this comment](https://github.com/ramda/ramda/issues/2976#issuecomment-990408945). This leads to change of typings for the following methods in **Rambda**:\n\n-- R.unless\n\n-- R.toString\n\n-- R.ifElse\n\n-- R.always\n\n-- R.complement\n\n-- R.cond\n\n-- R.is\n\n-- R.sortBy\n\n-- R.dissoc\n\n-- R.toPairs\n\n-- R.assoc\n\n-- R.toLower\n\n-- R.toUpper\n\n- One more reason for the breaking change is changing of export declarations in `package.json` based on [this blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#packagejson-exports-imports-and-self-referencing) and [this merged Ramda's PR](https://github.com/ramda/ramda/pull/2999). This also led to renaming of `babel.config.js` to `babel.config.cjs`. \n\n- Add `R.apply`, `R.bind` and `R.unapply`\n\n- `R.startsWith/R.endsWith` now support lists as inputs. This way, it matches current Ramda behavior. \n\n- Remove unused typing for `R.chain`.\n\n- `R.map`/`R.filter` no longer accept bad inputs as iterable. This way, Rambda behaves more like Ramda, which also throws.\n\n- Make `R.lastIndexOf` follow the logic of `R.indexOf`.\n\n- Change `R.type` logic to Ramda logic. This way, `R.type` can return `Error` and `Set` as results.\n\n- Add missing logic in `R.equals` to compare sets - [Issue #599](https://github.com/selfrefactor/rambda/issues/599)\n\n- Improve list cloning - [Issue #595](https://github.com/selfrefactor/rambda/issues/595)\n\n- Handle multiple inputs with `R.allPass` and `R.anyPass` - [Issue #604](https://github.com/selfrefactor/rambda/issues/604)\n\n- Fix `R.length` wrong logic with inputs as `{length: 123}` - [Issue #606](https://github.com/selfrefactor/rambda/issues/606).\n\n- Improve non-curry typings of `R.merge` by using types from [mobily/ts-belt](https://github.com/mobily/ts-belt).\n\n- Improve performance of `R.uniqWith`.\n\n- Wrong `R.update` if index is `-1` - [PR #593](https://github.com/selfrefactor/rambda/pull/593)\n\n- Make `R.eqProps` safe for falsy inputs - based on [this opened Ramda PR](https://github.com/ramda/ramda/pull/2943).\n\n- Incorrect benchmarks for `R.pipe/R.compose` - [Issue #608](https://github.com/selfrefactor/rambda/issues/608)\n\n- Fix `R.last/R.head` typings - [Issue #609](https://github.com/selfrefactor/rambda/issues/609) \n\n6.9.0\n\n- Fix slow `R.uniq` methods - [Issue #581](https://github.com/selfrefactor/rambda/issues/581)\n\nFixing `R.uniq` was done by improving `R.indexOf` which has performance implication to all methods importing `R.indexOf`:\n\n- R.includes\n- R.intersection\n- R.difference\n- R.excludes\n- R.symmetricDifference\n- R.union\n\n- R.without no longer support the following case - `without('0:1', ['0', '0:1']) // => ['0']`. Now it throws as the first argument should be a list, not a string. Ramda, on the other hand, returns an empty list - https://github.com/ramda/ramda/issues/3086. \n\n6.8.3\n\n- Fix TypeScript build process with `rambda/immutable` - [Issue #572](https://github.com/selfrefactor/rambda/issues/572)\n\n- Add `R.objOf` method\n\n- Add `R.mapObjIndexed` method\n\n- Publish shorter README.md version to NPM\n\n6.8.0\n\n- `R.has` use `Object.prototype.hasOwnProperty`- [Issue #572](https://github.com/selfrefactor/rambda/issues/572)\n\n- Expose `immutable.ts` typings which are Rambda typings with `readonly` statements - [Issue #565](https://github.com/selfrefactor/rambda/issues/565)\n\n- Fix `R.intersection` wrong order compared to Ramda.\n\n- `R.path` wrong return of `null` instead of `undefined` when path value is `null` - [PR #577](https://github.com/selfrefactor/rambda/pull/577)\n\n6.7.0\n\n- Remove `ts-toolbelt` types from TypeScript definitions. Most affected are the following methods, which lose one of its curried definitions:\n\n1. R.maxBy\n2. R.minBy\n3. R.pathEq\n4. R.viewOr\n5. R.when\n6. R.merge\n7. R.mergeDeepRight\n8. R.mergeLeft\n\n6.6.0\n\n- Change `R.piped` typings to mimic that of `R.pipe`. Main difference is that `R.pipe` is focused on unary functions.\n\n- Fix wrong logic when `R.without` use `R.includes` while it should use array version of `R.includes`.\n\n- Use uglify plugin for UMD bundle.\n\n- Remove `dist` folder from `.gitignore` in order to fix `Deno` broken package. [Issue #570](https://github.com/selfrefactor/rambda/issues/570)\n\n- Improve `R.fromPairs` typings - [Issue #567](https://github.com/selfrefactor/rambda/issues/567)\n\n6.5.3\n\n- Wrong logic where `R.without` use `R.includes` while it should use the array version of `R.includes`\n\nThis is Ramda bug, that Rambda also has before this release - https://github.com/ramda/ramda/issues/3086\n\n6.5.2\n\n- Wrong `R.defaultTo` typings - changes introduced in v6.5.0 are missing their TS equivalent.\n\n- Update dependencies\n\n6.5.1\n\nFix wrong versions in changelog\n\n6.5.0\n\n- `R.defaultTo` no longer accepts infinite inputs, thus it follows Ramda implementation.\n\n- `R.equals` supports equality of functions.\n\n- `R.pipe` doesn't use `R.compose`.\n\n- Close [Issue #561](https://github.com/selfrefactor/rambda/issues/561) - export several internal TS interfaces and types\n\n- Close [Issue #559](https://github.com/selfrefactor/rambda/issues/559) - improve `R.propOr` typings\n\n- Add `CHANGELOG.md` file in release files list\n\n> This is only part of the changelog. You can read the full text in [CHANGELOG.md](CHANGELOG.md) file.\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-changelog)\n\n## ❯ Additional info\n\n> Most influential contributors(in alphabetical order)\n\n- ![farwayer avatar](https://avatars.githubusercontent.com/farwayer) [@farwayer](https://github.com/farwayer) - improving performance in R.find, R.filter; give the idea how to make benchmarks more reliable;\n\n- ![thejohnfreeman avatar](https://avatars.githubusercontent.com/thejohnfreeman) [@thejohnfreeman](https://github.com/thejohnfreeman) - add R.assoc, R.chain;\n\n- ![peeja avatar](https://avatars.githubusercontent.com/peeja) [@peeja](https://github.com/peeja) - add several methods and fix mutiple issues; provides great MR documentation\n\n- ![helmuthdu avatar](https://avatars.githubusercontent.com/helmuthdu) [@helmuthdu](https://github.com/helmuthdu) - add R.clone; help improve code style;\n\n- ![jpgorman avatar](https://avatars.githubusercontent.com/jpgorman) [@jpgorman](https://github.com/jpgorman) - add R.zip, R.reject, R.without, R.addIndex;\n\n- ![ku8ar avatar](https://avatars.githubusercontent.com/ku8ar) [@ku8ar](https://github.com/ku8ar) - add R.slice, R.propOr, R.identical, R.propIs and several math related methods; introduce the idea to display missing Ramda methods;\n\n- ![romgrk avatar](https://avatars.githubusercontent.com/romgrk) [@romgrk](https://github.com/romgrk) - add R.groupBy, R.indexBy, R.findLast, R.findLastIndex;\n\n- ![squidfunk avatar](https://avatars.githubusercontent.com/squidfunk) [@squidfunk](https://github.com/squidfunk) - add R.assocPath, R.symmetricDifference, R.difference, R.intersperse;\n\n- ![synthet1c avatar](https://avatars.githubusercontent.com/synthet1c) [@synthet1c](https://github.com/synthet1c) - add all lenses methods; add R.applySpec, R.converge;\n\n- ![vlad-zhukov avatar](https://avatars.githubusercontent.com/vlad-zhukov) [@vlad-zhukov](https://github.com/vlad-zhukov) - help with configuring Rollup, Babel; change export file to use ES module exports;\n\n> Rambda references\n\n- [Interview with Dejan Totef at SurviveJS blog](https://survivejs.com/blog/rambda-interview/)\n\n- [Awesome functional Javascript programming libraries](https://github.com/stoeffel/awesome-fp-js#libraries)\n\n- [Overview of Rambda pros/cons](https://mobily.github.io/ts-belt/docs/#rambda-%EF%B8%8F)\n\n> Links to Rambda\n\n- [awesome-fp-js](https://github.com/stoeffel/awesome-fp-js)\n\n- [Web Tools Weekly #280](https://mailchi.mp/webtoolsweekly/web-tools-280)\n\n- [awesome-docsify](https://github.com/docsifyjs/awesome-docsify)\n\n> Deprecated from `Used by` section\n\n- [SAP's Cloud SDK](https://github.com/SAP/cloud-sdk) - This repo doesn't uses `Rambda` since *October/2020* [commit that removes Rambda](https://github.com/SAP/cloud-sdk/commit/b29b4f915c4e4e9c2441e7b6b67cf83dac1fdac3)\n\n[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#-additional-info)\n\n## My other libraries\n\n\n \n \n \n \n \n \n \n \n \n
\n

Niketa theme

\n Collection of 9 light VSCode themes\n
\n

Niketa dark theme

\n Collection of 9 dark VSCode themes\n
\n

String-fn

\n String utility library\n
\n

Useful Javascript libraries

\n Large collection of JavaScript,TypeScript and Angular related repos links\n
\n

Run-fn

\n CLI commands for lint JS/TS files, commit git changes and upgrade of dependencies\n
\n\n## Stargazers over time\n\n[![Stargazers over time](https://starchart.cc/selfrefactor/rambda.svg)](https://starchart.cc/selfrefactor/rambda)", "licenseText": "MIT License\n\nCopyright (c) 2017 Dejan Toteff\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" }, "artifacts": [], "remote": { "resolved": "https://registry.npmjs.org/rambda/-/rambda-9.4.2.tgz", "type": "tarball", "reference": "https://registry.npmjs.org/rambda/-/rambda-9.4.2.tgz", "hash": "", "integrity": "sha512-++euMfxnl7OgaEKwXh9QqThOjMeta2HH001N1v4mYQzBjJBnmXBh2BCK6dZAbICFVXOFUVD3xFG0R3ZPU0mxXw==", "registry": "npm", "packageName": "rambda", "cacheIntegrity": "sha512-++euMfxnl7OgaEKwXh9QqThOjMeta2HH001N1v4mYQzBjJBnmXBh2BCK6dZAbICFVXOFUVD3xFG0R3ZPU0mxXw== sha1-Gg2mFxylgw6IMR8Ag+X9i5RaMq0=" }, "registry": "npm", "hash": "fbe7ae31fc6797b3a06842b05e1f50a9384e8cc7ad6b61c7d34d4dd6fe26610cc18c9067997061d8108ae9d6406c80855573855150f7c451b447764f5349b15f" }