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;
} else if (typeof signParams === 'object') {
checkSignArgs(this, signParams);
vin = signParams.vin;
keyPair = signParams.keyPair;
redeemScript = signParams.redeemScript;
hashType = signParams.hashType;
witnessValue = signParams.witnessValue;
witnessScript = signParams.witnessScript;
({
vin,
keyPair,
redeemScript,
hashType,
witnessValue,
witnessScript,
} = signParams);
} else {
throw new TypeError(
'TransactionBuilder sign first arg must be TxbSignArg or number',

View file

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