utils

Various utility functions used throughout Mocha's codebase.

Source:

Members

(inner) debug

Source:

Module dependencies.

(inner) ignore

Source:

Ignored directories.

Methods

(static) clamp(value, range) → {number}

Source:

Clamps a numeric value to an inclusive range.

Parameters:
Name Type Description
value number

Value to be clamped.

range Array:.<numer:>

Two element array specifying [min, max] range.

Returns:

clamped value

Type
number

(static) clean(str) → {string}

Source:

Strip the function definition from str, and re-indent for pre whitespace.

Parameters:
Name Type Description
str string
Returns:
Type
string

(static) createMap(…objopt) → {Object}

Creates a map-like object.

Source:
See:

A "map" is an object with no prototype, for our purposes. In some cases this would be more appropriate than a Map, especially if your environment doesn't support it. Recommended for use in Mocha's public APIs.

Parameters:
Name Type Attributes Description
obj * <optional>
<repeatable>

Arguments to Object.assign()

Returns:

An object with no prototype, having ...obj properties

Type
Object

(static) defineConstants() → {Object}

Create a read-only map-like object.
This differs from createMap only in that the argument must be non-empty, because the result is frozen.

Source:
See:
Returns:

A frozen object with no prototype, having ...obj properties

Type
Object

(static) isPromise(value) → {boolean}

Source:

Crude, but effective.

Parameters:
Name Type Description
value *
Returns:

Whether or not value is a Promise

Type
boolean

(static) noop()

Source:

It's a noop.

(static) stackTraceFilter() → {function}

This Filter based on mocha-clean module.(see: github.com/rstacruz/mocha-clean)

Source:

When invoking this function you get a filter function that get the Error.stack as an input,
and return a prettify output.
(i.e: strip Mocha and internal node functions from stack trace).

Returns:
Type
function