Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dizmo/functions-after
dizmoFun: after handler
https://github.com/dizmo/functions-after
after dizmo function handler javascript library typescript
Last synced: about 15 hours ago
JSON representation
dizmoFun: after handler
- Host: GitHub
- URL: https://github.com/dizmo/functions-after
- Owner: dizmo
- License: isc
- Created: 2018-08-21T14:54:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T13:43:25.000Z (about 1 year ago)
- Last Synced: 2024-11-03T14:04:14.855Z (12 days ago)
- Topics: after, dizmo, function, handler, javascript, library, typescript
- Language: JavaScript
- Size: 916 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM version](https://badge.fury.io/js/%40dizmo%2Ffunctions-after.svg)](https://npmjs.org/package/@dizmo/functions-after)
[![Build Status](https://travis-ci.com/dizmo/functions-after.svg?branch=master)](https://travis-ci.com/dizmo/functions-after)
[![Coverage Status](https://coveralls.io/repos/github/dizmo/functions-after/badge.svg?branch=master)](https://coveralls.io/github/dizmo/functions-after?branch=master)# @dizmo/functions-after
Returns a function decorating an original function with a callback, which will be invoked after the execution of the original function. The return value of the original function will be handed over to the *after* callback as an argument, while the return value of the callback will become the overall result.
## Usage
### Install
```sh
npm install @dizmo/functions-after --save
```### Require
```javascript
const { after } = require("@dizmo/functions-after");
```### Examples
```typescript
import { after } from "@dizmo/functions-after";
``````typescript
const f1 = (): number => {
return 1;
};
const f2 = after(f1, (n: number): number => {
return n + 1;
});
const expect = 2 === f2();
``````typescript
class Class {
@after.decorator((n: number): number => {
return n + 1;
})
public method(): number {
return 1;
}
}
const expect = 2 === new Class().method();
```## Development
### Clean
```sh
npm run clean
```### Build
```sh
npm run build
```#### without linting and cleaning:
```sh
npm run -- build --no-lint --no-clean
```#### with UMD bundling (incl. minimization):
```sh
npm run -- build --prepack
```#### with UMD bundling (excl. minimization):
```sh
npm run -- build --prepack --no-minify
```### Lint
```sh
npm run lint
```#### with auto-fixing:
```sh
npm run -- lint --fix
```### Test
```sh
npm run test
```#### without linting, cleaning and (re-)building:
```sh
npm run -- test --no-lint --no-clean --no-build
```### Cover
```sh
npm run cover
```#### without linting, cleaning and (re-)building:
```sh
npm run -- cover --no-lint --no-clean --no-build
```## Documentation
```sh
npm run docs
```## Publish
```sh
npm publish
```#### initially (if public):
```sh
npm publish --access=public
```## Copyright
© 2020 [dizmo AG](http://dizmo.com/), Switzerland