{"id":15704263,"url":"https://github.com/rpearce/ts-fns","last_synced_at":"2025-05-12T14:22:38.964Z","repository":{"id":42509350,"uuid":"451000369","full_name":"rpearce/ts-fns","owner":"rpearce","description":":warning: experimentation with typescript and functions","archived":false,"fork":false,"pushed_at":"2025-05-12T14:19:14.000Z","size":1617,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-12T14:22:30.542Z","etag":null,"topics":["fp","functional-programming","ts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rpearce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rpearce"}},"created_at":"2022-01-23T04:06:10.000Z","updated_at":"2025-05-12T14:19:16.000Z","dependencies_parsed_at":"2024-04-22T11:43:40.436Z","dependency_job_id":"0f1631f5-e11f-4dbe-988c-40528c3a6f04","html_url":"https://github.com/rpearce/ts-fns","commit_stats":{"total_commits":59,"total_committers":3,"mean_commits":"19.666666666666668","dds":0.4067796610169492,"last_synced_commit":"f58d7d6dc535aa041b6b3e2d07bc38c4d33c73f8"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpearce%2Fts-fns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpearce%2Fts-fns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpearce%2Fts-fns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpearce%2Fts-fns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rpearce","download_url":"https://codeload.github.com/rpearce/ts-fns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754365,"owners_count":21958849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fp","functional-programming","ts","typescript"],"created_at":"2024-10-03T20:10:58.562Z","updated_at":"2025-05-12T14:22:38.915Z","avatar_url":"https://github.com/rpearce.png","language":"TypeScript","funding_links":["https://github.com/sponsors/rpearce"],"categories":[],"sub_categories":[],"readme":"# @rpearce/ts-fns\n\nPublic domain ([LICENSE](./LICENSE)) Typescript helper functions for copying \u0026\npasting into projects. You can try it out here: https://npm.runkit.com/%40rpearce%2Fts-fns.\n\nMost functions export two calling styles, regular and partial application:\n\n```typescript\n// Regular\nhasProp('color', { color: 'blue' }) // true\n\n// Partial application\nhasPropU('color')({ color: 'blue' }) // true\n```\n\nSpecial thanks to the following for helping with some typings!\n\n* [Hackle Wayne](https://github.com/hackle)\n* [Lewis Campbell](https://github.com/LAC-Tech)\n\n## Typed functions\n\nNote: many functions have a unary, partial application style counterpart ending\nin `U`; e.g., `cond` also exports `condU`.\n\n* [`F`](./source/F.ts)\n* [`T`](./source/T.ts)\n* [`classNames`](./source/classNames.ts)\n* [`compose2`](./source/compose2.ts)\n* [`compose3`](./source/compose3.ts)\n* [`cond`, `condU`](./source/cond.ts)\n* [`constant`](./source/constant.ts)\n* [`doesPropEq`, `doesPropEqU`](./source/doesPropEq.ts)\n* [`filter`, `filterU`](./source/filter.ts)\n* [`hasProp`, `hasPropU`](./source/hasProp.ts)\n* [`identity`](./source/identity.ts)\n* [`insertAt`, `insertAtU`](./source/insertAt.ts)\n* [`isArray`](./source/isArray.ts)\n* [`isFunction`](./source/isFunction.ts)\n* [`isFunctor`](./source/isFunctor.ts)\n* [`isObject`](./source/isObject.ts)\n* [`lift2`, `lift2U`](./source/lift2.ts)\n* [`lift3`, `lift3U`](./source/lift3.ts)\n* [`log`](./source/log.ts)\n* [`map`, `mapU`](./source/map.ts)\n* [`mapObject`, `mapObjectU`](./source/mapObject.ts)\n* [`omitKeys`, `omitKeysU`](./source/omitKeys.ts)\n* [`pickKeys`, `pickKeysU`](./source/pickKeys.ts)\n* [`pipe2`](./source/pipe2.ts)\n* [`pipe3`](./source/pipe3.ts)\n* [`propOr`, `propOrU`](./source/propOr.ts)\n* [`reduce`, `reduceU`](./source/reduce.ts)\n* [`reduceRight`, `reduceRightU`](./source/reduceRight.ts)\n* [`shuffle`](./source/shuffle.ts)\n* [`sum`](./source/sum.ts)\n* [`takeN`, `takeNU`](./source/takeN.ts)\n* [`unless`, `unlessU`](./source/unless.ts)\n* [`when`, `whenU`](./source/when.ts)\n* [`zip`](./source/zip.ts)\n\n## TODO\n\n* `both`\n* `either`\n* `ifElse`\n* `neither`\n* `sortAscBy`\n* `sortDescBy`\n* ??? Open an issue to request something!\n\n## Usage\n\nCopy the functions and types you need into your project.\n\n### Example\n\n```typescript\nimport {\n  doesPropEq,\n  doesPropEqU,\n  takeN,\n  takeNU,\n} from './wherever-i-copied-the-helpers-to'\n\ntakeN(3, [1, 2, 3, 4])  // [1, 2, 3]\ntakeNU(3)([1, 2, 3, 4]) // [1, 2, 3]\n\ndoesPropEq('color', 'blue', { a: 'foo', b: 'bar', color: 'blue' })  // true\ndoesPropEqU('color')('blue')({ a: 'foo', b: 'bar', color: 'blue' }) // true\n```\n\n### More in-depth unary partial application example\n\n```typescript\nimport { lift2U, propOrU } from './wherever-i-copied-the-helpers-to'\n\nconst propOrNA      = propOr('N/A')\nconst getName       = propOrNA('name')\nconst getEmail      = propOrNA('email')\nconst joinWithPipe  = (x: string) =\u003e (y: string) =\u003e `${x} | ${y}`\nconst joinNameEmail = lift2U(joinWithPipe)(getName)(getEmail)\nconst input         = { name: 'bobert', email: 'bobert@email.com', foo: 'bar' }\n\nconsole.log(joinNameEmail(input))\n// 'bobert | bobert@email.com'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpearce%2Fts-fns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frpearce%2Fts-fns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpearce%2Fts-fns/lists"}