@tapjs/intercept
Advanced tools
Comparing version 0.0.0-20 to 0.0.0-21
@@ -6,2 +6,10 @@ "use strict"; | ||
const stack_1 = require("@tapjs/stack"); | ||
const notConfig = (m, property, caller) => { | ||
const s = typeof property === 'string' | ||
? `'${property}'` | ||
: property.toString(); | ||
const er = new Error(`Cannot ${m} ${s}, defined {configurable:false}`); | ||
Error.captureStackTrace(er, caller); | ||
return er; | ||
}; | ||
/** | ||
@@ -39,2 +47,5 @@ * Implementation class providing the | ||
} | ||
if (orig && !orig.configurable) { | ||
throw notConfig('intercept property', prop, this.#t.t.intercept); | ||
} | ||
let restore; | ||
@@ -167,2 +178,5 @@ // if we have an original, then that serves as the basis for | ||
const prop = Object.getOwnPropertyDescriptor(obj, method); | ||
if (prop && !prop.configurable) { | ||
throw notConfig('capture method', method, this.#t.t.capture); | ||
} | ||
// if we don't have a prop we can restore by just deleting | ||
@@ -169,0 +183,0 @@ // otherwise, we restore by putting it back as it was |
import { plugin as TeardownPlugin } from '@tapjs/after'; | ||
import { at, captureString } from '@tapjs/stack'; | ||
const notConfig = (m, property, caller) => { | ||
const s = typeof property === 'string' | ||
? `'${property}'` | ||
: property.toString(); | ||
const er = new Error(`Cannot ${m} ${s}, defined {configurable:false}`); | ||
Error.captureStackTrace(er, caller); | ||
return er; | ||
}; | ||
/** | ||
@@ -35,2 +43,5 @@ * Implementation class providing the | ||
} | ||
if (orig && !orig.configurable) { | ||
throw notConfig('intercept property', prop, this.#t.t.intercept); | ||
} | ||
let restore; | ||
@@ -163,2 +174,5 @@ // if we have an original, then that serves as the basis for | ||
const prop = Object.getOwnPropertyDescriptor(obj, method); | ||
if (prop && !prop.configurable) { | ||
throw notConfig('capture method', method, this.#t.t.capture); | ||
} | ||
// if we don't have a prop we can restore by just deleting | ||
@@ -165,0 +179,0 @@ // otherwise, we restore by putting it back as it was |
{ | ||
"name": "@tapjs/intercept", | ||
"version": "0.0.0-20", | ||
"version": "0.0.0-21", | ||
"description": "a built-in tap extension for t.intercept() and t.capture()", | ||
@@ -34,2 +34,5 @@ "type": "module", | ||
}, | ||
"tap": { | ||
"typecheck": false | ||
}, | ||
"keywords": [ | ||
@@ -45,7 +48,7 @@ "tapjs plugin" | ||
"peerDependencies": { | ||
"@tapjs/core": "0.0.0-20" | ||
"@tapjs/core": "0.0.0-21" | ||
}, | ||
"dependencies": { | ||
"@tapjs/after": "0.0.0-20", | ||
"@tapjs/stack": "0.0.0-6" | ||
"@tapjs/after": "0.0.0-21", | ||
"@tapjs/stack": "0.0.0-7" | ||
}, | ||
@@ -52,0 +55,0 @@ "engines": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98216
959
+ Added@tapjs/after@0.0.0-21(transitive)
+ Added@tapjs/core@0.0.0-21(transitive)
+ Added@tapjs/processinfo@3.1.8(transitive)
+ Added@tapjs/stack@0.0.0-7(transitive)
+ Added@tapjs/test@0.0.0-21(transitive)
- Removed@tapjs/after@0.0.0-20(transitive)
- Removed@tapjs/core@0.0.0-20(transitive)
- Removed@tapjs/processinfo@2.5.6(transitive)
- Removed@tapjs/stack@0.0.0-6(transitive)
- Removed@tapjs/test@0.0.0-20(transitive)
Updated@tapjs/after@0.0.0-21
Updated@tapjs/stack@0.0.0-7