MCPcopy Index your code
hub / github.com/nodejs/node / Assert

Function Assert

lib/assert.js:105–132  ·  view source on GitHub ↗

* @class Assert * @param {AssertOptions} [options] - Optional configuration for assertions. * @throws {ERR_CONSTRUCT_CALL_REQUIRED} If not called with `new`.

(options)

Source from the content-addressed store, hash-verified

103 * @throws {ERR_CONSTRUCT_CALL_REQUIRED} If not called with `new`.
104 */
105function Assert(options) {
106 if (!new.target) {
107 throw new ERR_CONSTRUCT_CALL_REQUIRED('Assert');
108 }
109
110 options = ObjectAssign({ __proto__: null, strict: true, skipPrototype: false }, options);
111
112 const allowedDiffs = ['simple', 'full'];
113 if (options.diff !== undefined) {
114 validateOneOf(options.diff, 'options.diff', allowedDiffs);
115 }
116
117 this.AssertionError = AssertionError;
118 ObjectDefineProperty(this, kOptions, {
119 __proto__: null,
120 value: options,
121 enumerable: false,
122 configurable: false,
123 writable: false,
124 });
125
126 if (options.strict) {
127 this.equal = this.strictEqual;
128 this.deepEqual = this.deepStrictEqual;
129 this.notEqual = this.notStrictEqual;
130 this.notDeepEqual = this.notDeepStrictEqual;
131 }
132}
133
134// All of the following functions must throw an AssertionError
135// when a corresponding condition is not met, with a message that

Callers 1

Calls 1

ObjectAssignFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…