3 ms·
With Extractors [1] (currently at Stage 1), you could define something like this to work: const Integer = { [Symbol.customMatcher]: (value) => [Numbe
by the_imp 2y ago
With Extractors [1] (currently at Stage 1), you could define something like this to work:
const Integer = {
[Symbol.customMatcher]: (value) => [Number.parseInt(value)]
}
const Integer(counter) = 42.56;
// counter === 42
[1] https://github.com/tc39/proposal-extractors https://github.com/tc39/proposal-extractors