Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@faast/ts-common

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@faast/ts-common - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

4

dist/lib/utils/validation.d.ts

@@ -5,2 +5,4 @@ import { ValidationError, Type } from 'io-ts';

export declare const SimpleReporter: Reporter<Array<string>>;
export declare function assertType<T>(typeCodec: Type<T>, value: unknown, description?: string): T;
export declare function assertType<T>(typeCodec: Type<T>, value: unknown, description?: string, ErrorType?: {
new (message: string): Error;
}): T;

@@ -23,6 +23,6 @@ import { UnionType, IntersectionType } from 'io-ts';

};
export function assertType(typeCodec, value, description = 'type') {
export function assertType(typeCodec, value, description = 'type', ErrorType = TypeError) {
const validation = typeCodec.decode(value);
if (validation.isLeft()) {
throw new TypeError(`Invalid ${description} - ${SimpleReporter.report(validation)[0]}`);
throw new ErrorType(`Invalid ${description} - ${SimpleReporter.report(validation)[0]}`);
}

@@ -29,0 +29,0 @@ return validation.value;

{
"name": "@faast/ts-common",
"version": "0.2.4",
"version": "0.2.5",
"description": "Common typescript types and utils used by faast",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -35,8 +35,13 @@ import { Context, ValidationError, UnionType, IntersectionType, Type } from 'io-ts'

*/
export function assertType<T>(typeCodec: Type<T>, value: unknown, description: string = 'type'): T {
export function assertType<T>(
typeCodec: Type<T>,
value: unknown,
description: string = 'type',
ErrorType: { new (message: string): Error } = TypeError,
): T {
const validation = typeCodec.decode(value)
if (validation.isLeft()) {
throw new TypeError(`Invalid ${description} - ${SimpleReporter.report(validation)[0]}`)
throw new ErrorType(`Invalid ${description} - ${SimpleReporter.report(validation)[0]}`)
}
return validation.value
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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