{"id":17105599,"url":"https://github.com/yarnaimo/lifts","last_synced_at":"2025-08-04T04:38:05.298Z","repository":{"id":71659082,"uuid":"260206350","full_name":"yarnaimo/lifts","owner":"yarnaimo","description":"⛵ LIghtweight Functional programming library for TypeScript","archived":false,"fork":false,"pushed_at":"2020-07-27T03:42:04.000Z","size":206,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T01:13:41.175Z","etag":null,"topics":["functional-programming","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yarnaimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-04-30T12:32:20.000Z","updated_at":"2024-05-11T20:33:16.000Z","dependencies_parsed_at":"2023-05-13T11:15:08.483Z","dependency_job_id":null,"html_url":"https://github.com/yarnaimo/lifts","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarnaimo%2Flifts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarnaimo%2Flifts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarnaimo%2Flifts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarnaimo%2Flifts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yarnaimo","download_url":"https://codeload.github.com/yarnaimo/lifts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650754,"owners_count":21139681,"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":["functional-programming","typescript"],"created_at":"2024-10-14T15:42:29.304Z","updated_at":"2025-04-13T01:13:46.136Z","avatar_url":"https://github.com/yarnaimo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lifts\n\n**LI**ghtweight **F**unctional programming library for **T**ype**S**cript\n\n## Install\n\n```sh\nyarn add lifts remeda\n# or\nnpm i -S lifts remeda\n```\n\n## Usage\n\n### Do\n\nShorthand for Immediately Invoked Function Expression\n\n```ts\nconst date = new Date('2020-04-17')\n\nconst result: number | null = Do(() =\u003e {\n    // check date is valid\n    if (!isNaN(date)) {\n        return date.getDate()\n    } else {\n        return null\n    }\n})\nresult // =\u003e 17\n\n// equivalent to\nconst result = (() =\u003e {\n    if (!isNaN(date)) {\n        return date.getDate()\n    } else {\n        return null\n    }\n})()\n```\n\n### Switch\n\nObject-Style `switch`\n\n```ts\nconst fn = (value: string) =\u003e\n    Switch(value)(\n        {\n            a: () =\u003e 'String A',\n            b: () =\u003e 'String B',\n        },\n        () =\u003e null, // default value\n    )\n\nfn('a') // =\u003e 'string A'\nfn('b') // =\u003e 'string B'\nfn('c') // =\u003e null (default value)\n```\n\n### Result\n\n```ts\nconst parseDate = (dateStr: string): IResult\u003cDate, Error\u003e =\u003e {\n    const date = new Date(dateStr)\n\n    // check date is valid\n    if (!isNaN(date)) {\n        return Result.ok(date)\n    } else {\n        return Result.err(new Error('Invalid Date'))\n    }\n}\n\nparseDate('2020-04-17')\n// =\u003e { isOk: true, valueOrError: Date('2020-04-17') }\n\nparseDate('foo')\n// =\u003e { isOk: false, valueOrError: Error('Invalid Date') }\n```\n\n#### Result.switch\n\n```ts\nconst result = parseDate('2020-04-17')\n\nResult.switch(result)({\n    ok: (value: Date) =\u003e {\n        // called if result is Ok\n        return value.getDate()\n    },\n    err: (error: Error) =\u003e {\n        // called if result is Err\n        return null\n    },\n})\n// =\u003e 17\n```\n\n```ts\nconst result = parseDate('foo')\n\nResult.switch(result)({\n    ok: (value) =\u003e {\n        return value.getDate()\n    },\n    err: (error) =\u003e {\n        return null\n    },\n})\n// =\u003e null\n```\n\n#### Result.wrap\n\nWraps Error with `Result.err()` if error caught, else wraps value with `Result.ok()`.\n\n```ts\nconst result = Result.wrap(() =\u003e {\n    if (condition) {\n        return true\n    } else {\n        throw new Error()\n    }\n})\n```\n\n### MapAsync\n\n\u003c!-- ```ts\n``` --\u003e\n\n### Pipe\n\n\u003c!-- ```ts\n``` --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarnaimo%2Flifts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarnaimo%2Flifts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarnaimo%2Flifts/lists"}