@tdreyno/fluent-decoders
TypeScript icon, indicating that this package has built-in type declarations

1.25.5-4 • Public • Published

fluent-decoders

npm latest version Minified Size

fluent-decoders is a Fluent-style API wrapper around nvie/decoders.

Note: Version is ALWAYS locked to same number as upstream decoders library

Example

import { array, boolean, string, tuple3 } from "@tdreyno/fluent-decoders"

interface Person {
  name: string
  age: string
  isActive: boolean
}

const toPerson = ([name, age, isActive]): Person => ({ name, age, isActive })

const containsInt = (s: any): s is StringInt => !isNaN(parseInt(s, 10))

const personDecoder = tuple3(string, string.refine(containsInt), boolean).map(
  toPerson,
)

const person = personDecoder.validate(["Name", "42", true])

// Compose
const people = array(personDecoder).validate([
  ["A", "4", true],
  ["B", "2", false],
])

Installation

Yarn

yarn add @tdreyno/fluent-decoders

NPM

npm install --save @tdreyno/fluent-decoders

License

fluent-decoders is licensed under the Hippocratic License. It is an Ethical Source license derived from the MIT License, amended to limit the impact of the unethical use of open source software.

Readme

Keywords

none

Package Sidebar

Install

npm i @tdreyno/fluent-decoders

Weekly Downloads

40

Version

1.25.5-4

License

none

Unpacked Size

71.2 kB

Total Files

27

Last publish

Collaborators

  • tdreyno91