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

Function invalidArgTypeHelper

test/common/index.js:836–854  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

834
835// A helper function to simplify checking for ERR_INVALID_ARG_TYPE output.
836function invalidArgTypeHelper(input) {
837 if (input == null) {
838 return ` Received ${input}`;
839 }
840 if (typeof input === 'function') {
841 return ` Received function ${input.name}`;
842 }
843 if (typeof input === 'object') {
844 if (input.constructor?.name) {
845 return ` Received an instance of ${input.constructor.name}`;
846 }
847 return ` Received ${inspect(input, { depth: -1 })}`;
848 }
849
850 let inspected = inspect(input, { colors: false });
851 if (inspected.length > 28) { inspected = `${inspected.slice(inspected, 0, 25)}...`; }
852
853 return ` Received type ${typeof input} (${inspected})`;
854}
855
856function requireNoPackageJSONAbove(dir = __dirname) {
857 let possiblePackage = path.join(dir, '..', 'package.json');

Callers 1

test-assert.jsFile · 0.85

Calls 2

sliceMethod · 0.65
inspectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…