Members
Discard
When the maximum capacity is reached, new items added to the
queue will be silently discarded.
- Source:
(constant) EvictionPolicy
This enumeration holds supported eviction policies by some of collections.
- Source:
FIFO
The underlying collection evicts the items inserted first (like a queue).
- Source:
Ignore
Ignore the policy, and keep on enqueueing items, regardless of
whether the maximum capacity is reached or not.
- Source:
LFU
The underlying collection evicts the least frequently used elements first.
- Source:
LIFO
The underlying collection evicts the items inserted last (like a stack).
- Source:
LRU
The underlying collection evicts the least recently used elements first.
- Source:
MFU
The underlying collection evicts the most frequently used elements first.
- Source:
MRU
The underlying collection evicts the most recently used elements first.
- Source:
None
Do not evict. Requires manually freeing space in the underlying collection.
- Source:
Random
The underlying collection evicts the items inserted in a random order.
- Source:
ThrowError
When enqueueing new items and the maximum capacity is already
reached, an Error is thrown.
- Source:
Undetermined
The underlying collection may evict elements indeterministically.
- Source:
Methods
(async) assertThrowsAsync()
Parameters:
Type | Description |
---|---|
- 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
(async) refresh()
- Source:
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