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

x-value

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

x-value - npm Package Compare versions

Comparing version 0.0.1-10 to 0.0.1-11

8

bld/library/@utils.d.ts
import type { ArrayType, AtomicType, IntersectionType, ObjectType, OptionalType, RecordType, RefinedType, TupleType, Type, UnionType } from './type';
import type { Nominal } from './utils';
import type { Denominalize, __nominalType } from './utils';
export declare const hasOwnProperty: (v: PropertyKey) => boolean;
export declare const toString: () => string;
export declare type __MediumTypeOf<TType, TMediumTypes> = TType extends ObjectType<infer TDefinition> ? __ObjectTypeDefinitionToMediumType<TDefinition, TMediumTypes> : TType extends RecordType<infer TKey, infer TValue> ? Record<__MediumTypeOfRecordKeyType<TKey, TMediumTypes>, __MediumTypeOf<TValue, TMediumTypes>> : TType extends ArrayType<infer TElementType> ? __MediumTypeOf<TElementType, TMediumTypes>[] : TType extends TupleType<infer TTuple> ? __TupleMediumType<TTuple, TMediumTypes> : TType extends RefinedType<infer TType, infer TNominal> ? __MediumTypeOf<TType, TMediumTypes> & TNominal : TType extends AtomicType<infer TTypeSymbol> ? __AtomicMediumType<TTypeSymbol, TMediumTypes> : TType extends UnionType<infer TTypeTuple> ? __MediumTypeOf<TTypeTuple[number], TMediumTypes> : TType extends IntersectionType<infer TTypeTuple> ? __UnionToIntersection<__MediumTypeOf<TTypeTuple[number], TMediumTypes>> : TType extends OptionalType<infer TType> ? __MediumTypeOf<TType, TMediumTypes> | undefined : never;
export declare type __MediumTypeOf<TType, TMediumTypes> = TType extends ObjectType<infer TDefinition> ? __ObjectTypeDefinitionToMediumType<TDefinition, TMediumTypes> : TType extends RecordType<infer TKey, infer TValue> ? Record<__MediumTypeOfRecordKeyType<TKey, TMediumTypes>, __MediumTypeOf<TValue, TMediumTypes>> : TType extends ArrayType<infer TElementType> ? __MediumTypeOf<TElementType, TMediumTypes>[] : TType extends TupleType<infer TTuple> ? __TupleMediumType<TTuple, TMediumTypes> : TType extends RefinedType<infer TType, infer TNominal> ? __RefinedMediumType<TType, TNominal, TMediumTypes> : TType extends AtomicType<infer TTypeSymbol> ? __AtomicMediumType<TTypeSymbol, TMediumTypes> : TType extends UnionType<infer TTypeTuple> ? __MediumTypeOf<TTypeTuple[number], TMediumTypes> : TType extends IntersectionType<infer TTypeTuple> ? __UnionToIntersection<__MediumTypeOf<TTypeTuple[number], TMediumTypes>> : TType extends OptionalType<infer TType> ? __MediumTypeOf<TType, TMediumTypes> | undefined : never;
export declare type __ObjectTypeDefinitionToMediumType<TDefinition, TMediumTypes> = {

@@ -16,2 +16,5 @@ [TKey in __KeyOfOptional<TDefinition>]?: TDefinition[TKey] extends OptionalType<infer TNestedType> ? __MediumTypeOf<TNestedType, TMediumTypes> : never;

};
export declare type __RefinedMediumType<TType, TNominal, TMediumTypes> = __MediumTypeOf<TType, TMediumTypes> extends infer T ? unknown extends TNominal ? T : T & TNominal & {
[TNominalTypeSymbol in typeof __nominalType]: Denominalize<T>;
} : never;
export declare type __AtomicMediumType<TSymbol extends symbol, TMediumTypes> = TMediumTypes extends {

@@ -30,4 +33,3 @@ [TKey in TSymbol]: infer TMediumType;

} ? TPacked : TFallback;
export declare type __Nominal<TNominal> = TNominal extends string | symbol ? Nominal<TNominal> : TNominal;
export declare type __ElementOrArray<T> = T | T[];
export declare function merge(partials: unknown[]): unknown;

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

import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __Nominal } from '../@utils';
import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint, TypeOf } from './type';

export interface ArrayType<TElement> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TElement>[]>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TElement>[]>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TElement, TMediumTypes>[]>): TypeOf<TElement>[];

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: TypeOf<TElement>[]): __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TElement, TMediumTypes>[]>;

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

import type { __AtomicMediumType, __ElementOrArray, __MediumTypesPackedType, __Nominal } from '../@utils';
import type { __AtomicMediumType, __ElementOrArray, __MediumTypesPackedType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -10,3 +11,3 @@ import type { TypeConstraint } from './type';

export interface AtomicType<TSymbol> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__AtomicMediumType<TSymbol, XValue.Types>>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__AtomicMediumType<TSymbol, XValue.Types>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __AtomicMediumType<TSymbol, TMediumTypes>>): __AtomicMediumType<TSymbol, XValue.Types>;

@@ -13,0 +14,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __AtomicMediumType<TSymbol, XValue.Types>): __MediumTypesPackedType<TMediumTypes, __AtomicMediumType<TSymbol, TMediumTypes>>;

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

import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __Nominal, __UnionToIntersection } from '../@utils';
import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __UnionToIntersection } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint, TypeOf } from './type';

export interface IntersectionType<TTypeTuple> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__UnionToIntersection<TypeOf<TTypeTuple[number]>>>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__UnionToIntersection<TypeOf<TTypeTuple[number]>>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __UnionToIntersection<__MediumTypeOf<TTypeTuple[number], TMediumTypes>>>): __UnionToIntersection<TypeOf<TTypeTuple[number]>>;

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __UnionToIntersection<TypeOf<TTypeTuple[number]>>): __MediumTypesPackedType<TMediumTypes, __UnionToIntersection<__MediumTypeOf<TTypeTuple[number], TMediumTypes>>>;

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

import type { __ElementOrArray, __MediumTypesPackedType, __Nominal, __ObjectTypeDefinitionToMediumType } from '../@utils';
import type { __ElementOrArray, __MediumTypesPackedType, __ObjectTypeDefinitionToMediumType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint } from './type';

export interface ObjectType<TTypeDefinition> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__ObjectTypeDefinitionToMediumType<TTypeDefinition, XValue.Types>>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__ObjectTypeDefinitionToMediumType<TTypeDefinition, XValue.Types>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, packed: __MediumTypesPackedType<TMediumTypes, __ObjectTypeDefinitionToMediumType<TTypeDefinition, TMediumTypes>>): __ObjectTypeDefinitionToMediumType<TTypeDefinition, XValue.Types>;

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __ObjectTypeDefinitionToMediumType<TTypeDefinition, XValue.Types>): __MediumTypesPackedType<TMediumTypes, __ObjectTypeDefinitionToMediumType<TTypeDefinition, TMediumTypes>>;

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

import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __Nominal } from '../@utils';
import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint, TypeOf } from './type';

export interface OptionalType<TType> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TType> | undefined>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TType> | undefined>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TType, TMediumTypes> | undefined>): TypeOf<TType> | undefined;

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: TypeOf<TType> | undefined): __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TType, TMediumTypes> | undefined>;

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

import type { __ElementOrArray, __MediumTypeOf, __MediumTypeOfRecordKeyType, __MediumTypesPackedType, __Nominal, __TypeOfRecordKeyType } from '../@utils';
import type { __ElementOrArray, __MediumTypeOf, __MediumTypeOfRecordKeyType, __MediumTypesPackedType, __TypeOfRecordKeyType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint, TypeOf } from './type';

export interface RecordType<TKey, TValue> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<Record<__TypeOfRecordKeyType<TKey>, TypeOf<TValue>>>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<Record<__TypeOfRecordKeyType<TKey>, TypeOf<TValue>>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, packed: __MediumTypesPackedType<TMediumTypes, Record<__MediumTypeOfRecordKeyType<TKey, TMediumTypes>, __MediumTypeOf<TValue, TMediumTypes>>>): Record<__TypeOfRecordKeyType<TKey>, TypeOf<TValue>>;

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: Record<__TypeOfRecordKeyType<TKey>, TypeOf<TValue>>): __MediumTypesPackedType<TMediumTypes, Record<__MediumTypeOfRecordKeyType<TKey, TMediumTypes>, __MediumTypeOf<TValue, TMediumTypes>>>;

@@ -1,11 +0,12 @@

import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __Nominal } from '../@utils';
import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __RefinedMediumType } from '../@utils';
import type { Medium } from '../medium';
import type { TypeConstraint, TypeOf } from './type';
import type { Nominal } from '../utils';
import type { TypeConstraint } from './type';
import { Type } from './type';
export interface RefinedType<TType, TNominal> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TType> & TNominal>>): RefinedType<this, __Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TType, TMediumTypes> & TNominal>): TypeOf<TType> & TNominal;
encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: TypeOf<TType> & TNominal): __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TType, TMediumTypes> & TNominal>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__RefinedMediumType<TType, TNominal, XValue.Types>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TType, TMediumTypes> & TNominal>): __RefinedMediumType<TType, TNominal, XValue.Types>;
encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __RefinedMediumType<TType, TNominal, XValue.Types>): __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TType, TMediumTypes> & TNominal>;
transform<TFromMediumTypes extends object, TToMediumTypes extends object>(from: Medium<TFromMediumTypes>, to: Medium<TToMediumTypes>, value: __MediumTypesPackedType<TFromMediumTypes, __MediumTypeOf<TType, TFromMediumTypes> & TNominal>): __MediumTypesPackedType<TToMediumTypes, __MediumTypeOf<TType, TToMediumTypes> & TNominal>;
is(value: unknown): value is TypeOf<TType> & TNominal;
is(value: unknown): value is __RefinedMediumType<TType, TNominal, XValue.Types>;
}

@@ -12,0 +13,0 @@ export declare class RefinedType<TType extends Type, TNominal> extends Type<'refined'> {

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

import type { __ElementOrArray, __MediumTypesPackedType, __Nominal, __TupleMediumType } from '../@utils';
import type { __ElementOrArray, __MediumTypesPackedType, __TupleMediumType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint } from './type';

export interface TupleType<TElements> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__TupleMediumType<TElements, XValue.Types>>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<__TupleMediumType<TElements, XValue.Types>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __MediumTypesPackedType<TMediumTypes, __TupleMediumType<TElements, TMediumTypes>>): __TupleMediumType<TElements, XValue.Types>;

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: __TupleMediumType<TElements, XValue.Types>): __MediumTypesPackedType<TMediumTypes, __TupleMediumType<TElements, TMediumTypes>>;

import type { __MediumTypeOf } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
export declare abstract class Type<TCategory extends string = string> {
protected __static_type_category: TCategory;
refine(constraints: TypeConstraint | TypeConstraint[]): RefinedType<Type, unknown>;
refine(constraints: TypeConstraint | TypeConstraint[]): RefinedType<Type, Nominal<unknown>>;
decode(medium: Medium, packed: unknown): unknown;

@@ -7,0 +8,0 @@ encode(medium: Medium, value: unknown): unknown;

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

import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType, __Nominal } from '../@utils';
import type { __ElementOrArray, __MediumTypeOf, __MediumTypesPackedType } from '../@utils';
import type { Medium } from '../medium';
import type { Nominal } from '../utils';
import type { RefinedType } from './refined-type';

@@ -7,3 +8,3 @@ import type { TypeConstraint, TypeOf } from './type';

export interface UnionType<TTypeTuple> {
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TTypeTuple[number]>>>): RefinedType<this, __Nominal<TNominal>>;
refine<TNominal>(constraints: __ElementOrArray<TypeConstraint<TypeOf<TTypeTuple[number]>>>): RefinedType<this, Nominal<TNominal>>;
decode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, packed: __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TTypeTuple[number], TMediumTypes>>): TypeOf<TTypeTuple[number]>;

@@ -10,0 +11,0 @@ encode<TMediumTypes extends object>(medium: Medium<TMediumTypes>, value: TypeOf<TTypeTuple[number]>): __MediumTypesPackedType<TMediumTypes, __MediumTypeOf<TTypeTuple[number], TMediumTypes>>;

@@ -10,8 +10,20 @@ import type { Type, TypeOf } from './type';

*/
export declare const nominal: unique symbol;
export declare type Nominal<TKey extends string | symbol, TType = unknown> = TType & {
[TNominalSymbol in typeof nominal]: {
[TNominalKey in TKey]: true;
export declare const __nominal: unique symbol;
/**
* DECLARATION ONLY.
*
* Exported to avoid TS4023 error:
* https://github.com/Microsoft/TypeScript/issues/5711
*/
export declare const __nominalType: unique symbol;
export declare type Nominal<TNominal, T = unknown> = T & (unknown extends TNominal ? unknown : {
[TNominalTypeSymbol in typeof __nominalType]: T;
} & ([TNominal] extends [string | symbol] ? {
[TNominalSymbol in typeof __nominal]: {
[TNominalKey in TNominal]: true;
};
};
} : TNominal));
export declare type Denominalize<T> = T extends {
[TNominalTypeSymbol in typeof __nominalType]: infer TDenominalized;
} ? TDenominalized : T;
export declare const UnknownRecord: import("./type").RecordType<AtomicType<typeof stringTypeSymbol>, AtomicType<typeof import("./types").unknownTypeSymbol>>;

@@ -18,0 +30,0 @@ export declare function literal<T extends string>(literal: T): AtomicType<typeof stringTypeSymbol>;

{
"name": "x-value",
"version": "0.0.1-10",
"version": "0.0.1-11",
"repository": "https://github.com/vilic/x-value.git",

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

@@ -231,3 +231,3 @@ [![NPM version](https://img.shields.io/npm/v/x-value?color=%23cb3837&style=flat-square)](https://www.npmjs.com/package/x-value)

> The `superJSON` medium is actually a packed medium. However, the related definitions are inherited.
> The `superJSON` medium is actually a packed medium. However, the related definitions are inherited from `x.JSONTypes`.

@@ -234,0 +234,0 @@ ## License

@@ -13,3 +13,3 @@ import type {

} from './type';
import type {Nominal} from './utils';
import type {Denominalize, __nominalType} from './utils';

@@ -34,3 +34,3 @@ export const hasOwnProperty = Object.prototype.hasOwnProperty;

: TType extends RefinedType<infer TType, infer TNominal>
? __MediumTypeOf<TType, TMediumTypes> & TNominal
? __RefinedMediumType<TType, TNominal, TMediumTypes>
: TType extends AtomicType<infer TTypeSymbol>

@@ -75,2 +75,14 @@ ? __AtomicMediumType<TTypeSymbol, TMediumTypes>

export type __RefinedMediumType<TType, TNominal, TMediumTypes> = __MediumTypeOf<
TType,
TMediumTypes
> extends infer T
? unknown extends TNominal
? T
: T &
TNominal & {
[TNominalTypeSymbol in typeof __nominalType]: Denominalize<T>;
}
: never;
export type __AtomicMediumType<

@@ -116,6 +128,2 @@ TSymbol extends symbol,

export type __Nominal<TNominal> = TNominal extends string | symbol
? Nominal<TNominal>
: TNominal;
export type __ElementOrArray<T> = T | T[];

@@ -122,0 +130,0 @@

@@ -5,6 +5,6 @@ import type {

__MediumTypesPackedType,
__Nominal,
} from '../@utils';
import {toString} from '../@utils';
import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -18,3 +18,3 @@ import type {RefinedType} from './refined-type';

constraints: __ElementOrArray<TypeConstraint<TypeOf<TElement>[]>>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -21,0 +21,0 @@ decode<TMediumTypes extends object>(

@@ -5,5 +5,5 @@ import type {

__MediumTypesPackedType,
__Nominal,
} from '../@utils';
import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -28,3 +28,3 @@ import type {RefinedType} from './refined-type';

>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -31,0 +31,0 @@ decode<TMediumTypes extends object>(

@@ -5,3 +5,2 @@ import type {

__MediumTypesPackedType,
__Nominal,
__UnionToIntersection,

@@ -11,2 +10,3 @@ } from '../@utils';

import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -22,3 +22,3 @@ import type {RefinedType} from './refined-type';

>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -25,0 +25,0 @@ decode<TMediumTypes extends object>(

import type {
__ElementOrArray,
__MediumTypesPackedType,
__Nominal,
__ObjectTypeDefinitionToMediumType,

@@ -9,2 +8,3 @@ } from '../@utils';

import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -22,3 +22,3 @@ import type {RefinedType} from './refined-type';

>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -25,0 +25,0 @@ decode<TMediumTypes extends object>(

@@ -5,5 +5,5 @@ import type {

__MediumTypesPackedType,
__Nominal,
} from '../@utils';
import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -17,3 +17,3 @@ import type {RefinedType} from './refined-type';

constraints: __ElementOrArray<TypeConstraint<TypeOf<TType> | undefined>>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -20,0 +20,0 @@ decode<TMediumTypes extends object>(

@@ -6,3 +6,2 @@ import type {

__MediumTypesPackedType,
__Nominal,
__TypeOfRecordKeyType,

@@ -12,2 +11,3 @@ } from '../@utils';

import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -23,3 +23,3 @@ import type {RefinedType} from './refined-type';

>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -26,0 +26,0 @@ decode<TMediumTypes extends object>(

@@ -5,7 +5,8 @@ import type {

__MediumTypesPackedType,
__Nominal,
__RefinedMediumType,
} from '../@utils';
import type {Medium} from '../medium';
import type {Nominal} from '../utils';
import type {TypeConstraint, TypeIssue, TypeOf, TypePath} from './type';
import type {TypeConstraint, TypeIssue, TypePath} from './type';
import {Type} from './type';

@@ -15,4 +16,6 @@

refine<TNominal>(
constraints: __ElementOrArray<TypeConstraint<TypeOf<TType> & TNominal>>,
): RefinedType<this, __Nominal<TNominal>>;
constraints: __ElementOrArray<
TypeConstraint<__RefinedMediumType<TType, TNominal, XValue.Types>>
>,
): RefinedType<this, Nominal<TNominal>>;

@@ -25,7 +28,7 @@ decode<TMediumTypes extends object>(

>,
): TypeOf<TType> & TNominal;
): __RefinedMediumType<TType, TNominal, XValue.Types>;
encode<TMediumTypes extends object>(
medium: Medium<TMediumTypes>,
value: TypeOf<TType> & TNominal,
value: __RefinedMediumType<TType, TNominal, XValue.Types>,
): __MediumTypesPackedType<

@@ -48,3 +51,5 @@ TMediumTypes,

is(value: unknown): value is TypeOf<TType> & TNominal;
is(
value: unknown,
): value is __RefinedMediumType<TType, TNominal, XValue.Types>;
}

@@ -51,0 +56,0 @@

import type {
__ElementOrArray,
__MediumTypesPackedType,
__Nominal,
__TupleMediumType,

@@ -9,2 +8,3 @@ } from '../@utils';

import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -20,3 +20,3 @@ import type {RefinedType} from './refined-type';

>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -23,0 +23,0 @@ decode<TMediumTypes extends object>(

import type {__MediumTypeOf} from '../@utils';
import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -11,3 +12,3 @@ /* eslint-disable @mufan/import-groups */

constraints: TypeConstraint | TypeConstraint[],
): RefinedType<Type, unknown> {
): RefinedType<Type, Nominal<unknown>> {
return refined(this, constraints);

@@ -14,0 +15,0 @@ }

@@ -5,5 +5,5 @@ import type {

__MediumTypesPackedType,
__Nominal,
} from '../@utils';
import type {Medium} from '../medium';
import type {Nominal} from '../utils';

@@ -17,3 +17,3 @@ import type {RefinedType} from './refined-type';

constraints: __ElementOrArray<TypeConstraint<TypeOf<TTypeTuple[number]>>>,
): RefinedType<this, __Nominal<TNominal>>;
): RefinedType<this, Nominal<TNominal>>;

@@ -20,0 +20,0 @@ decode<TMediumTypes extends object>(

@@ -19,10 +19,31 @@ import isEqual from 'lodash.isequal';

*/
export declare const nominal: unique symbol;
export declare const __nominal: unique symbol;
export type Nominal<TKey extends string | symbol, TType = unknown> = TType & {
[TNominalSymbol in typeof nominal]: {
[TNominalKey in TKey]: true;
};
};
/**
* DECLARATION ONLY.
*
* Exported to avoid TS4023 error:
* https://github.com/Microsoft/TypeScript/issues/5711
*/
export declare const __nominalType: unique symbol;
export type Nominal<TNominal, T = unknown> = T &
(unknown extends TNominal
? unknown
: {
[TNominalTypeSymbol in typeof __nominalType]: T;
} & ([TNominal] extends [string | symbol]
? {
[TNominalSymbol in typeof __nominal]: {
[TNominalKey in TNominal]: true;
};
}
: TNominal));
export type Denominalize<T> = T extends {
[TNominalTypeSymbol in typeof __nominalType]: infer TDenominalized;
}
? TDenominalized
: T;
export const UnknownRecord = record(string, unknown);

@@ -29,0 +50,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

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

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