{"id":20390674,"url":"https://github.com/dizmo/functions-before","last_synced_at":"2026-05-20T14:05:07.228Z","repository":{"id":46987566,"uuid":"146290233","full_name":"dizmo/functions-before","owner":"dizmo","description":"dizmoFun: before handler","archived":false,"fork":false,"pushed_at":"2023-10-18T13:43:25.000Z","size":1327,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-15T10:08:43.449Z","etag":null,"topics":["before","dizmo","function","handler","javascript","library","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.org/package/@dizmo/functions-before","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dizmo.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":"2018-08-27T11:48:38.000Z","updated_at":"2022-11-16T19:00:05.000Z","dependencies_parsed_at":"2023-02-08T12:31:44.478Z","dependency_job_id":"ef1002c3-f48a-465d-98f0-23632ced3c0f","html_url":"https://github.com/dizmo/functions-before","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"fb5d72cd0d94291612eb34b82248d7d27e5a491f"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-before","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-before/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-before/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dizmo%2Ffunctions-before/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dizmo","download_url":"https://codeload.github.com/dizmo/functions-before/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940579,"owners_count":20045883,"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":["before","dizmo","function","handler","javascript","library","typescript"],"created_at":"2024-11-15T03:26:15.136Z","updated_at":"2026-05-20T14:05:07.199Z","avatar_url":"https://github.com/dizmo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM version](https://badge.fury.io/js/%40dizmo%2Ffunctions-before.svg)](https://npmjs.org/package/@dizmo/functions-before)\n[![Build Status](https://travis-ci.com/dizmo/functions-before.svg?branch=master)](https://travis-ci.com/dizmo/functions-before)\n[![Coverage Status](https://coveralls.io/repos/github/dizmo/functions-before/badge.svg?branch=master)](https://coveralls.io/github/dizmo/functions-before?branch=master)\n\n# @dizmo/functions-before\n\nReturns a function decorating an original function with a callback, which will be invoked before the execution of the original function. The callback can block the invocation of the original function by returning `false`.\n\n## Usage\n\n### Install\n\n```sh\nnpm install @dizmo/functions-before --save\n```\n\n### Require\n\n```javascript\nconst { before } = require(\"@dizmo/functions-before\");\n```\n\n### Examples\n\n```typescript\nimport { before } from \"@dizmo/functions-before\";\n```\n\n```typescript\nconst f1 = (value: number): number =\u003e {\n    return value;\n};\nconst f2 = before(f1, (\n    fn: Function, value: number\n): boolean|undefined =\u003e {\n    const expect = value === 0 || value === 1;\n});\nconst expect0 = f2(0) === 0;\nconst expect1 = f2(1) === 1;\n```\n\n```typescript\nclass Class {\n    @before.decorator((\n        fn: Function, value: number\n    ): boolean|undefined =\u003e {\n        return false; // blocks method invocation!\n    })\n    public method(value: number): number {\n        return value;\n    }\n}\nconst expect0 = new Class().method(0) === undefined;\nconst expect1 = new Class().method(1) === undefined;\n```\n\n## Development\n\n### Clean\n\n```sh\nnpm run clean\n```\n\n### Build\n\n```sh\nnpm run build\n```\n\n#### without linting and cleaning:\n\n```sh\nnpm run -- build --no-lint --no-clean\n```\n\n#### with UMD bundling (incl. minimization):\n\n```sh\nnpm run -- build --prepack\n```\n\n#### with UMD bundling (excl. minimization):\n\n```sh\nnpm run -- build --prepack --no-minify\n```\n\n### Lint\n\n```sh\nnpm run lint\n```\n\n#### with auto-fixing:\n\n```sh\nnpm run -- lint --fix\n```\n\n### Test\n\n```sh\nnpm run test\n```\n\n#### without linting, cleaning and (re-)building:\n\n```sh\nnpm run -- test --no-lint --no-clean --no-build\n```\n\n### Cover\n\n```sh\nnpm run cover\n```\n\n#### without linting, cleaning and (re-)building:\n\n```sh\nnpm run -- cover --no-lint --no-clean --no-build\n```\n\n## Documentation\n\n```sh\nnpm run docs\n```\n\n## Publish\n\n```sh\nnpm publish\n```\n\n#### initially (if public):\n\n```sh\nnpm publish --access=public\n```\n\n## Copyright\n\n © 2020 [dizmo AG](http://dizmo.com/), Switzerland\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizmo%2Ffunctions-before","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdizmo%2Ffunctions-before","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdizmo%2Ffunctions-before/lists"}