Skip to content

Commit

Permalink
code: simplify key-value extraction
Browse files Browse the repository at this point in the history
Credit: @elidoran
Reviewed-By: @othiym23
PR-URL: #73
  • Loading branch information
elidoran authored and othiym23 committed Dec 13, 2016
1 parent 5271229 commit 07c69d3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/nopt.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ function parse (args, data, remain, types, shorthands) {
}
var hadEq = false
if (arg.charAt(0) === "-" && arg.length > 1) {
if (arg.indexOf("=") !== -1) {
var at = arg.indexOf('=')
if (at > -1) {
hadEq = true
var v = arg.split("=")
arg = v.shift()
v = v.join("=")
args.splice.apply(args, [i, 1].concat([arg, v]))
var v = arg.substr(at + 1)
arg = arg.substr(0, at)
args.splice(i, 1, arg, v)
}

// see if it's a shorthand
Expand Down

0 comments on commit 07c69d3

Please sign in to comment.