0.6.0 • Published 6 months ago

vaco v0.6.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

wait

takes an async function and wait for it to finish to execute the next one, during the time any call to the function will be ignored and undefined is returned, the last call parameters will always be saved which will be used when the initial call fininshed to call another one

shield

takes a function and amount of time in millisecond to wait and then execute the function again

Staty

Staty is a state machine library that takes an object with boolean values as the first parameter and handlers as the second parameter. Handlers can have keys representing states or combinations of states separated by ",". You can place "!" at the beginning of a key to indicate that it must be false for the handler to apply.

Each handler function must return a function, even if it's empty, which will be called for cleanup purposes. The staty function returns another function that takes a new state (or a partial state) to change the previous state and checks the handlers. Handlers that satisfy the new state will be called, and previously applied handlers won't be called twice.

If a handler doesn't satisfy the new state, it will be deleted, and the returned function will be called for cleanup.

Here's an example:

const states = { foo: true, bar: true }
const retFn = jest.fn()
const handlers = {
  "foo, !bar": jest.fn(() => retFn),
  "!foo, !bar": jest.fn(),
}

const changeState = staty(states, handlers)
changeState({ bar: false })
changeState({ foo: false, bar: true })

expect(handlers["foo, !bar"]).toHaveBeenCalledTimes(1)
expect(retFn).toHaveBeenCalledTimes(1)
expect(handlers["!foo, !bar"]).toHaveBeenCalledTimes(0)
0.5.0

7 months ago

0.6.0

6 months ago

0.1.11

9 months ago

0.0.10

10 months ago

0.0.11

9 months ago

0.2.1

8 months ago

0.2.0

9 months ago

0.3.6

8 months ago

0.3.5

8 months ago

0.3.8

8 months ago

0.3.7

8 months ago

0.4.1

8 months ago

0.3.2

8 months ago

0.4.0

8 months ago

0.2.2

8 months ago

0.3.4

8 months ago

0.4.2

8 months ago

0.3.3

8 months ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago