Skip to content

Commit 057a1fb

Browse files
authored
Merge pull request #15 from bitcoinjs/refactor
refactor: forbid unnecessary callback wrapper for consistent code style
2 parents 893971c + 2246a2c commit 057a1fb

File tree

7 files changed

+13
-24
lines changed

7 files changed

+13
-24
lines changed

src/lib/combiner/index.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ function combine(psbts) {
1111
throw new Error('Combine: Self missing transaction');
1212
}
1313
const selfGlobalSet = getKeySet(selfKeyVals.globalKeyVals);
14-
const selfInputSets = selfKeyVals.inputKeyVals.map(input => getKeySet(input));
15-
const selfOutputSets = selfKeyVals.outputKeyVals.map(output =>
16-
getKeySet(output),
17-
);
14+
const selfInputSets = selfKeyVals.inputKeyVals.map(getKeySet);
15+
const selfOutputSets = selfKeyVals.outputKeyVals.map(getKeySet);
1816
for (const other of others) {
1917
const otherTx = getTx(other);
2018
if (
@@ -34,9 +32,7 @@ function combine(psbts) {
3432
otherKeyVals.globalKeyVals,
3533
),
3634
);
37-
const otherInputSets = otherKeyVals.inputKeyVals.map(input =>
38-
getKeySet(input),
39-
);
35+
const otherInputSets = otherKeyVals.inputKeyVals.map(getKeySet);
4036
otherInputSets.forEach((inputSet, idx) =>
4137
inputSet.forEach(
4238
keyPusher(
@@ -46,9 +42,7 @@ function combine(psbts) {
4642
),
4743
),
4844
);
49-
const otherOutputSets = otherKeyVals.outputKeyVals.map(output =>
50-
getKeySet(output),
51-
);
45+
const otherOutputSets = otherKeyVals.outputKeyVals.map(getKeySet);
5246
otherOutputSets.forEach((outputSet, idx) =>
5347
outputSet.forEach(
5448
keyPusher(

src/lib/converter/tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function reverseBuffer(buffer) {
1616
}
1717
exports.reverseBuffer = reverseBuffer;
1818
function keyValsToBuffer(keyVals) {
19-
const buffers = keyVals.map(keyVal => keyValToBuffer(keyVal));
19+
const buffers = keyVals.map(keyValToBuffer);
2020
buffers.push(Buffer.from([0]));
2121
return Buffer.concat(buffers);
2222
}

src/lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function updateMaker(typeName) {
8383
) {
8484
throw new Error(`Key type ${name} must be an array`);
8585
}
86-
if (!data.every(v => check(v))) {
86+
if (!data.every(check)) {
8787
throwForUpdateMaker(typeName, name, expected, data);
8888
}
8989
// @ts-ignore

ts_src/lib/combiner/index.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ export function combine(psbts: PsbtAttributes[]): PsbtAttributes {
1212
throw new Error('Combine: Self missing transaction');
1313
}
1414
const selfGlobalSet = getKeySet(selfKeyVals.globalKeyVals);
15-
const selfInputSets = selfKeyVals.inputKeyVals.map(input => getKeySet(input));
16-
const selfOutputSets = selfKeyVals.outputKeyVals.map(output =>
17-
getKeySet(output),
18-
);
15+
const selfInputSets = selfKeyVals.inputKeyVals.map(getKeySet);
16+
const selfOutputSets = selfKeyVals.outputKeyVals.map(getKeySet);
1917

2018
for (const other of others) {
2119
const otherTx = getTx(other);
@@ -38,9 +36,7 @@ export function combine(psbts: PsbtAttributes[]): PsbtAttributes {
3836
),
3937
);
4038

41-
const otherInputSets = otherKeyVals.inputKeyVals.map(input =>
42-
getKeySet(input),
43-
);
39+
const otherInputSets = otherKeyVals.inputKeyVals.map(getKeySet);
4440
otherInputSets.forEach((inputSet, idx) =>
4541
inputSet.forEach(
4642
keyPusher(
@@ -51,9 +47,7 @@ export function combine(psbts: PsbtAttributes[]): PsbtAttributes {
5147
),
5248
);
5349

54-
const otherOutputSets = otherKeyVals.outputKeyVals.map(output =>
55-
getKeySet(output),
56-
);
50+
const otherOutputSets = otherKeyVals.outputKeyVals.map(getKeySet);
5751
otherOutputSets.forEach((outputSet, idx) =>
5852
outputSet.forEach(
5953
keyPusher(

ts_src/lib/converter/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function reverseBuffer(buffer: Buffer): Buffer {
1717
}
1818

1919
export function keyValsToBuffer(keyVals: KeyValue[]): Buffer {
20-
const buffers = keyVals.map(keyVal => keyValToBuffer(keyVal));
20+
const buffers = keyVals.map(keyValToBuffer);
2121
buffers.push(Buffer.from([0]));
2222
return Buffer.concat(buffers);
2323
}

ts_src/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function updateMaker<T, Y>(
112112
) {
113113
throw new Error(`Key type ${name} must be an array`);
114114
}
115-
if (!data.every(v => check(v))) {
115+
if (!data.every(check)) {
116116
throwForUpdateMaker(typeName, name, expected, data);
117117
}
118118
// @ts-ignore

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"no-implicit-dependencies": [true, "dev"],
2020
"no-return-await": true,
2121
"no-var-requires": false,
22+
"no-unnecessary-callback-wrapper": true,
2223
"no-unused-expression": false,
2324
"object-literal-sort-keys": false,
2425
"quotemark": [true, "single", "avoid-escape"],

0 commit comments

Comments
 (0)