Socket
Socket
Sign inDemoInstall

io-ts

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

5

CHANGELOG.md

@@ -16,2 +16,7 @@ # Changelog

# 1.1.3
* **Internal**
* upgrade to `typings-checker@2.0.0` (@gcanti)
# 1.1.2

@@ -18,0 +23,0 @@

4

lib/index.js

@@ -892,4 +892,2 @@ "use strict";

exports.ExactType = ExactType;
// typings-checker doesn't know Object.assign
var assign = Object.assign;
var getProps = function (type) {

@@ -905,3 +903,3 @@ switch (type._tag) {

case 'IntersectionType':
return type.types.reduce(function (props, type) { return assign(props, getProps(type)); }, {});
return type.types.reduce(function (props, type) { return Object.assign(props, getProps(type)); }, {});
}

@@ -908,0 +906,0 @@ };

{
"name": "io-ts",
"version": "1.1.2",
"version": "1.1.3",
"description": "TypeScript compatible runtime type system for IO validation",

@@ -47,3 +47,3 @@ "files": ["lib"],

"typescript": "2.8.3",
"typings-checker": "1.1.2"
"typings-checker": "2.0.0"
},

@@ -50,0 +50,0 @@ "tags": ["typescript", "validation", "inference", "types", "runtime"],

@@ -324,19 +324,32 @@ [![build status](https://img.shields.io/travis/gcanti/io-ts/master.svg?style=flat-square)](https://travis-ci.org/gcanti/io-ts)

No, however you can define your own logic for that (if you _really_ trust the input and the involved types don't perform
deserializations)
No, however you can define your own logic for that (if you _really_ trust the input)
```ts
import * as t from 'io-ts'
import { failure } from 'io-ts/lib/PathReporter'
import { Either, right } from 'fp-ts/lib/Either'
const { NODE_ENV } = process.env
export function unsafeValidate<A, O>(value: any, type: t.Type<A, O>): A {
if (NODE_ENV !== 'production') {
export function unsafeDecode<A, O>(value: t.mixed, type: t.Type<A, O>): Either<t.Errors, A> {
if (NODE_ENV !== 'production' || type.encode !== t.identity) {
return type.decode(value)
} else {
// unsafe cast
return right(value as A)
}
}
// or...
import { failure } from 'io-ts/lib/PathReporter'
export function unsafeGet<A, O>(value: t.mixed, type: t.Type<A, O>): A {
if (NODE_ENV !== 'production' || type.encode !== t.identity) {
return type.decode(value).getOrElseL(errors => {
throw new Error(failure(errors).join('\n'))
})
} else {
// unsafe cast
return value as A
}
// unsafe cast
return value as A
}

@@ -343,0 +356,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc