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

@starbeam/verify

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@starbeam/verify - npm Package Compare versions

Comparing version 0.8.10-unstable.6ff9a7b to 0.8.10-unstable.7ee43a9

4

package.json
{
"name": "@starbeam/verify",
"version": "0.8.10-unstable.6ff9a7b",
"version": "0.8.10-unstable.7ee43a9",
"type": "module",

@@ -28,3 +28,3 @@ "main": "index.ts",

"dependencies": {
"@starbeam/core-utils": "0.8.10-unstable.6ff9a7b"
"@starbeam/core-utils": "0.8.10-unstable.7ee43a9"
},

@@ -31,0 +31,0 @@ "devDependencies": {

export function format(value: unknown): string {
/* eslint-disable */
switch (typeof value) {

@@ -18,5 +17,5 @@ case "boolean":

return `{class ${value.name}}`;
} else if (fn.match(/^function\s*[*]/)) {
} else if (/^function\s*[*]/.exec(fn)) {
return `{function* ${value.name}}`;
} else if (fn.match(/^async\s+function/)) {
} else if (/^async\s+function/.exec(fn)) {
return `{async function ${value.name}}`;

@@ -34,2 +33,3 @@ } else if (value.name) {

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const proto = Object.getPrototypeOf(value);

@@ -49,3 +49,2 @@

}
/* eslint-enable */
}
export class VerificationError<T = unknown> extends Error {
constructor(message: string, readonly expectation: Expectation<T>) {
constructor(
message: string,
readonly expectation: Expectation<T>,
) {
super(message);

@@ -12,3 +15,3 @@ }

check: (input: Input) => input is Output,
error?: Expectation<Value>
error?: Expectation<Value>,
): asserts value is Output & Value;

@@ -18,3 +21,3 @@ export function verify<Value, Narrow extends Value>(

check: (input: Value) => input is Narrow,
error?: Expectation<Value>
error?: Expectation<Value>,
): asserts value is Narrow;

@@ -24,3 +27,3 @@ export function verify(

check: (input: unknown) => boolean,
error?: Expectation<unknown>
error?: Expectation<unknown>,
): void {

@@ -35,3 +38,3 @@ if (!check(value)) {

`Assumption was incorrect: ${name}`,
expected()
expected(),
);

@@ -57,3 +60,3 @@ } else {

check: (input: T) => input is U,
error?: Expectation<T>
error?: Expectation<T>,
): U {

@@ -67,3 +70,3 @@ verify(value, check, error);

_check: (input: T) => input is U,
_error?: Expectation<T>
_error?: Expectation<T>,
): U => {

@@ -81,3 +84,3 @@ return value as U;

associated: Expectation<In> | undefined,
specified: Expectation<In> | undefined
specified: Expectation<In> | undefined,
): Expectation<In> | undefined {

@@ -100,3 +103,3 @@ if (!associated && !specified) {

specified.#actual ?? associated.#actual,
specified.#when ?? associated.#when
specified.#when ?? associated.#when,
);

@@ -114,3 +117,3 @@ }

got: ((input: In) => string | undefined) | undefined,
when: string | undefined
when: string | undefined,
) {

@@ -144,3 +147,3 @@ this.#description = description;

actual,
updater.when ? updater.when(this.#when) : this.#when
updater.when ? updater.when(this.#when) : this.#when,
);

@@ -154,3 +157,3 @@ }

this.#actual,
this.#when
this.#when,
);

@@ -164,3 +167,3 @@ }

this.#actual,
this.#when
this.#when,
);

@@ -170,3 +173,3 @@ }

butGot<NewIn extends In>(
kind: string | ((value: NewIn) => string)
kind: string | ((value: NewIn) => string),
): Expectation<NewIn> {

@@ -177,3 +180,3 @@ return new Expectation(

typeof kind === "string" ? () => kind : kind,
this.#when
this.#when,
);

@@ -187,3 +190,3 @@ }

this.#actual,
situation
situation,
);

@@ -241,12 +244,15 @@ }

expected.butGot = <In>(
kind: string | ((input: In) => string)
kind: string | ((input: In) => string),
): Expectation<In> => expected().butGot(kind);
// eslint-disable-next-line
const ASSOCIATED: WeakMap<Function, Expectation<any>> = new WeakMap();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyFn = (...args: any[]) => any;
// eslint-disable-next-line @typescript-eslint/consistent-generic-constructors
const ASSOCIATED: WeakMap<AnyFn, Expectation> = new WeakMap();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expected.associate = <Check extends (input: In) => any, In>(
check: Check,
expectation: Expectation<In>
expectation: Expectation<In>,
): Check extends infer C ? C : never => {

@@ -261,3 +267,3 @@ ASSOCIATED.set(check, expectation);

actual?: (
actual: ((input: In) => string | undefined) | undefined
actual: ((input: In) => string | undefined) | undefined,
) => ((input: NewIn) => string | undefined) | undefined;

@@ -269,3 +275,3 @@ when?: (when: string | undefined) => string | undefined;

check: (input: In) => boolean,
updater: Updater<In, NewIn>
updater: Updater<In, NewIn>,
): Expectation<NewIn> => {

@@ -272,0 +278,0 @@ const expectation = ASSOCIATED.get(check) ?? expected();

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