aceink / Exports
Ƭ ErrorValue<T
, E
>: [E
, undefined
] | [null
, T
]
Name |
---|
T |
E |
Ƭ Func<Result
, Args
>: (...args
: Args
) => Result
Name | Type |
---|---|
Result |
ExplicitAny |
Args |
extends ExplicitAny [] = ExplicitAny [] |
▸ (...args
): Result
Anonymous Function definition
Name | Type |
---|---|
...args |
Args |
Result
▸ createDeferred<T
>(value?
): Deferred
<T
>
Create a new Deferred instance
Name |
---|
T |
Name | Type |
---|---|
value? |
T |
Deferred
<T
>
▸ createLock<RefType
>(count?
, bound?
): Semaphore
<RefType
>
Basic counting semaphore/lock factory
Name | Type |
---|---|
RefType |
number |
Name | Type | Default value |
---|---|---|
count? |
number |
undefined |
bound |
boolean |
true |
Semaphore
<RefType
>
▸ delay<T
>(ms?
, arg?
): Promise
<T
>
delay a certain number of milliseconds returning a promise that resolves an argument
Name | Type |
---|---|
T |
undefined |
Name | Type |
---|---|
ms? |
number |
arg? |
T |
Promise
<T
>
▸ each<T
, K
>(this
, list
, iterator
, «destructured»?
): Promise
<void
>
Iterate a list with optional concurrency
Name | Type |
---|---|
T |
T |
K |
any |
Name | Type |
---|---|
this |
void | K |
list |
Iterable <T > |
iterator |
IteratorFunc <T , any > |
«destructured» |
Object |
› concurrency? |
number |
› context? |
void | K |
› onError? |
"settle" | "bail" |
Promise
<void
>
▸ gowait<T
, E
>(promised
): Promise
<ErrorValue
<T
, E
>>
Kind of like nodes ErrBacks, but with the ease (and overhead) of promises. It will only reject promises for native errors. Syncronous errors are caught.
Example
const [err, value] = await gowait(doWorkThatMightErrorAsync())
if (err) {
panic(err)
} else {
success(value)
}
Name | Type |
---|---|
T |
T |
E |
Error |
Name | Type |
---|---|
promised |
Promise <T > | Func <Promise <T >> |
Promise
<ErrorValue
<T
, E
>>
▸ identity<T
>(x
): T
Basic identity function
Name |
---|
T |
Name | Type |
---|---|
x |
T |
T
▸ map<T
, R
, K
>(this
, list
, iterator
, «destructured»?
): Promise
<R
[]>
Map over a list with optional concurrency
Name | Type |
---|---|
T |
T |
R |
R |
K |
any |
Name | Type |
---|---|
this |
K |
list |
Iterable <T > |
iterator |
IteratorFunc <T , R > |
«destructured» |
Object |
› concurrency? |
number |
› context? |
K |
Promise
<R
[]>
▸ noop(): void
Basic noop function
void
▸ once<T
>(fn
, after?
): T
Execute fn one time and [after=noop] for every subsequent invocation
Name | Type |
---|---|
T |
extends Func <any , any []> |
Name | Type | Default value |
---|---|---|
fn |
T |
undefined |
after |
Func <any , any []> |
noop |
T
▸ q(size
, bound?
): Queue
Create Queue with a specified size
Name | Type | Default value |
---|---|---|
size |
number |
undefined |
bound |
boolean |
true |