Sets & Maps
Decoders for maps and sets.
mapping
mapping( decoder: Decoder<T> ): Decoder<Map<string, T>> (source)
Similar to record(), but returns the result as a
Map<string, T> (an
ES6 Map)
instead.
Try it
| Input | Result |
|---|---|
| … | |
| … |
setFromArray
setFromArray( decoder: Decoder<T> ): Decoder<Set<T>> (source)
Similar to array(), but returns the result as an
ES6 Set.
Try it
| Input | Result |
|---|---|
| … | |
| … | |
| … |
Limiting set sizes
sized( decoder: Decoder<Set<T>>, options: SizeOptions ): Decoder<Set<T>> (source)
Will be available once 2.9 is released.
Takes any set decoder and rejects values that don't match the given size constraints. Also works with strings and arrays.
SizeOptions accepts min, max, or size (shorthand for exact length).
Try it
| Input | Result |
|---|---|
| … | |
| … | |
| … | |
| … |