How to use decoders - 10 common examples

To help you get started, we’ve selected a few decoders examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nvie / decoders / src / types / object-tests.ts View on Github external
import { exact, object, pojo, string } from 'decoders';

// $ExpectType Decoder<{ foo: string; bar: { qux: string; }; }, unknown>
object({
    foo: string,
    bar: object({ qux: string }),
});

// $ExpectType Decoder<{ foo: string; bar: { qux: string; }; }, unknown>
exact({
    foo: string,
    bar: object({ qux: string }),
});

// $ExpectType Decoder<{ [key: string]: unknown; }, unknown>
pojo;
github nvie / decoders / src / types / instanceOf-tests.ts View on Github external
import { instanceOf } from 'decoders';

// $ExpectType Decoder
instanceOf(Error);

// $ExpectType Decoder
instanceOf(TypeError);

// $ExpectType Decoder
instanceOf(RegExp);

// $ExpectType Decoder, unknown>
instanceOf>(Promise);

// $ExpectError
instanceOf>(Set);
github nvie / decoders / src / types / instanceOf-tests.ts View on Github external
import { instanceOf } from 'decoders';

// $ExpectType Decoder
instanceOf(Error);

// $ExpectType Decoder
instanceOf(TypeError);

// $ExpectType Decoder
instanceOf(RegExp);

// $ExpectType Decoder, unknown>
instanceOf>(Promise);

// $ExpectError
instanceOf>(Set);
github nvie / decoders / src / types / instanceOf-tests.ts View on Github external
import { instanceOf } from 'decoders';

// $ExpectType Decoder
instanceOf(Error);

// $ExpectType Decoder
instanceOf(TypeError);

// $ExpectType Decoder
instanceOf(RegExp);

// $ExpectType Decoder, unknown>
instanceOf>(Promise);

// $ExpectError
instanceOf>(Set);
github nvie / decoders / src / types / instanceOf-tests.ts View on Github external
import { instanceOf } from 'decoders';

// $ExpectType Decoder
instanceOf(Error);

// $ExpectType Decoder
instanceOf(TypeError);

// $ExpectType Decoder
instanceOf(RegExp);

// $ExpectType Decoder, unknown>
instanceOf>(Promise);

// $ExpectError
instanceOf>(Set);
github nvie / decoders / src / types / instanceOf-tests.ts View on Github external
import { instanceOf } from 'decoders';

// $ExpectType Decoder
instanceOf(Error);

// $ExpectType Decoder
instanceOf(TypeError);

// $ExpectType Decoder
instanceOf(RegExp);

// $ExpectType Decoder, unknown>
instanceOf>(Promise);

// $ExpectError
instanceOf>(Set);
github nvie / decoders / src / types / optional-tests.ts View on Github external
import { maybe, nullable, optional, string } from 'decoders';

optional(string); // $ExpectType Decoder
optional(optional(string)); // $ExpectType Decoder

nullable(string); // $ExpectType Decoder
nullable(nullable(string)); // $ExpectType Decoder

maybe(string); // $ExpectType Decoder
maybe(maybe(string)); // $ExpectType Decoder
github nvie / decoders / src / types / optional-tests.ts View on Github external
import { maybe, nullable, optional, string } from 'decoders';

optional(string); // $ExpectType Decoder
optional(optional(string)); // $ExpectType Decoder

nullable(string); // $ExpectType Decoder
nullable(nullable(string)); // $ExpectType Decoder

maybe(string); // $ExpectType Decoder
maybe(maybe(string)); // $ExpectType Decoder
github nvie / decoders / src / types / optional-tests.ts View on Github external
import { maybe, nullable, optional, string } from 'decoders';

optional(string); // $ExpectType Decoder
optional(optional(string)); // $ExpectType Decoder

nullable(string); // $ExpectType Decoder
nullable(nullable(string)); // $ExpectType Decoder

maybe(string); // $ExpectType Decoder
maybe(maybe(string)); // $ExpectType Decoder
github nvie / decoders / src / types / optional-tests.ts View on Github external
import { maybe, nullable, optional, string } from 'decoders';

optional(string); // $ExpectType Decoder
optional(optional(string)); // $ExpectType Decoder

nullable(string); // $ExpectType Decoder
nullable(nullable(string)); // $ExpectType Decoder

maybe(string); // $ExpectType Decoder
maybe(maybe(string)); // $ExpectType Decoder