Members
(constant) ConstrainedQueueCapacityPolicy :Number
Type:
- Number
Properties:
Name | Type | Description |
---|---|---|
Dequeue |
Number | Dequeue items to make space and accomodate new items. |
IgnoreEnqueue |
Number | Ignore attempts to enqueue more items once the full capacity is reached. New items are not enqueued and silently discarded. |
RejectEnqueue |
Number | Reject attempts to enqueue more items once the full capacity is reached. An error is thrown in this case. |
- Source:
(constant) EvictionPolicy :Number
This enumeration holds supported eviction policies by some of collections.
Type:
- Number
Properties:
Name | Type | Description |
---|---|---|
None |
Number | Do not evict. Requires manually freeing space in the underlying collection. |
Undetermined |
Number | The underlying collection may evict elements indeterministically. |
LRU |
Number | The underlying collection evicts the least recently used elements first. |
MRU |
Number | The underlying collection evicts the most recently used elements first. |
LFU |
Number | The underlying collection evicts the least frequently used elements first. |
MFU |
Number | The underlying collection evicts the most frequently used elements first. |
FIFO |
Number | The underlying collection evicts the items inserted first (like a queue). |
LIFO |
Number | The underlying collection evicts the items inserted last (like a stack). |
Random |
Number | The underlying collection evicts the items inserted in a random order. |
- Source:
(constant) JobQueueCapacityPolicy :Number
Type:
- Number
Properties:
Name | Type | Description |
---|---|---|
Ignore |
Number | Ignore the policy, and keep on enqueueing items, regardless of whether the maximum capacity is reached or not. |
Discard |
Number | When the maximum capacity is reached, new items added to the queue will be silently discarded. |
ThrowError |
Number | When enqueueing new items and the maximum capacity is already reached, an Error is thrown. |
- Source:
(constant) ProducerConsumerQueueCapacityPolicy :Number
Adds more policies for @see {ProducerConsumerQueue}, which is also of type
Type:
- Number
Properties:
Name | Type | Description |
---|---|---|
DeferEnqueue |
Number | The default for @see {ProducerConsumerQueue}. When such a queue reaches its maximum capacity, further enqueue calls will be deferred and handled according to a policy. |
- Source:
- See:
-
- {ConstrainedQueue}.
- {ConstrainedQueueCapacityPolicy}
Methods
(async) assertThrowsAsync(promiseFn)
Parameters:
Name | Type | Description |
---|---|---|
promiseFn |
producerHandler.<Promise.<any>> |
- Source:
deepCloneObject(obj)
Deep-clones an Object using JSON.parse() and JSON.stringify(). This means
that complex properties, such as functions, will not be copied. Use this
function therefore to copy objects that contain literal values or arrays
and nested objects of them.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The Object to deep-clone |
- Source:
defer() → {Deferred.<T>}
- Source:
Returns:
- Type
- Deferred.<T>
deferMocha()
Mocha does not support this use case (async function with done):
https://github.com/mochajs/mocha/issues/2407#issuecomment-237408877
This function creates a deferred that can be resolved/rejected using
a generic done-callback.
- Source:
Returns:
formatError(err) → {String}
Formats an Error like this if err is (all returned values are prefixed by 'Error: '):
- not an Error: return 'Error: formatValue(err)'
- an Error: [err.constructor.name] optionally followed by ': ' if the error has a
message or a stack; If it has a stack, the stack's print is prefixed by 'Stack: '
Parameters:
Name | Type | Description |
---|---|---|
err |
Error | any | An instance of Error or any other thrown value. |
- Source:
Returns:
- Type
- String
formatValue(val) → {String}
Formats any value to a useful string that reflects the given value's contents.
Formats like this if val is:
- undefined: ''
- null: ''
- typeof string: val (identity)
- val.toString() if val's prototype !== null || val's prototype.ctor !== Object
- inspect(val), otherwise
Parameters:
Name | Type | Description |
---|---|---|
val |
any |
- Source:
Returns:
- Type
- String
getRandomNumber() → {Number}
Uses crypto.randomBytes() to generate a 32 bit signed random number.
- Source:
Returns:
a 32-bit signed integer.
- Type
- Number
mergeObjects(…objects) → {Object}
Merges two or more objects and returns a new object. Recursively merges
nested objects. Iterates the objects in the order they were given. If a
key is present in the next object as well, it will overwrite the value
of the previous object. Atomic properties and arrays are replaced in
the resulting object. Passing two objects with the first being an empty
new object, you may use this function to clone objects as well. Object-
properties that are actually Class-instances will be copied (i.e. it
will point to the same instance in the merged object).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
objects |
Object |
<repeatable> |
Two or more Objects to merge. |
- Source:
Returns:
the result of the merge
- Type
- Object
throwError(error)
Throws an Error by conditionally wrapping the given error into an
actual instance of Error using wrapError().
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | any | The value that should be thrown. |
- Source:
Throws:
-
The given error as is (if instance of Error) or being wrapped into an Error.
- Type
- Error
timeout(ms) → {Promise.<void>}
A function that creates an awaitable timout.
Parameters:
Name | Type | Description |
---|---|---|
ms |
Number | Milliseconds to wait before resolving |
- Source:
Returns:
a Promise that is resolved after
the amount of milliseconds given.
- Type
- Promise.<void>
wrapError(error) → {Error}
Optionally wraps an arbitrary value that shall be thrown as an Error
into an instance of Error by applying formatError() and constructing
a new Error from it.
If the given error is an instance of Error, then it is returned as is.
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | any | The value that should be thrown and needs to be wrapped. |
- Source:
Returns:
Always returns an instance of Error.
- Type
- Error