1.2.35 • Published 8 months ago

syncfunction v1.2.35

Weekly downloads
46
License
MIT
Repository
github
Last release
8 months ago

SyncFunction

A mutex for synchronization using promises

Usage as in sequence lock

const {SyncFunction} = require('syncfunction') // or SyncQueue

const sync = SyncFunction()
sync(async()=>{
    await [...] // only one at a time
})
await sync(async()=>{
    await [...] // only one at a time
})

Usage as throat

A throat is an asyncronous function that executes work in the background without awaiting on the result. A throat guaruntees no more than n functions will be executed at a time.

const sync = ThroatFunction(2)
await sync(async()=>{
    await [...] // only 2 at a time
})
await sync(async()=>{
    await [...] // only 2 at a time
})
await sync(async()=>{
    await [...] // only 2 at a time
})

// wait until done
await sync(null)

Usage in a throat queue

A throat is an asyncronous function that executes work in the background with each function call returning an awaitable promise for the underlying call. A throat guaruntees no more than n functions will be executed at a time.

SyncLite usage

A lightweight version of SyncFunction (thats just an array at it's core) for when you need a large number of syncfunctions with minimal cost. Best restricted in use to when it will be able to immediately execute.

1.2.30

8 months ago

1.2.31

8 months ago

1.2.34

8 months ago

1.2.35

8 months ago

1.2.32

8 months ago

1.2.27

1 year ago

1.2.28

1 year ago

1.2.29

1 year ago

1.2.18

1 year ago

1.2.19

1 year ago

1.2.20

1 year ago

1.2.23

1 year ago

1.2.24

1 year ago

1.2.21

1 year ago

1.2.22

1 year ago

1.2.25

1 year ago

1.2.26

1 year ago

1.2.17

1 year ago

1.2.15

2 years ago

1.2.12

2 years ago

1.2.14

2 years ago

1.2.11

2 years ago

1.2.9

2 years ago

1.2.10

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.17

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago