https://github.com/estrattonbailey/tarry.js
Tiny composable sequencing utility. 250 bytes gzipped.
https://github.com/estrattonbailey/tarry.js
queue sequencer
Last synced: about 2 months ago
JSON representation
Tiny composable sequencing utility. 250 bytes gzipped.
- Host: GitHub
- URL: https://github.com/estrattonbailey/tarry.js
- Owner: estrattonbailey
- Created: 2016-09-13T02:11:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-21T16:12:29.000Z (over 7 years ago)
- Last Synced: 2025-04-02T20:39:06.660Z (2 months ago)
- Topics: queue, sequencer
- Language: JavaScript
- Homepage:
- Size: 87.9 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tarry.js
Tiny composable sequencing utility. **250 bytes gzipped.**## Usage
```javascript
import { tarry, queue } from 'tarry.js'
```### `tarry`
Pass a function to convert it to a *delay-able* function.```javascript
const myFunc = () => console.log('Hello world')const myDelayedFunc = tarry(myFunc, 200)
myDelayedFunc() // fires myFunc after 200ms
myDelayedFunc(500) // fires myFunc after 500ms
myDelayedFunc(1000) // fires myFunc after 1000ms
```### `queue`
Pass a series of `tarry` functions to create a call-able sequence.
```javascript
const a = tarry(() => {}, 200)
const b = tarry(() => {})
const c = tarry(() => {}, 1000)const someBoolean = false
const sequence = queue(a, b(someBoolean ? 200 : 1000), c(500))
sequence() // calls `a` in 200ms, `b` in 1000ms, and `c` in 500ms
```# API
### tarry(function[, delay])
Returns a delayed function. If no delay is given, the function will be called
immediately.The returned function can then accept a delay as its only parameter. This will
override the `delay` passed in the original definition (if any).### queue(function[, ...functions])
Accepts a series of functions returned from `tarry` calls. Returns a function.
When called, executes all functions in the queue, according to their order and
`delay` values.# What is this for?
I use it fairly often for animations and step-sequenced flows. Handy, but certainly
not necessary.## License
MIT License © [Eric Bailey](https://estrattonbailey.com)