Adjust base library usage of for vs reduce/map (#1151)

* Adjust base library usage of `for` vs `reduce/map`

* Additional

* Adjust
This commit is contained in:
Jaco
2021-10-31 08:27:14 +02:00
committed by GitHub
parent 7ef169585f
commit a4cefa4bfc
20 changed files with 130 additions and 87 deletions
+3 -3
View File
@@ -23,9 +23,9 @@ export function keyExtractPath (derivePath: string): ExtractResult {
if (parts) {
constructed = parts.join('');
parts.forEach((value: string): void => {
path.push(DeriveJunction.from(value.substr(1)));
});
for (const p of parts) {
path.push(DeriveJunction.from(p.substr(1)));
}
}
assert(constructed === derivePath, () => `Re-constructed path "${constructed}" does not match input`);
+6 -3
View File
@@ -18,8 +18,11 @@ const generators = {
export function keyFromPath (pair: Keypair, path: DeriveJunction[], type: KeypairType): Keypair {
const keyHdkd = generators[type];
let result = pair;
return path.reduce((pair, junction): Keypair => {
return keyHdkd(pair, junction);
}, pair);
for (const junction of path) {
result = keyHdkd(result, junction);
}
return result;
}