remeda
Version:
A utility library for JavaScript and Typescript.
1 lines • 1.47 kB
Source Map (JSON)
{"version":3,"file":"identity.cjs","names":["identityImplementation: IdentityFunction"],"sources":["../src/identity.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Accept functions with more than a single parameter too, we use `any` because that catches all possible cases.\ntype IdentityFunction = <T>(firstParameter: T, ...rest: any) => T;\n\n/**\n * A function that returns the first argument passed to it.\n *\n * Notice that this is a dataLast impl where the function needs to be invoked\n * to get the \"do nothing\" function.\n *\n * See also:\n * * `doNothing` - A function that doesn't return anything.\n * * `constant` - A function that ignores the input arguments and returns the same value on every invocation.\n *\n * @signature\n * R.identity();\n * @example\n * R.map([1,2,3], R.identity()); // => [1,2,3]\n * @category Function\n */\nexport function identity(): IdentityFunction {\n // Notice that the exported identity function is just the \"factory\" for the\n // identity function. We do it this way so that all \"Function\" utilities have\n // a similar API where the function is called, and not just used \"headless\".\n // e.g. `identity()` and not `identity`, just like the API for `constant(1)`.\n return identityImplementation;\n}\n\nconst identityImplementation: IdentityFunction = (firstParameter) =>\n firstParameter;\n"],"mappings":"AAmBA,SAAgB,GAA6B,CAK3C,OAAO,EAGT,MAAMA,EAA4C,GAChD"}