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

@bunt/input

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bunt/input - npm Package Compare versions

Comparing version 0.24.24 to 0.24.25

dist/Type/Mutate.d.ts

13

dist/interfaces.d.ts

@@ -1,10 +0,7 @@

import { Fields, List, Union, RecordType } from "./Type";
import { KeyOf } from "@bunt/util";
import { TypeAbstract } from "./TypeAbstract";
export declare type FieldFn<T> = () => T;
export declare type FieldType<T> = T | FieldFn<T>;
export declare type FieldsSchema<T> = {
[K in keyof T]-?: T[K] extends Array<infer S> ? FieldType<List<S>> : T[K] extends Date ? FieldType<TypeAbstract<T[K]>> : T[K] extends Record<any, any> ? FieldType<Fields<T[K]> | Union<T[K]> | typeof RecordType> : FieldType<TypeAbstract<T[K]>>;
export declare type FieldMayFn<T> = T | (() => T);
export declare type FieldsSchema<T extends Record<string, any>> = {
[K in KeyOf<T>]-?: FieldSelectType<T[K]>;
};
export declare type ObjectFields<T> = T extends Promise<infer A> ? FieldsSchema<Exclude<A, undefined | null>> : FieldsSchema<Exclude<T, undefined | null>>;
export declare type FieldSelectType<T> = FieldType<TypeAbstract<T>>;
export declare type ObjectTypeMerge<T extends Record<string, any>> = Fields<T> | ObjectFields<T>;
export declare type FieldSelectType<T> = FieldMayFn<TypeAbstract<T>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Type_1 = require("./Type");
new Type_1.Fields({ foo: Type_1.Int, bar: Type_1.Int });
new Type_1.Fields({ foo: new Type_1.Nullable(Type_1.Int), bar: Type_1.Int });
//# sourceMappingURL=interfaces.js.map

@@ -1,10 +0,10 @@

import { ObjectFields, ObjectTypeMerge } from "../interfaces";
import { FieldsSchema } from "../interfaces";
import { TypeAbstract } from "../TypeAbstract";
export declare class Fields<TValue extends Record<string, any>> extends TypeAbstract<TValue> {
#private;
constructor(fields: ObjectFields<TValue>, name?: string);
constructor(fields: FieldsSchema<TValue>, name?: string);
get name(): string;
get fields(): ObjectFields<TValue>;
merge<F extends Record<string, any>>(from: ObjectTypeMerge<F>): Fields<TValue & F>;
get fields(): FieldsSchema<TValue>;
merge<F extends Record<string, any>>(from: Fields<F> | FieldsSchema<F>): Fields<TValue & F>;
validate(payload: unknown): Promise<TValue>;
}

@@ -19,1 +19,2 @@ export * from "./DateTime";

export * from "./ScalarType";
export * from "./Mutate";

@@ -35,2 +35,3 @@ "use strict";

__exportStar(require("./ScalarType"), exports);
__exportStar(require("./Mutate"), exports);
//# sourceMappingURL=index.js.map

@@ -1,5 +0,6 @@

import { Promisify } from "@bunt/util";
import { MayNullable, Promisify } from "@bunt/util";
import { SuperType } from "../SuperType";
export declare class Nullable<TValue> extends SuperType<TValue | undefined, TValue> {
export declare class Nullable<TValue> extends SuperType<MayNullable<TValue>, Exclude<TValue, undefined | null>> {
readonly nullable = true;
validate(payload: unknown): Promisify<TValue | undefined>;
}

@@ -7,2 +7,6 @@ "use strict";

class Nullable extends SuperType_1.SuperType {
constructor() {
super(...arguments);
this.nullable = true;
}
validate(payload) {

@@ -9,0 +13,0 @@ if ((0, util_1.isNull)(payload) || (0, util_1.isUndefined)(payload)) {

import { Promisify } from "@bunt/util";
import { TypeAbstract } from "../TypeAbstract";
export declare type UnionSelector = (input: unknown) => TypeAbstract<unknown> | undefined;
import { IScalarType } from "./ScalarType";
export declare type UnionSelector<TValue> = (input: unknown) => TypeAbstract<TValue> | undefined;
export declare class Union<TValue> extends TypeAbstract<TValue> {
#private;
constructor(selector: UnionSelector, name?: string);
constructor(config: {
name?: string;
selector: IScalarType<TValue>;
});
constructor(selector: UnionSelector<TValue>);
get name(): string;
validate(input: unknown): Promisify<TValue>;
}

@@ -16,10 +16,18 @@ "use strict";

exports.Union = void 0;
const util_1 = require("@bunt/util");
const TypeAbstract_1 = require("../TypeAbstract");
class Union extends TypeAbstract_1.TypeAbstract {
constructor(selector, name = "Union") {
constructor(...args) {
super();
_Union_selector.set(this, void 0);
_Union_name.set(this, void 0);
__classPrivateFieldSet(this, _Union_selector, selector, "f");
__classPrivateFieldSet(this, _Union_name, name, "f");
const [arg1, arg2] = args;
if ((0, util_1.isObject)(arg1)) {
__classPrivateFieldSet(this, _Union_selector, arg1.selector, "f");
__classPrivateFieldSet(this, _Union_name, arg1.name ?? "Union", "f");
}
else {
__classPrivateFieldSet(this, _Union_selector, arg1, "f");
__classPrivateFieldSet(this, _Union_name, arg2, "f");
}
}

@@ -31,3 +39,3 @@ get name() {

const type = __classPrivateFieldGet(this, _Union_selector, "f").call(this, input);
this.assert(!!type, `${this.name} detection was failed`, input);
this.assert(!!type, `${this.name} type detection failed`, input);
return type.validate(input);

@@ -34,0 +42,0 @@ }

{
"name": "@bunt/input",
"version": "0.24.24",
"version": "0.24.25",
"keywords": [

@@ -29,6 +29,6 @@ "typescript"

"dependencies": {
"@bunt/util": "^0.24.20"
"@bunt/util": "^0.24.25"
},
"license": "MIT",
"gitHead": "7a559c0f0626dc613f3470f0172c3f3d6c064471"
"gitHead": "da3211786dca4ca020e2bdf17a2f20080ee6f2df"
}

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