Skip to content

Latest commit

 

History

History
338 lines (230 loc) · 8.2 KB

API.md

File metadata and controls

338 lines (230 loc) · 8.2 KB

Classes

ForkPromiseProxy
ListHandler
Loop
Thread

Members

IfForkPromiseProxy

Async conditions

Functions

List(list)ListHandler

takes a list and returns a List handler instance

async(fn)function

Takes a function and returns an async version of it

threaded(fn)Promise

takes a function, spawns a webworker and executes that function inside the webworker

ForkPromiseProxy

Kind: global class

new ForkPromiseProxy()

Proxy class for handling promises

forkPromiseProxy.resolve(type) ⇒ ?

When the promise resolves it should call this method to handle the if else statements

Kind: instance method of ForkPromiseProxy

Param Type Description
type String 'then' or 'else' types

forkPromiseProxy.then(handle) ⇒ ForkPromiseProxy

sets the handle function for a true conditions

Kind: instance method of ForkPromiseProxy

Param Type
handle function

forkPromiseProxy.else(handle) ⇒ ForkPromiseProxy

sets the handle function for a false condition

Kind: instance method of ForkPromiseProxy

Param Type
handle function

ListHandler

Kind: global class

new ListHandler(list)

Async array usage

Param Type
list Array

listHandler.filter(condition) ⇒ Promise

Filter an array and return a new array with the filtered values

Kind: instance method of ListHandler

Param Type
condition function

listHandler.each(handle) ⇒ Promise

Iterate thru a list

Kind: instance method of ListHandler

Param Type
handle function

listHandler.map(handle) ⇒ Promise

Itarate thru the list and create a new array with augmentet values

Kind: instance method of ListHandler

Param Type
handle function

listHandler.find(condition) ⇒ Promise

Find a specific elemnet inside a list

Kind: instance method of ListHandler

Param Type
condition function

Loop

Kind: global class

new Loop(handle, iterations)

Async loop class that takes a handle as a parameter and a maximum number of iterations

Param Type
handle function
iterations Number

loop.start()

Starts the loop

Kind: instance method of Loop

loop.done()

stops the loop normally

Kind: instance method of Loop

loop.terminate(type, message)

Interupt the loop with a type and message. This will call the reject callback on the promise.

Kind: instance method of Loop

Param Type
type String
message String

loop.cancel(message)

Cancel the loop and provide a reason message

Kind: instance method of Loop

Param Type
message String

loop.kill(message)

Kill the loop and provide a reason message

Kind: instance method of Loop

Param Type
message String

Loop.until(handle, iterations) ⇒ Promise

Loop until the handle function returns true

Kind: static method of Loop

Param Type
handle function
iterations Number

Loop.unique(id) ⇒ Object

Creates a unique loop task that will terminate when another task with the same id starts

Kind: static method of Loop

Param Type
id String

Thread

Kind: global class

new Thread(handle)

Helper class that will run a function in a separate thread by using webworkers

Param Type
handle function

thread.exec(params) ⇒ Promise

Execute the function

Kind: instance method of Thread

Param Type Description
params Array function arguments

thread.start()

Start the thread. Creates a new webworker

Kind: instance method of Thread

thread.terminate()

terminates the thread and worker

Kind: instance method of Thread

Async conditions

Kind: global variable

Param Type
condition function

List(list) ⇒ ListHandler

takes a list and returns a List handler instance

Kind: global function

Param Type
list Array

async(fn) ⇒ function

Takes a function and returns an async version of it

Kind: global function

Param Type
fn function

threaded(fn) ⇒ Promise

takes a function, spawns a webworker and executes that function inside the webworker

Kind: global function

Param Type
fn function