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

Function internalMatch

lib/assert.js:822–852  ·  view source on GitHub ↗
(string, regexp, message, fn)

Source from the content-addressed store, hash-verified

820};
821
822function internalMatch(string, regexp, message, fn) {
823 if (!isRegExp(regexp)) {
824 throw new ERR_INVALID_ARG_TYPE(
825 'regexp', 'RegExp', regexp,
826 );
827 }
828 const match = fn === Assert.prototype.match;
829 if (typeof string !== 'string' ||
830 RegExpPrototypeExec(regexp, string) !== null !== match) {
831
832 const generatedMessage = message.length === 0;
833
834 // 'The input was expected to not match the regular expression ' +
835 message[0] ||= (typeof string !== 'string' ?
836 'The "string" argument must be of type string. Received type ' +
837 `${typeof string} (${inspect(string)})` :
838 (match ?
839 'The input did not match the regular expression ' :
840 'The input was expected to not match the regular expression ') +
841 `${inspect(regexp)}. Input:\n\n${inspect(string)}\n`);
842 innerFail({
843 actual: string,
844 expected: regexp,
845 message,
846 operator: fn.name,
847 stackStartFn: fn,
848 diff: this?.[kOptions]?.diff,
849 generatedMessage: generatedMessage,
850 });
851 }
852}
853
854/**
855 * Expects the `string` input to match the regular expression.

Callers 1

assert.jsFile · 0.85

Calls 2

innerFailFunction · 0.85
inspectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…