🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

io-ts-immutable

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts-immutable

A collection of io-ts codecs for the immutable collections from immutable-js

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
8
-38.46%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install io-ts-immutable

or

yarn add io-ts-immutable

Usage

List

import {List} from "immutable";
import * as tImmutable from "io-ts-immutable";
import * as t from "io-ts";
const input = [1, 2, 3];
const decoded: List<number> = tImmutable.list(t.number).decode(input);
const encoded = tImmutable.list(t.number).encode(decoded);

Map

The map-codec has, besides it's two codec parameters, a third parameter called "format". This parameter controls how the encoded value must look like.

import * as tImmutable from "io-ts-immutable";
import * as t from "io-ts";
const input = {
    one: 1,
    two: 2,
    three: 3
};
const decoded = tImmutable.map(t.string, t.number, "object").decode(input);
const encoded = tImmutable.map(t.string, t.number, "object").encode(decoded);
import * as tImmutable from "io-ts-immutable";
import * as t from "io-ts";
const input: Array<[string, number]> = [["one", 1], ["two", 2], ["three", 3]];
const decoded = tImmutable.map(t.string, t.number, "tuples").decode(input);
const encoded = tImmutable.map(t.string, t.number, "tuples").encode(decoded);
import * as tImmutable from "io-ts-immutable";
import * as t from "io-ts";
const input = [
    {key: "one", value: 1},
    {key: "two", value: 2},
    {key: "three", value: 3}
];
const decoded = tImmutable.map(t.string, t.number, "pairs").decode(input);
const encoded = tImmutable.map(t.string, t.number, "pairs").encode(decoded);

Keywords

io-ts

FAQs

Package last updated on 05 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts