{"id":22982359,"url":"https://github.com/niradler/fn-lifecycle","last_synced_at":"2025-07-01T13:08:41.681Z","repository":{"id":93026772,"uuid":"607392511","full_name":"niradler/fn-lifecycle","owner":"niradler","description":"Control the before and after of running a function, can be used for validation, caching, data mutation and more.","archived":false,"fork":false,"pushed_at":"2023-03-14T22:11:02.000Z","size":175,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-06T11:03:48.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://niradler.github.io/fn-lifecycle/","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/niradler.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":"2023-02-27T22:10:33.000Z","updated_at":"2023-03-27T21:32:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"d69f4b92-b332-4e71-83a1-826820da9c0c","html_url":"https://github.com/niradler/fn-lifecycle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niradler/fn-lifecycle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niradler%2Ffn-lifecycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niradler%2Ffn-lifecycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niradler%2Ffn-lifecycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niradler%2Ffn-lifecycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niradler","download_url":"https://codeload.github.com/niradler/fn-lifecycle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niradler%2Ffn-lifecycle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262969886,"owners_count":23392530,"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":[],"created_at":"2024-12-15T02:18:01.497Z","updated_at":"2025-07-01T13:08:41.670Z","avatar_url":"https://github.com/niradler.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# function lifecycle\n\nControl the before and after of running a function, can be used for validation, caching, data mutation and more.\n\n## Features\n\n- Wraps functions to create a lifecycle of before and after\n- Supports TypeScript\n- Can be used for validation, caching, and more\n- Easy to use and integrate into existing projects\n- Provides a flexible and customizable solution for managing function lifecycles\n\n## Usage\n\n```sh\nnpm i fn-lifecycle\n```\n\n```ts\nimport { Lifecycle } from \"fn-lifecycle\";\nconst lc = new Lifecycle({ name: 1 });\nfunction validate(name) {\n  if (!name || (name \u0026\u0026 name.length \u003c this._.config.name)) {\n    throw new Error(\"name is missing\");\n  }\n}\nconst addGreet = (name) =\u003e `Hi, ${name}`;\nconst greet = lc.before(validate).after(addGreet).decorate(whatIsMyName);\nconst myName = \"Nir\";\nawait greet(myName);\nexpect(await greet(myName)).toBe(`Hi, ${myName}`);\n```\n\ncheck the tests folder for more complete examples.\n\n### Contributing\n\nContributions are always welcome! If you have any ideas or suggestions for how to improve this package, please feel free to open an issue or submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniradler%2Ffn-lifecycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniradler%2Ffn-lifecycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniradler%2Ffn-lifecycle/lists"}