Skip to content

Commit

Permalink
fix: replace deprecated String.prototype.substr() (#85)
Browse files Browse the repository at this point in the history
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
  • Loading branch information
CommanderRoot committed Jul 20, 2022
1 parent c86f824 commit 40c686f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/nopt.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function validatePath (data, k, val) {
, home = os.homedir()

if (home && val.match(homePattern)) {
data[k] = path.resolve(home, val.substr(2))
data[k] = path.resolve(home, val.slice(2))
} else {
data[k] = path.resolve(val)
}
Expand Down Expand Up @@ -262,8 +262,8 @@ function parse (args, data, remain, types, shorthands) {
var at = arg.indexOf('=')
if (at > -1) {
hadEq = true
var v = arg.substr(at + 1)
arg = arg.substr(0, at)
var v = arg.slice(at + 1)
arg = arg.slice(0, at)
args.splice(i, 1, arg, v)
}

Expand All @@ -283,7 +283,7 @@ function parse (args, data, remain, types, shorthands) {
var no = null
while (arg.toLowerCase().indexOf("no-") === 0) {
no = !no
arg = arg.substr(3)
arg = arg.slice(3)
}

if (abbrevs[arg]) arg = abbrevs[arg]
Expand Down

0 comments on commit 40c686f

Please sign in to comment.