0.0.4 • Published 9 years ago

synchronicity v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

synchronicity

For when a future callback just won't do.

Installation

npm install synchronicity

Documentation

This module is a wrapper for the deasync module, created in order to have a nicer API and functions. The API is based on the API of synchronize.js1

sync.create ( function f ):

  • A wrapper for deasync(f)
  • Returns a synchronous version of an asynchronous function.

sync.sleep ( int ms ):

  • A reference to deasync.sleep(ms)
  • Pauses execution of the current script until the requested milliseconds have passed.

sync.until ( function ):

  • Pauses execution until the predicate returns true.

sync.exe ( object, string function_name [, array args] ) or sync.exe ( null, function [, array args] ):

  • Runs the given function with the given args and returns an object you can use to track the progress of the execution.
  • If the array args is provided, it must contain the result of sync.defer as a value. If it does not, it will throw an error.
  • When args is not provided, it defaults to [sync.defer().all()]
  • Returns an object with the keys promise, result, and potentially leftovers (if .all() is run on the defer() result)

sync.wait ( object, string function_name [, array args] ) or sync.exe ( null, function [, array args]):

  • Uses the sync.exe function to wait for a function to complete, then returns the result.

sync.parallel ( list_of_arrays... ):

  • Takes any number of arrays which represent the arguments of each call to sync.wait. Returns the results in one array when complete.

sync.lazy ( function ):

  • Runs a function at some point. No promises. (Eventually there will be, just haven't gotten to it yet)

Notes

1Synchronize.js functions must be called inside a fiber, which is annoying and makes it less useful. (For instance, it'd be impossible to create a synchronous version of a function using it). Deasync does not require fibers, and this module makes it have that nice api.

0.0.4

9 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago