Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Remove extra memo conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
g. nicholas d'andrea committed Oct 12, 2020
1 parent 95ed02e commit f891db1
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/abi-utils/lib/arbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,13 @@ const Type: fc.Memo<string> = fc.memo(n =>
fc.oneof(Primitive(), ArrayFixed(n > 3 ? 3 : n), ArrayDynamic(n))
);

const ArrayFixed = fc.memo(n => {
const tuple =
n <= 1
? fc.tuple(Primitive(), fc.integer(1, 256))
: fc.tuple(Type(), fc.integer(1, 256));

return tuple.map(([type, length]) => `${type}[${length}]`);
});

const ArrayDynamic = fc.memo(n => {
const item = n <= 1 ? Primitive() : Type();
const ArrayFixed = fc.memo(n =>
fc
.tuple(Type(n - 1), fc.integer(1, 256))
.map(([type, length]) => `${type}[${length}]`)
);

return item.map(type => `${type}[]`);
});
const ArrayDynamic = fc.memo(n => Type(n - 1).map(type => `${type}[]`));

const reservedWords = new Set([
"Error",
Expand Down

0 comments on commit f891db1

Please sign in to comment.