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.3 to 0.0.4

74

dist/main.d.ts

@@ -26,3 +26,3 @@ declare class InternalArktypeError extends Error {

type join<segments extends string[], delimiter extends string, result extends string = ""> = segments extends [infer head extends string, ...infer tail extends string[]] ? join<tail, delimiter, result extends "" ? head : `${result}${delimiter}${head}`> : result;
type split<s extends string, delimiter extends string, result extends string[] = []> = s extends `${infer head}${delimiter}${infer tail}` ? split<tail, delimiter, [...result, head]> : [...result, s];
type split<s extends string, delimiter extends string, current extends string = "", result extends string[] = []> = s extends `${infer head}${infer tail}` ? head extends delimiter ? split<tail, delimiter, "", [...result, current]> : split<tail, delimiter, `${current}${head}`, result> : [...result, s];
declare const getPath: (root: unknown, path: string[]) => unknown;

@@ -59,3 +59,2 @@ declare const intersectUniqueLists: <item>(l: readonly item[], r: readonly item[]) => item[];

} & unknown;
type overlaps<l, r> = [l & r] extends [never] ? false : true;
type exact<t extends object, u extends object> = {

@@ -180,3 +179,2 @@ [k in keyof t]: k extends keyof u ? t[k] : never;

readonly Set: SetConstructor;
readonly Object: ObjectConstructor;
readonly String: StringConstructor;

@@ -195,6 +193,7 @@ readonly Number: NumberConstructor;

};
type objectKindOf<data, kinds extends ObjectKindSet = BuiltinObjectConstructors> = unknown extends data ? undefined | keyof kinds : data extends object ? object extends data ? keyof kinds : {
[kind in keyof kinds]: kinds[kind] extends Constructor<data> ? kind : data extends (...args: never[]) => unknown ? "Function" : "Object";
}[keyof kinds] : undefined;
declare const objectKindOf: <data, kinds extends ObjectKindSet = {
type instantiableObjectKind<data extends object, kinds extends ObjectKindSet> = {
[kind in keyof kinds]: kinds[kind] extends Constructor<data> ? kind : never;
}[keyof kinds];
type objectKindOf<data extends object, kinds extends ObjectKindSet = BuiltinObjectConstructors> = object extends data ? keyof kinds | undefined : data extends Fn ? "Function" : instantiableObjectKind<data, kinds> extends never ? keyof kinds | undefined : instantiableObjectKind<data, kinds>;
declare const objectKindOf: <data extends object, kinds extends ObjectKindSet = {
readonly Array: ArrayConstructor;

@@ -207,3 +206,2 @@ readonly Date: DateConstructor;

readonly Set: SetConstructor;
readonly Object: ObjectConstructor;
readonly String: StringConstructor;

@@ -216,2 +214,18 @@ readonly Number: NumberConstructor;

}>(data: data, kinds?: kinds | undefined) => objectKindOf<data, kinds> | undefined;
declare const objectKindOrDomainOf: <data, kinds extends ObjectKindSet = {
readonly Array: ArrayConstructor;
readonly Date: DateConstructor;
readonly Error: ErrorConstructor;
readonly Function: FunctionConstructor;
readonly Map: MapConstructor;
readonly RegExp: RegExpConstructor;
readonly Set: SetConstructor;
readonly String: StringConstructor;
readonly Number: NumberConstructor;
readonly Boolean: BooleanConstructor;
readonly WeakMap: WeakMapConstructor;
readonly WeakSet: WeakSetConstructor;
readonly Promise: PromiseConstructor;
}>(data: data, kinds?: kinds | undefined) => (objectKindOf<data & object, kinds> & {}) | domainOf<data>;
type objectKindOrDomainOf<data, kinds extends ObjectKindSet = BuiltinObjectConstructors> = data extends object ? objectKindOf<data, kinds> extends undefined ? "object" : objectKindOf<data, kinds> : domainOf<data>;
declare const hasObjectKind: <kind extends keyof kinds, kinds extends ObjectKindSet = {

@@ -225,3 +239,2 @@ readonly Array: ArrayConstructor;

readonly Set: SetConstructor;
readonly Object: ObjectConstructor;
readonly String: StringConstructor;

@@ -233,7 +246,6 @@ readonly Number: NumberConstructor;

readonly Promise: PromiseConstructor;
}>(data: unknown, kind: kind, kinds?: kinds | undefined) => data is InstanceType<kinds[kind]>;
}>(data: object, kind: kind, kinds?: kinds | undefined) => data is InstanceType<kinds[kind]>;
declare const isArray: (data: unknown) => data is readonly unknown[];
/** Each defaultObjectKind's completion for the phrase "Must be _____" */
declare const objectKindDescriptions: {
readonly Object: "an object";
readonly Array: "an array";

@@ -254,9 +266,8 @@ readonly Function: "a function";

declare const getExactBuiltinConstructorName: (constructor: unknown) => BuiltinObjectKind | undefined;
type Constructor<instance = {}> = new (...args: never[]) => instance;
type AbstractableConstructor<instance = {}> = abstract new (...args: never[]) => instance;
type instanceOf<constructor> = constructor extends AbstractableConstructor<infer instance> ? instance : never;
type Constructor<instance = {}> = abstract new (...args: never[]) => instance;
type instanceOf<constructor> = constructor extends Constructor<infer instance> ? instance : never;
/** Mimics output of TS's keyof operator at runtime */
declare const prototypeKeysOf: <t>(value: t) => (keyof t)[];
declare const getBaseDomainKeys: <domain extends Domain>(domain: domain) => Record<Domain, readonly PropertyKey[]>[domain][number][];
declare const constructorExtends: (constructor: AbstractableConstructor, base: AbstractableConstructor) => boolean;
declare const constructorExtends: (constructor: Constructor, base: Constructor) => boolean;

@@ -285,5 +296,7 @@ type Dict<k extends string = string, v = unknown> = {

};
type mutable<o> = {
-readonly [k in keyof o]: o[k];
};
type mutable<o, maxDepth extends number = 1> = mutableRecurse<o, [
], maxDepth>;
type mutableRecurse<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends object ? o extends Fn ? o : {
-readonly [k in keyof o]: mutableRecurse<o[k], [...depth, 1], maxDepth>;
} : o;
type entryOf<o> = {

@@ -298,7 +311,7 @@ [k in keyof o]-?: [k, o[k] & ({} | null)];

];
type fromEntries<entries extends readonly Entry[]> = {
type fromEntries<entries extends readonly Entry[]> = evaluate<{
[entry in entries[number] as entry[0]]: entry[1];
};
declare const fromEntries: <const entries extends readonly Entry<PropertyKey, unknown>[]>(entries: entries) => fromEntries<entries>;
declare const transform: <const o extends object, transformed extends Entry<PropertyKey, unknown> | readonly Entry<PropertyKey, unknown>[]>(o: o, flatMapEntry: (entry: { [k in keyof o]-?: [k, o[k] & ({} | null)]; }[o extends readonly unknown[] ? keyof o & number : keyof o]) => transformed) => intersectUnion<fromEntries<transformed extends readonly Entry<PropertyKey, unknown>[] ? transformed : [transformed]>> extends infer T ? { [k_1 in keyof T]: intersectUnion<fromEntries<transformed extends readonly Entry<PropertyKey, unknown>[] ? transformed : [transformed]>>[k_1]; } : never;
}>;
declare const fromEntries: <const entries extends readonly Entry<PropertyKey, unknown>[]>(entries: entries) => { [entry in entries[number] as entry[0]]: entry[1]; } extends infer T ? { [k in keyof T]: { [entry in entries[number] as entry[0]]: entry[1]; }[k]; } : never;
declare const transform: <const o extends object, transformed extends Entry<PropertyKey, unknown> | readonly Entry<PropertyKey, unknown>[]>(o: o, flatMapEntry: (entry: { [k in keyof o]-?: [k, o[k] & ({} | null)]; }[o extends readonly unknown[] ? keyof o & number : keyof o]) => transformed) => intersectUnion<{ [entry in (transformed extends readonly Entry<PropertyKey, unknown>[] ? transformed : [transformed])[number] as entry[0]]: entry[1]; } extends infer T_1 ? { [k_2 in keyof T_1]: { [entry in (transformed extends readonly Entry<PropertyKey, unknown>[] ? transformed : [transformed])[number] as entry[0]]: entry[1]; }[k_2]; } : never> extends infer T ? { [k_1 in keyof T]: intersectUnion<{ [entry in (transformed extends readonly Entry<PropertyKey, unknown>[] ? transformed : [transformed])[number] as entry[0]]: entry[1]; } extends infer T_1 ? { [k_2 in keyof T_1]: { [entry in (transformed extends readonly Entry<PropertyKey, unknown>[] ? transformed : [transformed])[number] as entry[0]]: entry[1]; }[k_2]; } : never>[k_1]; } : never;
/** Mimics the result of Object.keys(...) */

@@ -321,2 +334,6 @@ type keysOf<o> = o extends readonly unknown[] ? number extends o["length"] ? `${number}` : keyof o & `${number}` : {

}>;
type replaceKey<o, k extends keyof o, v> = evaluate<Omit<o, k> & {
[_ in k]: v;
}>;
type valueOf<o> = o[keyof o];
declare const ShallowClone: new <t extends object>(base: t) => t;

@@ -337,3 +354,3 @@ declare class DynamicBase<t extends object> extends ShallowClone<t> {

type Json = {
[k: string]: JsonData;
[k: string | number]: JsonData;
} | readonly JsonData[];

@@ -424,2 +441,5 @@ type JsonData = string | boolean | number | null | Json;

} : never;
type isDisjoint<l, r> = l & r extends never ? true : domainOf<l> & domainOf<r> extends never ? true : [l, r] extends [object, object] ? true extends valueOf<{
[k in Extract<keyof l & keyof r, requiredKeyOf<l> | requiredKeyOf<r>>]: isDisjoint<l[k], r[k]>;
}> ? true : false : false;

@@ -443,7 +463,7 @@ type applyElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = labels extends [unknown, ...infer labelsTail] ? t extends readonly [infer head, ...infer tail] ? readonly [

type ComposeSignatures = {
<traits extends NonEmptyList<AbstractableConstructor>>(...traits: traits): compose<traits>;
<labels extends 1[]>(): <traits extends NonEmptyList<AbstractableConstructor>>(...traits: traits) => compose<traits, labels>;
<traits extends NonEmptyList<Constructor>>(...traits: traits): compose<traits>;
<labels extends 1[]>(): <traits extends NonEmptyList<Constructor>>(...traits: traits) => compose<traits, labels>;
};
declare const compose: ComposeSignatures;
type compose<traits extends readonly AbstractableConstructor[], labels extends 1[] = []> = composeRecurse<traits, [], {}, labels>;
type compose<traits extends readonly Constructor[], labels extends 1[] = []> = composeRecurse<traits, [], {}, labels>;
type composeRecurse<traits extends readonly unknown[], parameters extends readonly unknown[], instance extends {}, labels extends 1[]> = traits extends readonly [

@@ -454,2 +474,2 @@ abstract new (...args: infer nextArgs) => infer nextInstance,

export { AbstractableConstructor, AndPreserveUnknown, BigintLiteral, BuiltinObjectConstructors, BuiltinObjectKind, BuiltinObjects, CastableBase, CollapsingList, CompiledFunction, Completion, ComposeSignatures, Constructor, Dict, Digit, Domain, DynamicBase, ErrorMessage, Fn, Hkt, IntegerLiteral, InternalArktypeError, Json, JsonData, List, NonEmptyList, NonNullishDomain, NullishDomain, NumberLiteral, NumericParseOptions, ObjectKindSet, ParseError, PartialRecord, Primitive, PrimitiveDomain, ReadonlyArray, SerializablePrimitive, SerializationOptions, SerializedPrimitive, SerializedPrimitives, Stringifiable, Thunk, ZeroWidthSpace, and, andPreserveUnknown, arraySubclassToReadonly, autocomplete, builtinObjectKinds, cached, compose, composeRecurse, conform, constructorExtends, defer, defined, domainOf, entriesOf, entryOf, equals, evaluate, exact, exactMessageOnError, extend, fromEntries, getBaseDomainKeys, getExactBuiltinConstructorName, getPath, hasDomain, hasObjectKind, id, includes, inferDomain, instanceOf, intersectArrays, intersectParameters, intersectUnion, intersectUniqueLists, isAny, isArray, isKeyOf, isNever, isThunk, isUnknown, isWellFormedInteger, isWellFormedNumber, join, keySet, keysOf, lazily, listFrom, listable, merge, mergeAll, mutable, nominal, objectKindDescriptions, objectKindOf, optionalKeyOf, optionalizeKeys, overlaps, overloadOf, paramsOf, pathToString, print, propwiseXor, prototypeKeysOf, requireKeys, requiredKeyOf, returnOf, satisfy, serializePrimitive, shallowClone, snapshot, split, spliterate, stringify, stringifyUnion, throwInternalError, throwParseError, thunkable, transform, tryParseInteger, tryParseNumber, tryParseWellFormedBigint, unionToTuple, wellFormedIntegerMatcher, wellFormedNumberMatcher, widen, writeMalformedNumericLiteralMessage };
export { AndPreserveUnknown, BigintLiteral, BuiltinObjectConstructors, BuiltinObjectKind, BuiltinObjects, CastableBase, CollapsingList, CompiledFunction, Completion, ComposeSignatures, Constructor, Dict, Digit, Domain, DynamicBase, ErrorMessage, Fn, Hkt, IntegerLiteral, InternalArktypeError, Json, JsonData, List, NonEmptyList, NonNullishDomain, NullishDomain, NumberLiteral, NumericParseOptions, ObjectKindSet, ParseError, PartialRecord, Primitive, PrimitiveDomain, ReadonlyArray, SerializablePrimitive, SerializationOptions, SerializedPrimitive, SerializedPrimitives, Stringifiable, Thunk, ZeroWidthSpace, and, andPreserveUnknown, arraySubclassToReadonly, autocomplete, builtinObjectKinds, cached, compose, composeRecurse, conform, constructorExtends, defer, defined, domainOf, entriesOf, entryOf, equals, evaluate, exact, exactMessageOnError, extend, fromEntries, getBaseDomainKeys, getExactBuiltinConstructorName, getPath, hasDomain, hasObjectKind, id, includes, inferDomain, instanceOf, intersectArrays, intersectParameters, intersectUnion, intersectUniqueLists, isAny, isArray, isDisjoint, isKeyOf, isNever, isThunk, isUnknown, isWellFormedInteger, isWellFormedNumber, join, keySet, keysOf, lazily, listFrom, listable, merge, mergeAll, mutable, nominal, objectKindDescriptions, objectKindOf, objectKindOrDomainOf, optionalKeyOf, optionalizeKeys, overloadOf, paramsOf, pathToString, print, propwiseXor, prototypeKeysOf, replaceKey, requireKeys, requiredKeyOf, returnOf, satisfy, serializePrimitive, shallowClone, snapshot, split, spliterate, stringify, stringifyUnion, throwInternalError, throwParseError, thunkable, transform, tryParseInteger, tryParseNumber, tryParseWellFormedBigint, unionToTuple, valueOf, wellFormedIntegerMatcher, wellFormedNumberMatcher, widen, writeMalformedNumericLiteralMessage };

@@ -181,3 +181,2 @@ // domain.ts

Set,
Object,
String,

@@ -191,5 +190,2 @@ Number,

var objectKindOf = (data, kinds) => {
if (domainOf(data) !== "object") {
return void 0;
}
const kindSet = kinds ?? builtinObjectKinds;

@@ -200,8 +196,12 @@ let prototype = Object.getPrototypeOf(data);

}
return prototype?.constructor?.name;
const name = prototype?.constructor?.name;
if (name === void 0 || name === "Object") {
return void 0;
}
return name;
};
var objectKindOrDomainOf = (data, kinds) => typeof data === "object" && data !== null ? objectKindOf(data, kinds) ?? "object" : domainOf(data);
var hasObjectKind = (data, kind, kinds) => objectKindOf(data, kinds) === kind;
var isArray = (data) => Array.isArray(data);
var objectKindDescriptions = {
Object: "an object",
Array: "an array",

@@ -396,2 +396,3 @@ Function: "a function",

objectKindOf,
objectKindOrDomainOf,
print,

@@ -398,0 +399,0 @@ prototypeKeysOf,

{
"name": "@arktype/util",
"version": "0.0.3",
"version": "0.0.4",
"author": {

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

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