Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nju33/soshoku
Request re-execution during processing Even when you come back and forth, you only re-execute once
https://github.com/nju33/soshoku
promise
Last synced: about 2 months ago
JSON representation
Request re-execution during processing Even when you come back and forth, you only re-execute once
- Host: GitHub
- URL: https://github.com/nju33/soshoku
- Owner: nju33
- License: mit
- Created: 2017-04-04T21:40:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-05T23:49:00.000Z (almost 8 years ago)
- Last Synced: 2024-04-14T12:49:43.670Z (9 months ago)
- Topics: promise
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/soshoku
- Size: 161 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Soshoku
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
Request re-execution during processing Even when you come back and forth, you only re-execute once.
## Install or Download
```sh
yarn add soshoku
npm i -S soshoku
```Or access to [releases page](https://github.com/nju33/soshoku/releases).
Then, download the latest version.## Usage
```js
import soshoku from 'soshoku';
const soshoku = require('soshoku');
```or
```html
```
### API
#### `constructor(func)`
- `func`: `Promise`
Register function.
#### `exec()`
Execute function.
### Example
```js
import Soshoku from 'soshoku';const doSomethingAsync = () => {
return new Promise(resolve => {
setTimeout(() => {
console.log('called!');
resolve();
}, 5000)
});
}new soshoku = new Soshoku(doSomethingAsync);
soshoku.exec();
setTimeout(soshoku.exec, 1000);
setTimeout(soshoku.exec, 2000);// The result comes out as 'called!' After 5s.
// And after 5s we also get 'called!'.
// But after 5s there is nothing.
```## LICENSE
The MIT License (MIT)
Copyright (c) 2017 nju33