Socket
Socket
Sign inDemoInstall

@arktype/util

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arktype/util - npm Package Compare versions

Comparing version 0.0.24 to 0.0.25

out/describe.d.ts

16

generics.ts

@@ -0,1 +1,2 @@

import type { Primitive } from "./domain.js"
import type { ErrorMessage } from "./errors.js"

@@ -100,1 +101,16 @@ import type { unionToTuple } from "./unionToTuple.js"

: result
type narrowTuple<t extends readonly unknown[]> = t extends readonly [
infer head,
...infer tail
]
? [head, ...narrowTuple<tail>]
: []
export type narrow<t> = t extends Primitive
? t
: t extends readonly unknown[]
? narrowTuple<t>
: { [k in keyof t]: narrow<t[k]> }
export const narrow = <t>(t: narrow<t>) => t
import type { evaluate } from "./generics.js";
import type { stringifyUnion } from "./unionToTuple.js";
export declare const hasDomain: <data, domain extends Domain>(data: data, kind: domain) => data is data & inferDomain<domain>;

@@ -21,3 +22,24 @@ type TypesByDomain = {

export declare const domainOf: <data>(data: data) => domainOf<data>;
declare const nonEnumerableDomainDescriptions: {
readonly bigint: "a bigint";
readonly number: "a number";
readonly object: "an object";
readonly string: "a string";
readonly symbol: "a symbol";
};
export type NonEnumerableDomain = keyof typeof nonEnumerableDomainDescriptions;
/** Each domain's completion for the phrase "Must be _____" */
export declare const domainDescriptions: {
boolean: "boolean";
null: "null";
undefined: "undefined";
bigint: "a bigint";
number: "a number";
object: "an object";
string: "a string";
symbol: "a symbol";
};
export type domainDescriptions = typeof domainDescriptions;
export type describeDomainOf<t> = stringifyUnion<domainDescriptions[domainOf<t>], " or ">;
export {};
//# sourceMappingURL=domain.d.ts.map

@@ -12,2 +12,19 @@ export const hasDomain = (data, kind) => domainOf(data) === kind;

};
const enumerableDomainDescriptions = {
boolean: "boolean",
null: "null",
undefined: "undefined"
};
const nonEnumerableDomainDescriptions = {
bigint: "a bigint",
number: "a number",
object: "an object",
string: "a string",
symbol: "a symbol"
};
/** Each domain's completion for the phrase "Must be _____" */
export const domainDescriptions = {
...nonEnumerableDomainDescriptions,
...enumerableDomainDescriptions
};
//# sourceMappingURL=domain.js.map

@@ -0,1 +1,2 @@

import type { Primitive } from "./domain.js";
import type { ErrorMessage } from "./errors.js";

@@ -42,3 +43,11 @@ import type { unionToTuple } from "./unionToTuple.js";

type collectWidenedType<t, remaining extends unknown[], result = never> = remaining extends [infer head, ...infer tail] ? collectWidenedType<t, tail, t extends head ? result | head : result> : result;
type narrowTuple<t extends readonly unknown[]> = t extends readonly [
infer head,
...infer tail
] ? [head, ...narrowTuple<tail>] : [];
export type narrow<t> = t extends Primitive ? t : t extends readonly unknown[] ? narrowTuple<t> : {
[k in keyof t]: narrow<t[k]>;
};
export declare const narrow: <t>(t: narrow<t>) => narrow<t>;
export {};
//# sourceMappingURL=generics.d.ts.map

1

out/generics.js
export const id = Symbol("id");
export const narrow = (t) => t;
//# sourceMappingURL=generics.js.map
export * from "./compilation.js";
export * from "./describe.js";
export * from "./domain.js";

@@ -3,0 +4,0 @@ export * from "./errors.js";

export * from "./compilation.js";
export * from "./describe.js";
export * from "./domain.js";

@@ -3,0 +4,0 @@ export * from "./errors.js";

8

out/objectKinds.d.ts

@@ -1,2 +0,2 @@

import { domainOf, type Domain } from "./domain.js";
import { domainOf, type Domain, type domainDescriptions } from "./domain.js";
import type { evaluate } from "./generics.js";

@@ -25,5 +25,6 @@ import type { List } from "./lists.js";

};
export type objectKindOf<data extends object, kinds extends ObjectKindSet = BuiltinObjectConstructors> = object extends data ? keyof kinds | undefined : data extends (...args: any[]) => unknown ? "Function" : instantiableObjectKind<data, kinds> extends never ? keyof kinds | undefined : instantiableObjectKind<data, kinds>;
export type objectKindOf<data extends object, kinds extends ObjectKindSet = BuiltinObjectConstructors> = object extends data ? keyof kinds | undefined : data extends (...args: never[]) => unknown ? "Function" : instantiableObjectKind<data, kinds> extends never ? keyof kinds | undefined : instantiableObjectKind<data, kinds>;
export type describeObject<o extends object> = objectKindOf<o> extends string ? objectKindDescriptions[objectKindOf<o>] : domainDescriptions["object"];
type instantiableObjectKind<data extends object, kinds extends ObjectKindSet> = {
[kind in keyof kinds]: kinds[kind] extends Constructor<data> ? kind : never;
[kind in keyof kinds]: data extends InstanceType<kinds[kind]> ? kind : never;
}[keyof kinds];

@@ -93,2 +94,3 @@ export declare const objectKindOf: <data extends object, kinds extends ObjectKindSet = {

};
export type objectKindDescriptions = typeof objectKindDescriptions;
export declare const getExactBuiltinConstructorName: (constructor: unknown) => BuiltinObjectKind | undefined;

@@ -95,0 +97,0 @@ export type Constructor<instance = {}> = abstract new (...args: never[]) => instance;

import type { conform } from "./generics.js";
import type { List, join } from "./lists.js";
export type stringifyUnion<t extends string> = join<unionToTuple<t>, ", ">;
export type stringifyUnion<t extends string, delimiter extends string = ", "> = join<unionToTuple<t>, delimiter>;
export type unionToTuple<t> = unionToTupleRecurse<t, []> extends infer result ? conform<result, t[]> : never;

@@ -5,0 +5,0 @@ type unionToTupleRecurse<t, result extends unknown[]> = getLastBranch<t> extends infer current ? [t] extends [never] ? result : unionToTupleRecurse<Exclude<t, current>, [current, ...result]> : never;

{
"name": "@arktype/util",
"version": "0.0.24",
"version": "0.0.25",
"author": {

@@ -5,0 +5,0 @@ "name": "David Blass",

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