npm.io
1.0.2 • Published 2 years ago

@fordi-org/assert

Licence
ISC
Version
1.0.2
Deps
0
Size
5 kB
Vulns
0
Weekly
0

@fordi-org/assert

A wrapper around node:assert where I keep custom assertions.

sameType

Assert that two items are the same type.

assert.sameType(actual, expected, message)

sameLength

Assert that two objects have the same length.

assert.sameLength(actual, expected, message);

closeTo

Assert that two numbers are close to one another within some tolerance.

assert.closeTo(actual, expected, epsilon, message);

The default tolerance is an epsilon of 1e-15; you can change the default by setting assert.closeTo.defaultEpsilon.

deeply

Create an assertion that applies recursively to objects / arrays.

const deepCustomAssertion = deeply(customAssertion);

deepCloseTo

assert.deepCloseTo(actual, expected, epsilon, message);

Same as assert.closeTo, but recursive.

Keywords