Skip to content

Commit 43893b6

Browse files
fix: replace deprecated String.prototype.substr() (npm#59)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <[email protected]>
1 parent 109af89 commit 43893b6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/env-replace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module.exports = (f, env) => f.replace(envExpr, (orig, esc, name) => {
77

88
// consume the escape chars that are relevant.
99
if (esc.length % 2) {
10-
return orig.substr((esc.length + 1) / 2)
10+
return orig.slice((esc.length + 1) / 2)
1111
}
1212

13-
return (esc.substr(esc.length / 2)) + val
13+
return (esc.slice(esc.length / 2)) + val
1414
})

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class Config {
366366
if (!/^npm_config_/i.test(envKey) || envVal === '') {
367367
continue
368368
}
369-
const key = envKey.substr('npm_config_'.length)
369+
const key = envKey.slice('npm_config_'.length)
370370
.replace(/(?!^)_/g, '-') // don't replace _ at the start of the key
371371
.toLowerCase()
372372
conf[key] = envVal

lib/parse-field.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const parseField = (f, key, opts, listElement = false) => {
5656
if (isPath) {
5757
const homePattern = platform === 'win32' ? /^~(\/|\\)/ : /^~\//
5858
if (homePattern.test(f) && home) {
59-
f = resolve(home, f.substr(2))
59+
f = resolve(home, f.slice(2))
6060
} else {
6161
f = resolve(f)
6262
}

0 commit comments

Comments
 (0)