Create a type predicate function that checks if input passes fn and has a size matching the given size or falling within the given range.
input
fn
size
const twoItemSet = withSize(instanceOf(Set), 2);twoItemSet(new Set([1, 2])); // truetwoItemSet(new Set([1])); // falseconst setWithRange = withSize(instanceOf(Set), [1, 3]);setWithRange(new Set([1, 2])); // truesetWithRange(new Set()); // false Copy
const twoItemSet = withSize(instanceOf(Set), 2);twoItemSet(new Set([1, 2])); // truetwoItemSet(new Set([1])); // falseconst setWithRange = withSize(instanceOf(Set), [1, 3]);setWithRange(new Set([1, 2])); // truesetWithRange(new Set()); // false
Create a type predicate function that checks if
inputpassesfnand has asizematching the givensizeor falling within the given range.Example