Browse Source

errors: replace `.split()` with `.replace()`

Replace a somewhat idiosyncratic use of `split()` to remove a prefix
with `replace()`. (A case could be made for `slice()` as well but I
think this is more readable.)

PR-URL: https://github.com/nodejs/node/pull/15545
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
canary-base
Rich Trott 8 years ago
committed by Ruben Bridgewater
parent
commit
55d49eb3cc
No known key found for this signature in database GPG Key ID: F07496B3EB3C1762
  1. 2
      lib/internal/errors.js

2
lib/internal/errors.js

@ -311,7 +311,7 @@ function invalidArgType(name, expected, actual) {
let determiner; let determiner;
if (typeof expected === 'string' && expected.startsWith('not ')) { if (typeof expected === 'string' && expected.startsWith('not ')) {
determiner = 'must not be'; determiner = 'must not be';
expected = expected.split('not ')[1]; expected = expected.replace(/^not /, '');
} else { } else {
determiner = 'must be'; determiner = 'must be';
} }

Loading…
Cancel
Save