New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

arktype

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arktype - npm Package Compare versions

Comparing version 1.0.5-alpha to 1.0.6-alpha

3

dist/cjs/nodes/discriminate.js

@@ -246,3 +246,4 @@ "use strict";

case "class":
return typeof definition === "string" ? definition : undefined;
const constructorName = Object(definition).name;
return constructorName && (0, _genericsTs.isKeyOf)(constructorName, _objectKindsTs.defaultObjectKinds) && _objectKindsTs.defaultObjectKinds[constructorName] === definition ? constructorName : undefined;
default:

@@ -249,0 +250,0 @@ return;

@@ -134,3 +134,3 @@ "use strict";

object: {
class: "Array",
class: Array,
props: {

@@ -137,0 +137,0 @@ [_propsTs.mappedKeys.index]: node

@@ -18,5 +18,3 @@ "use strict";

const classIntersection = (0, _composeTs.composeIntersection)((l, r, state)=>{
const lClass = typeof l === "string" ? _objectKindsTs.defaultObjectKinds[l] : l;
const rClass = typeof r === "string" ? _objectKindsTs.defaultObjectKinds[r] : r;
return lClass === rClass ? (0, _composeTs.equality)() : lClass instanceof rClass ? l : rClass instanceof lClass ? r : state.addDisjoint("class", l, r);
return l === r ? (0, _composeTs.equality)() : l instanceof r ? l : r instanceof l ? r : state.addDisjoint("class", l, r);
});

@@ -23,0 +21,0 @@ const checkClass = (expectedClass, state)=>{

@@ -51,3 +51,3 @@ "use strict";

object: {
class: "Array",
class: Array,
props

@@ -54,0 +54,0 @@ }

@@ -74,3 +74,3 @@ "use strict";

}
return (0, _genericsTs.listFrom)(resolution.object).every((branch)=>"class" in branch && branch.class === "Array");
return (0, _genericsTs.listFrom)(resolution.object).every((branch)=>"class" in branch && branch.class === Array);
default:

@@ -77,0 +77,0 @@ return false;

@@ -21,3 +21,3 @@ "use strict";

object: {
class: "Function"
class: Function
}

@@ -30,3 +30,3 @@ }

object: {
class: "Array"
class: Array
}

@@ -39,3 +39,3 @@ }

object: {
class: "Date"
class: Date
}

@@ -48,3 +48,3 @@ }

object: {
class: "Error"
class: Error
}

@@ -57,3 +57,3 @@ }

object: {
class: "Map"
class: Map
}

@@ -66,3 +66,3 @@ }

object: {
class: "RegExp"
class: RegExp
}

@@ -75,3 +75,3 @@ }

object: {
class: "Set"
class: Set
}

@@ -84,3 +84,3 @@ }

object: {
class: "Object"
class: Object
}

@@ -93,3 +93,3 @@ }

object: {
class: "String"
class: String
}

@@ -102,3 +102,3 @@ }

object: {
class: "Number"
class: Number
}

@@ -111,3 +111,3 @@ }

object: {
class: "Boolean"
class: Boolean
}

@@ -120,3 +120,3 @@ }

object: {
class: "WeakMap"
class: WeakMap
}

@@ -129,3 +129,3 @@ }

object: {
class: "WeakSet"
class: WeakSet
}

@@ -138,3 +138,3 @@ }

object: {
class: "Promise"
class: Promise
}

@@ -141,0 +141,0 @@ }

@@ -5,3 +5,3 @@ import { writeUndiscriminatableMorphUnionMessage } from "../parse/ast/union.js";

import { isKeyOf, keyCount, objectKeysOf } from "../utils/generics.js";
import { isArray, objectKindOf } from "../utils/objectKinds.js";
import { defaultObjectKinds, isArray, objectKindOf } from "../utils/objectKinds.js";
import { Path } from "../utils/paths.js";

@@ -232,3 +232,4 @@ import { serializePrimitive } from "../utils/serialize.js";

case "class":
return typeof definition === "string" ? definition : undefined;
const constructorName = Object(definition).name;
return constructorName && isKeyOf(constructorName, defaultObjectKinds) && defaultObjectKinds[constructorName] === definition ? constructorName : undefined;
default:

@@ -235,0 +236,0 @@ return;

@@ -112,3 +112,3 @@ import { compileDisjointReasonsMessage } from "../parse/ast/intersection.js";

object: {
class: "Array",
class: Array,
props: {

@@ -115,0 +115,0 @@ [mappedKeys.index]: node

@@ -1,7 +0,5 @@

import { defaultObjectKinds, objectKindOf } from "../../utils/objectKinds.js";
import { objectKindOf } from "../../utils/objectKinds.js";
import { composeIntersection, equality } from "../compose.js";
export const classIntersection = composeIntersection((l, r, state)=>{
const lClass = typeof l === "string" ? defaultObjectKinds[l] : l;
const rClass = typeof r === "string" ? defaultObjectKinds[r] : r;
return lClass === rClass ? equality() : lClass instanceof rClass ? l : rClass instanceof lClass ? r : state.addDisjoint("class", l, r);
return l === r ? equality() : l instanceof r ? l : r instanceof l ? r : state.addDisjoint("class", l, r);
});

@@ -8,0 +6,0 @@ export const checkClass = (expectedClass, state)=>{

@@ -37,3 +37,3 @@ import { rootIntersection, rootUnion, toArrayNode } from "../../nodes/node.js";

object: {
class: "Array",
class: Array,
props

@@ -40,0 +40,0 @@ }

@@ -57,3 +57,3 @@ import { stringifyRange } from "../../../../nodes/compose.js";

}
return listFrom(resolution.object).every((branch)=>"class" in branch && branch.class === "Array");
return listFrom(resolution.object).every((branch)=>"class" in branch && branch.class === Array);
default:

@@ -60,0 +60,0 @@ return false;

@@ -7,3 +7,3 @@ import { scope } from "./scope.js";

object: {
class: "Function"
class: Function
}

@@ -16,3 +16,3 @@ }

object: {
class: "Array"
class: Array
}

@@ -25,3 +25,3 @@ }

object: {
class: "Date"
class: Date
}

@@ -34,3 +34,3 @@ }

object: {
class: "Error"
class: Error
}

@@ -43,3 +43,3 @@ }

object: {
class: "Map"
class: Map
}

@@ -52,3 +52,3 @@ }

object: {
class: "RegExp"
class: RegExp
}

@@ -61,3 +61,3 @@ }

object: {
class: "Set"
class: Set
}

@@ -70,3 +70,3 @@ }

object: {
class: "Object"
class: Object
}

@@ -79,3 +79,3 @@ }

object: {
class: "String"
class: String
}

@@ -88,3 +88,3 @@ }

object: {
class: "Number"
class: Number
}

@@ -97,3 +97,3 @@ }

object: {
class: "Boolean"
class: Boolean
}

@@ -106,3 +106,3 @@ }

object: {
class: "WeakMap"
class: WeakMap
}

@@ -115,3 +115,3 @@ }

object: {
class: "WeakSet"
class: WeakSet
}

@@ -124,3 +124,3 @@ }

object: {
class: "Promise"
class: Promise
}

@@ -127,0 +127,0 @@ }

import type { EntryChecker } from "../../traverse/traverse.js";
import type { constructor } from "../../utils/generics.js";
export declare const classIntersection: import("../compose.js").Intersector<constructor | "Array" | "Date" | "Error" | "Function" | "Map" | "RegExp" | "Set" | "Object" | "String" | "Number" | "Boolean" | "WeakMap" | "WeakSet" | "Promise" | undefined>;
export declare const classIntersection: import("../compose.js").Intersector<constructor | undefined>;
export declare const checkClass: EntryChecker<"class">;
import type { Narrow } from "../../parse/ast/narrow.js";
import type { Domain, inferDomain } from "../../utils/domains.js";
import type { CollapsibleList, constructor, Dict } from "../../utils/generics.js";
import type { DefaultObjectKind } from "../../utils/objectKinds.js";
import type { IntersectionState, Intersector } from "../compose.js";

@@ -14,3 +13,3 @@ import type { FlattenContext, TraversalEntry, TraversalKey } from "../node.js";

readonly props?: PropsRule<$>;
readonly class?: DefaultObjectKind | constructor;
readonly class?: constructor;
readonly narrow?: NarrowRule;

@@ -23,3 +22,3 @@ };

export type FlatRules = RuleEntry[];
export type RuleEntry = ["regex", string] | ["divisor", number] | ["bound", FlatBound] | ["class", DefaultObjectKind | constructor] | DistilledPropsEntry | StrictPropsEntry | PropEntry | ["narrow", Narrow] | ["value", unknown];
export type RuleEntry = ["regex", string] | ["divisor", number] | ["bound", FlatBound] | ["class", constructor] | DistilledPropsEntry | StrictPropsEntry | PropEntry | ["narrow", Narrow] | ["value", unknown];
export type Rules<domain extends Domain = Domain, $ = Dict> = Domain extends domain ? NarrowableRules | LiteralRules : domain extends "object" ? defineRuleSet<domain, "props" | "range" | "narrow" | "class", $> : domain extends "string" ? defineRuleSet<domain, "regex" | "range" | "narrow", $> : domain extends "number" ? defineRuleSet<domain, "divisor" | "range" | "narrow", $> : defineRuleSet<domain, "narrow", $>;

@@ -26,0 +25,0 @@ type defineRuleSet<domain extends Domain, keys extends keyof NarrowableRules, $> = Pick<NarrowableRules<$>, keys> | LiteralRules<domain>;

@@ -8,3 +8,3 @@ import type { MetaBranch } from "../../nodes/branch.js";

import type { constructor, evaluate, evaluateObjectOrFunction, HomogenousTuple, List, returnOf } from "../../utils/generics.js";
import type { BuiltinClass, DefaultObjectKind, inferObjectKind } from "../../utils/objectKinds.js";
import type { BuiltinClass, inferObjectKind } from "../../utils/objectKinds.js";
import type { inferTerminal } from "./ast.js";

@@ -20,9 +20,6 @@ export type inferNode<node extends Node<$>, $ = {}> = node extends string ? inferTerminal<node, $> : node extends Node<$> ? inferResolution<node, $> extends infer result ? result extends BuiltinClass ? result : evaluateObjectOrFunction<result> : never : never;

type inferRules<domain extends Domain, branch, $> = branch extends LiteralRules ? branch["value"] : domain extends "object" ? branch extends NarrowableRules ? inferObjectRules<branch, $> : object : inferDomain<domain>;
type inferObjectRules<rules extends NarrowableRules, $> = rules["class"] extends DefaultObjectKind ? [rules["class"], rules["props"]] extends [
"Array",
{
"[index]": Prop<$, infer indexNode>;
length?: Prop<$, infer lengthNode>;
}
] ? lengthNode extends LiteralNode<"number", infer value> ? HomogenousTuple<inferNode<indexNode, $>, value> : inferNode<indexNode, $>[] : inferObjectKind<rules["class"]> : rules["class"] extends constructor<infer instance> ? instance : rules["props"] extends PropsRule ? inferProps<rules["props"], $> : object;
type inferObjectRules<rules extends NarrowableRules, $> = rules["class"] extends ArrayConstructor ? rules["props"] extends {
"[index]": Prop<$, infer indexNode>;
length?: Prop<$, infer lengthNode>;
} ? lengthNode extends LiteralNode<"number", infer value> ? HomogenousTuple<inferNode<indexNode, $>, value> : inferNode<indexNode, $>[] : unknown[] : rules["class"] extends FunctionConstructor ? inferObjectKind<"Function"> : rules["class"] extends constructor<infer instance> ? instance : rules["props"] extends PropsRule ? inferProps<rules["props"], $> : object;
type inferProps<props extends PropsRule, $> = evaluate<{

@@ -29,0 +26,0 @@ [k in requiredKeyOf<props>]: props[k] extends Prop<$, infer node> ? inferNode<node, $> : never;

@@ -26,5 +26,3 @@ import type { InferredObjectKinds } from "../utils/objectKinds.js";

Set: Set<unknown>;
Object: {
[x: string]: unknown;
};
Object: Record<string, unknown>;
String: String;

@@ -77,5 +75,3 @@ Number: Number;

Set: Set<unknown>;
Object: {
[x: string]: unknown;
};
Object: Record<string, unknown>;
String: String;

@@ -125,5 +121,3 @@ Number: Number;

Set: Set<unknown>;
Object: {
[x: string]: unknown;
};
Object: Record<string, unknown>;
String: String;

@@ -175,5 +169,3 @@ Number: Number;

Set: Set<unknown>;
Object: {
[x: string]: unknown;
};
Object: Record<string, unknown>;
String: String;

@@ -180,0 +172,0 @@ Number: Number;

@@ -9,5 +9,3 @@ export declare const jsObjectsScope: import("./scope.js").Scope<[{

Set: Set<unknown>;
Object: {
[x: string]: unknown;
};
Object: Record<string, unknown>;
String: String;

@@ -28,5 +26,3 @@ Number: Number;

Set: Set<unknown>;
Object: {
[x: string]: unknown;
};
Object: Record<string, unknown>;
String: String;

@@ -33,0 +29,0 @@ Number: Number;

{
"name": "arktype",
"description": "The first isomorphic type system for TS/JS",
"version": "1.0.5-alpha",
"version": "1.0.6-alpha",
"author": {

@@ -114,4 +114,4 @@ "name": "David Blass",

"ci:version": "ts-node ./dev/scripts/updateVersions.ts",
"ci:publish": "changeset publish"
"ci:publish": "pnpm publish"
}
}
<h1 align="center">ArkType <sub><sup>Isomorphic types for TS/JS</sup></sub></h1>
[<img src="./dev/arktype.io/static/img/arktype.gif">](https://arktype.io/try)
<sub><i>`typescript@4.9.5` in VS Codeβ€” no extensions or plugins required (<a href="#how">how?</a>)</i></sub>
<sub>
<i>`typescript@4.9.5` in VS Codeβ€” no extensions or plugins required (<a href="#how">how?</a>) (<a href="https://arktype.io/try">try in-browser</a>)</i>
</sub>
<br />
<img src="./dev/arktype.io/static/img/logo.svg" alt="ArkType Icon" height="16px"/><b> Try this demo in-browser at <a href="https://arktype.io/try">arktype.io/try</a></b>
<!-- @snipStart:intro -->
ArkType is a type-safe runtime validator that understands TypeScript syntax.
<br />
<br />
Each character you type is statically parsed so you'll know exactly what to expect from editor to runtime β›΅
<!-- @snipEnd -->
<!-- @snipStart:install -->

@@ -12,9 +22,8 @@

<img src="./dev/arktype.io/static/img/npm.svg" alt="Npm Icon" height="16px" />
<code>npm install arktype</code>
<img src="./dev/arktype.io/static/img/npm.svg" alt="Npm Icon" height="16px" /> <code>npm install arktype</code>
<sub>(or whatever package manager you prefer)</sub>
<br />
<img src="./dev/arktype.io/static/img/deno.svg" alt="Deno Icon" height="16px" />
<code>import type from "https://deno.land/x/arktype"</code>
<img src="./dev/arktype.io/static/img/deno.svg" alt="Deno Icon" height="16px" /> <code>import { type } from "https://deno.land/x/arktype/main.ts"</code>
Our types are tested in [strict-mode](https://www.typescriptlang.org/tsconfig#strict) with TypeScript versions `4.8`, `4.9`, and `5.0`.

@@ -168,3 +177,3 @@

Otherwise, consider sending me an email (david@arktype.io) letting me know you're a fan of ArkType. Either would make my day! 😊
Otherwise, consider sending me an email (david@arktype.io) or [message me on Discord](https://discord.gg/WSNF3Kc4xh) to let me know you're a fan of ArkType. Either would make my day! 😊

@@ -171,0 +180,0 @@ ## Collaboration

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