1.1.1 • Published 5 years ago

@piing/io-types v1.1.1

Weekly downloads
12
License
mit
Repository
github
Last release
5 years ago

@piing/io-types

A sellection of essential io-ts types for decoding io like url queries and such.

Install

npm i @piing/io-types

Examples

import * as io from "io-ts"

import { ArrayFromJSONString } from "@piing/io-types/lib/ArrayFromJSONString"
import { Nullable } from "@piing/io-types/lib/Nullable"
import { YesNoBool } from "@piing/io-types/lib/YesNoBool"


const JSONNumberArray = ArrayFromJSONString(io.number);
const JSONStringArray = ArrayFromJSONString(io.string);

JSONNumberArray.decode("[1,2,3]") // right [1,2,3]
JSONStringArray.decode(`["foo", "bar"]`) // right ["foo", "bar"]


const NullableNumber = Nullable(io.number)

NullableNumber.decode(null) // right null
NullableNumber.decode(1) // right 1


YesNoBool.decode("yes") // right true
YesNoBool.decode("no") // right false
1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.4

5 years ago

0.0.31

5 years ago

0.0.3

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago