TIL: destructuring objects without let or const is a thing

This commit is contained in:
junderw 2019-06-13 17:08:43 +09:00
parent 2e4c9f6b7a
commit 7c454e5f44
No known key found for this signature in database
GPG key ID: B256185D3A971908
2 changed files with 16 additions and 12 deletions

View file

@ -162,12 +162,14 @@ class TransactionBuilder {
vin = signParams; vin = signParams;
} else if (typeof signParams === 'object') { } else if (typeof signParams === 'object') {
checkSignArgs(this, signParams); checkSignArgs(this, signParams);
vin = signParams.vin; ({
keyPair = signParams.keyPair; vin,
redeemScript = signParams.redeemScript; keyPair,
hashType = signParams.hashType; redeemScript,
witnessValue = signParams.witnessValue; hashType,
witnessScript = signParams.witnessScript; witnessValue,
witnessScript,
} = signParams);
} else { } else {
throw new TypeError( throw new TypeError(
'TransactionBuilder sign first arg must be TxbSignArg or number', 'TransactionBuilder sign first arg must be TxbSignArg or number',

View file

@ -252,12 +252,14 @@ export class TransactionBuilder {
vin = signParams; vin = signParams;
} else if (typeof signParams === 'object') { } else if (typeof signParams === 'object') {
checkSignArgs(this, signParams); checkSignArgs(this, signParams);
vin = signParams.vin; ({
keyPair = signParams.keyPair; vin,
redeemScript = signParams.redeemScript; keyPair,
hashType = signParams.hashType; redeemScript,
witnessValue = signParams.witnessValue; hashType,
witnessScript = signParams.witnessScript; witnessValue,
witnessScript,
} = signParams);
} else { } else {
throw new TypeError( throw new TypeError(
'TransactionBuilder sign first arg must be TxbSignArg or number', 'TransactionBuilder sign first arg must be TxbSignArg or number',