1.25.5-4 • Published 2 years ago

@tdreyno/fluent-decoders v1.25.5-4

Weekly downloads
12
License
-
Repository
github
Last release
2 years ago

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.

1.25.5-3

2 years ago

1.25.5-4

2 years ago

1.25.5-0

2 years ago

1.25.5-1

2 years ago

1.25.0-1

3 years ago

1.24.1-1

3 years ago

1.24.0-1

3 years ago

1.23.4-6

3 years ago

1.23.4-4

3 years ago

1.23.4-3

3 years ago

1.23.4-5

3 years ago

1.23.4-2

3 years ago

1.23.3-2

3 years ago

1.23.3-1

3 years ago

1.23.3

3 years ago