Socket
Book a DemoInstallSign in
Socket

@scottrabin/decoder

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scottrabin/decoder

Decode JSON into application types

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@scottrabin/decoder

Decode unknown JSON values into known types via composable decoders.

The intended use case is external type parsing, which have no guarantees on structural types. This library aims to provide type safety to e.g. responses to API calls, localStorage and its ilk, and other boundaries where type information is lost or unavailable. It is not intended for use in transforming the interpreted data - it only affirms the data returned by the decoders meets the structural requirements.

Getting Started

$ yarn add @scottrabin/decoder
// in yourFile.ts
import * as decoders from "@scottrabin/decoder";

const myDecoder = decoders.struct(/* ... */);

API

See the documentation

Philosophy

decoder is intended to be modular; decoders are simple objects with a decode method, which accepts a value of type unknown and returns a Result type indicating success or failure in asserting the type of the given value matches the desired type.

License

MIT

Keywords

typescript

FAQs

Package last updated on 19 Mar 2022

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.