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

@contember/typesafe

Package Overview
Dependencies
Maintainers
5
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/typesafe - npm Package Compare versions

Comparing version 1.3.0-alpha.5 to 1.3.0-alpha.6

14

dist/src/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.valueAt = exports.coalesce = exports.transform = exports.nullable = exports.false_ = exports.true_ = exports.null_ = exports.enumeration = exports.intersection = exports.discriminatedTupleUnion = exports.tuple = exports.discriminatedUnion = exports.partiallyDiscriminatedUnion = exports.union = exports.record = exports.noExtraProps = exports.partial = exports.object = exports.array = exports.literal = exports.anyJsonObject = exports.anyJson = exports.scalar = exports.boolean = exports.integer = exports.number = exports.string = exports.fail = exports.ParseError = void 0;
const node_util_1 = require("node:util");
class ParseError extends Error {

@@ -212,2 +211,13 @@ constructor(path, reason, expected) {

exports.union = union;
const isSamePath = (a, b) => {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
};
const partiallyDiscriminatedUnion = (field, ...inner) => {

@@ -222,3 +232,3 @@ const type = (input, path = []) => {

if (e instanceof ParseError) {
if ((0, node_util_1.isDeepStrictEqual)(e.path, [...path, field])) {
if (isSamePath(e.path, [...path, field])) {
continue;

@@ -225,0 +235,0 @@ }

2

package.json
{
"name": "@contember/typesafe",
"version": "1.3.0-alpha.5",
"version": "1.3.0-alpha.6",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -1,3 +0,1 @@

import { isDeepStrictEqual } from 'node:util'
type Unpacked<T> = T extends readonly (infer U)[] ? U : never

@@ -245,2 +243,14 @@

const isSamePath = (a: PropertyKey[], b: PropertyKey[]) => {
if (a.length !== b.length) {
return false
}
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false
}
}
return true
}
export const partiallyDiscriminatedUnion = <T extends Type<JsonObject>[]>(field: string, ...inner: T): Type<ReturnType<Unpacked<T>>> => {

@@ -254,3 +264,3 @@ const type = (input: unknown, path: PropertyKey[] = []): ReturnType<Unpacked<T>> => {

if (e instanceof ParseError) {
if (isDeepStrictEqual(e.path, [...path, field])) {
if (isSamePath(e.path, [...path, field])) {
continue

@@ -257,0 +267,0 @@ }

Sorry, the diff of this file is not supported yet

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