@piing/io-types
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

@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

Readme

Keywords

Package Sidebar

Install

npm i @piing/io-types

Weekly Downloads

3

Version

1.1.1

License

mit

Unpacked Size

502 kB

Total Files

65

Last publish

Collaborators

  • dtudorache-clarisoft
  • gorillatron
  • piing_admin