feat: predicate filtering
This PR introduces a slight modification of the isArrayOf and only themes. Two new functions are introduced as more generic alternatives to the primitive and classy type guards:
isArrayOfAll(and its readonly counterpartisReadonlyArrayOfAll) is the same asisArrayOfbut receives type guards instead of classy/like type information.onlyIfis the same asonly, but receives type guards instead of classy/like type information, just likeisArrayOfAll.
With them, one can abstract away primitive or classy-type-specific type guards by depending solely on the TypeGuard concept.
This feature plays (or at least I expect that it will play) rather well with guard chaining; instead of having mono-typed array checks, e.g. isArrayOfStrings(x) || isArrayOfNumbers(x), one can check for arrays of diverse types, with the added possibility of single evaluation of the operand and a single curried type guard, e.g. isArrayOfAll(guard(isString).or(isNumber))(x) (typed as x is string | number).
In the future, I will submit a new PR that does interface checking by means of an interface descriptor, and the predicate filtering functionality will play a vital role in enabling a more flexible filtering in cases where a classy type is not available at runtime (e.g. when using only interfaces).
One PR remaining! :D
@SimonAlling , I still think there's merit in keeping this PR, so I'm keeping it. If you accept it, and if there's anything I must fix or improve, please do tell me!