
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@scottrabin/decoder
Advanced tools
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.
$ yarn add @scottrabin/decoder
// in yourFile.ts
import * as decoders from "@scottrabin/decoder";
const myDecoder = decoders.struct(/* ... */);
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.
FAQs
Decode JSON into application types
We found that @scottrabin/decoder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.