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

@tapjs/asserts

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tapjs/asserts - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

10

dist/commonjs/index.d.ts

@@ -20,7 +20,11 @@ /// <reference types="node" />

};
export type ErrorCauseMatch = {
cause: any;
export type ErrorCauseMatch<C extends {}> = {
cause: C;
[k: string]: any;
};
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch | RegExp;
export type ErrorErrorsMatch<C extends {}> = {
errors: C[];
[k: string]: any;
};
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch<{}> | ErrorErrorsMatch<{}> | RegExp;
export type ThrowsArgs = [] | [msg: string, extra?: Extra] | [wanted: ErrorMatch, ...messageExtra: MessageExtra];

@@ -27,0 +31,0 @@ export type ExpectedEmit = [

@@ -160,4 +160,4 @@ "use strict";

this.#t.currentAssert = this.#t.t.type;
const name = typeof klass === 'function'
? klass.name || '(anonymous constructor)'
const name = typeof klass === 'function' ?
klass.name || '(anonymous constructor)'
: klass;

@@ -171,11 +171,10 @@ const args = [msg, extra];

const tof = typeof obj;
const type = !obj && tof === 'object'
? 'null'
: // treat as object, but not Object
// t.type(() => {}, Function)
tof === 'function' &&
typeof klass === 'function' &&
klass !== Object
? 'object'
: tof;
const type = !obj && tof === 'object' ? 'null'
// treat as object, but not Object
// t.type(() => {}, Function)
: (tof === 'function' &&
typeof klass === 'function' &&
klass !== Object) ?
'object'
: tof;
if ((type === 'number' && klass === Number) ||

@@ -642,4 +641,4 @@ (type === 'string' && klass === String) ||

}
return ((w
? this.match(isRegExp(wanted) ? er.message : er, wanted, m, e)
return ((w ?
this.match(isRegExp(wanted) ? er.message : er, wanted, m, e)
: this.#t.pass(m, e)) && er);

@@ -665,4 +664,4 @@ }

// pull the errorOrigin from the thrown error, if possible
const res = er !== undefined && er !== null
? this.error(er, ...me)
const res = er !== undefined && er !== null ?
this.error(er, ...me)
: this.#t.fail(...me);

@@ -687,5 +686,3 @@ return (res && er) || res;

p =
typeof fnOrPromise === 'function'
? fnOrPromise()
: fnOrPromise;
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise);
}

@@ -714,4 +711,4 @@ catch (er) {

}
d.resolve((w
? this.match(isRegExp(w) ? er.message : er, w, m, e)
d.resolve((w ?
this.match(isRegExp(w) ? er.message : er, w, m, e)
: this.#t.pass(m, e)) &&

@@ -737,5 +734,3 @@ (er || true));

p =
typeof fnOrPromise === 'function'
? fnOrPromise()
: fnOrPromise;
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise);
}

@@ -756,4 +751,4 @@ catch (er) {

// pull the errorOrigin from the thrown error, if possible
const res = er !== undefined && er !== null
? this.error(er, ...me)
const res = er !== undefined && er !== null ?
this.error(er, ...me)
: this.#t.fail(...me);

@@ -781,5 +776,3 @@ d.resolve((res && er) || res);

p =
typeof fnOrPromise === 'function'
? fnOrPromise()
: fnOrPromise;
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise);
}

@@ -799,4 +792,4 @@ catch (er) {

// pull the errorOrigin from the thrown error, if possible
d.resolve(er !== undefined && er !== null
? this.error(er, ...me)
d.resolve(er !== undefined && er !== null ?
this.error(er, ...me)
: this.#t.fail(...me));

@@ -891,6 +884,12 @@ }

// or respect the at/stack added by another caller.
ex.errorOrigin = {
// iow, the "main" error is `t.error(...)`, but the "cause"
// callsite is whatever the error refers to.
const { cause } = ex;
ex.cause = {
message: er.message || msg,
at: ex.at,
stack: ex.stack,
};
if (cause !== undefined)
ex.cause.cause = cause;
ex.at = at;

@@ -897,0 +896,0 @@ ex.stack = stack;

@@ -20,7 +20,11 @@ /// <reference types="node" resolution-mode="require"/>

};
export type ErrorCauseMatch = {
cause: any;
export type ErrorCauseMatch<C extends {}> = {
cause: C;
[k: string]: any;
};
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch | RegExp;
export type ErrorErrorsMatch<C extends {}> = {
errors: C[];
[k: string]: any;
};
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch<{}> | ErrorErrorsMatch<{}> | RegExp;
export type ThrowsArgs = [] | [msg: string, extra?: Extra] | [wanted: ErrorMatch, ...messageExtra: MessageExtra];

@@ -27,0 +31,0 @@ export type ExpectedEmit = [

@@ -131,4 +131,4 @@ import { extraFromError, normalizeMessageExtra, } from '@tapjs/core';

this.#t.currentAssert = this.#t.t.type;
const name = typeof klass === 'function'
? klass.name || '(anonymous constructor)'
const name = typeof klass === 'function' ?
klass.name || '(anonymous constructor)'
: klass;

@@ -142,11 +142,10 @@ const args = [msg, extra];

const tof = typeof obj;
const type = !obj && tof === 'object'
? 'null'
: // treat as object, but not Object
// t.type(() => {}, Function)
tof === 'function' &&
typeof klass === 'function' &&
klass !== Object
? 'object'
: tof;
const type = !obj && tof === 'object' ? 'null'
// treat as object, but not Object
// t.type(() => {}, Function)
: (tof === 'function' &&
typeof klass === 'function' &&
klass !== Object) ?
'object'
: tof;
if ((type === 'number' && klass === Number) ||

@@ -613,4 +612,4 @@ (type === 'string' && klass === String) ||

}
return ((w
? this.match(isRegExp(wanted) ? er.message : er, wanted, m, e)
return ((w ?
this.match(isRegExp(wanted) ? er.message : er, wanted, m, e)
: this.#t.pass(m, e)) && er);

@@ -636,4 +635,4 @@ }

// pull the errorOrigin from the thrown error, if possible
const res = er !== undefined && er !== null
? this.error(er, ...me)
const res = er !== undefined && er !== null ?
this.error(er, ...me)
: this.#t.fail(...me);

@@ -658,5 +657,3 @@ return (res && er) || res;

p =
typeof fnOrPromise === 'function'
? fnOrPromise()
: fnOrPromise;
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise);
}

@@ -685,4 +682,4 @@ catch (er) {

}
d.resolve((w
? this.match(isRegExp(w) ? er.message : er, w, m, e)
d.resolve((w ?
this.match(isRegExp(w) ? er.message : er, w, m, e)
: this.#t.pass(m, e)) &&

@@ -708,5 +705,3 @@ (er || true));

p =
typeof fnOrPromise === 'function'
? fnOrPromise()
: fnOrPromise;
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise);
}

@@ -727,4 +722,4 @@ catch (er) {

// pull the errorOrigin from the thrown error, if possible
const res = er !== undefined && er !== null
? this.error(er, ...me)
const res = er !== undefined && er !== null ?
this.error(er, ...me)
: this.#t.fail(...me);

@@ -752,5 +747,3 @@ d.resolve((res && er) || res);

p =
typeof fnOrPromise === 'function'
? fnOrPromise()
: fnOrPromise;
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise);
}

@@ -770,4 +763,4 @@ catch (er) {

// pull the errorOrigin from the thrown error, if possible
d.resolve(er !== undefined && er !== null
? this.error(er, ...me)
d.resolve(er !== undefined && er !== null ?
this.error(er, ...me)
: this.#t.fail(...me));

@@ -862,6 +855,12 @@ }

// or respect the at/stack added by another caller.
ex.errorOrigin = {
// iow, the "main" error is `t.error(...)`, but the "cause"
// callsite is whatever the error refers to.
const { cause } = ex;
ex.cause = {
message: er.message || msg,
at: ex.at,
stack: ex.stack,
};
if (cause !== undefined)
ex.cause.cause = cause;
ex.at = at;

@@ -868,0 +867,0 @@ ex.stack = stack;

{
"name": "@tapjs/asserts",
"version": "1.2.0",
"version": "2.0.0",
"description": "",

@@ -43,9 +43,9 @@ "tshy": {

"dependencies": {
"@tapjs/stack": "1.2.8",
"@tapjs/stack": "2.0.0",
"is-actual-promise": "^1.0.1",
"tcompare": "6.4.6",
"tcompare": "7.0.0",
"trivial-deferred": "^2.0.0"
},
"peerDependencies": {
"@tapjs/core": "1.5.4"
"@tapjs/core": "2.0.0"
},

@@ -52,0 +52,0 @@ "tap": {

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