Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zcong1993/once
sync once helper
https://github.com/zcong1993/once
Last synced: 1 day ago
JSON representation
sync once helper
- Host: GitHub
- URL: https://github.com/zcong1993/once
- Owner: zcong1993
- License: mit
- Created: 2019-07-20T16:28:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T16:47:16.000Z (16 days ago)
- Last Synced: 2024-10-23T23:36:24.382Z (15 days ago)
- Language: TypeScript
- Size: 620 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# once
[![NPM version](https://img.shields.io/npm/v/@zcong/once.svg?style=flat)](https://npmjs.com/package/@zcong/once) [![NPM downloads](https://img.shields.io/npm/dm/@zcong/once.svg?style=flat)](https://npmjs.com/package/@zcong/once) [![CircleCI](https://circleci.com/gh/zcong1993/once/tree/master.svg?style=shield)](https://circleci.com/gh/zcong1993/once/tree/master) [![codecov](https://codecov.io/gh/zcong1993/once/branch/master/graph/badge.svg)](https://codecov.io/gh/zcong1993/once) [![typedoc](https://img.shields.io/badge/typedoc-active-brightgreen.svg)](https://zcong1993.github.io/once)
> sync once helper
## Install
```sh
$ yarn add @zcong/once
```## Example
```ts
import Once from '@zcong/once'class Test {}
// f only be called for the first time
const f = async () => new Test()
for (const _ of Array(10)) {
const test: Test = once.syncOnce('test', mockFn)
// test is Test instance which is f() returned.
}
```## License
MIT © zcong1993