From 40c686faffc600ed6f53c5ef1c3c6e1eaeda7c77 Mon Sep 17 00:00:00 2001 From: CommanderRoot Date: Wed, 20 Jul 2022 21:53:41 +0200 Subject: [PATCH] fix: replace deprecated String.prototype.substr() (#85) .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- lib/nopt.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nopt.js b/lib/nopt.js index ecfa5da..8abac92 100644 --- a/lib/nopt.js +++ b/lib/nopt.js @@ -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) } @@ -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) } @@ -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]