chore(): add successIndex at the correct position if we have optional params
This commit is contained in:
parent
d79d62bfa0
commit
6b286db51a
@ -61,7 +61,12 @@ function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Func
|
|||||||
args.push(obj);
|
args.push(obj);
|
||||||
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
|
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
|
||||||
// If we've specified a success/error index
|
// If we've specified a success/error index
|
||||||
args.splice(opts.successIndex, 0, resolve);
|
|
||||||
|
if (opts.successIndex > args.length) {
|
||||||
|
args[opts.successIndex] = resolve;
|
||||||
|
} else {
|
||||||
|
args.splice(opts.successIndex, 0, resolve);
|
||||||
|
}
|
||||||
|
|
||||||
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behaviour.
|
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behaviour.
|
||||||
if (opts.errorIndex > args.length) {
|
if (opts.errorIndex > args.length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user