0.3.1 • Published 6 years ago

tarry.js v0.3.1

Weekly downloads
59
License
MIT
Repository
github
Last release
6 years ago

tarry.js

Tiny composable sequencing utility. 250 bytes gzipped.

Usage

import { tarry, queue } from 'tarry.js'

tarry

Pass a function to convert it to a delay-able function.

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.

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

0.3.1

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

1.0.0

8 years ago

0.0.1

8 years ago