@tapjs/node-serialize
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -1,3 +0,4 @@ | ||
import type { Base } from '@tapjs/core'; | ||
import { Base } from '@tapjs/core'; | ||
export declare class TestMap<T extends {}> extends Map<Base, T> { | ||
constructor(items?: [Base, T][]); | ||
get(t: Base): T | undefined; | ||
@@ -4,0 +5,0 @@ has(t: Base): boolean; |
@@ -6,33 +6,33 @@ "use strict"; | ||
exports.TestMap = void 0; | ||
const kSerializationKey = Symbol.for('@tapjs/node-serialize.key'); | ||
const getKey = (t) => { | ||
const k = t[kSerializationKey]; | ||
if (k) | ||
return k; | ||
const n = String(Math.random()); | ||
Object.defineProperty(t, kSerializationKey, { | ||
value: n, | ||
writable: false, | ||
configurable: true, | ||
enumerable: false, | ||
}); | ||
return n; | ||
}; | ||
class TestMap extends Map { | ||
get(t) { | ||
const tt = t.t; | ||
if (tt !== undefined && tt !== t) { | ||
let vt = super.get(t.t); | ||
if (vt === undefined) { | ||
const v = super.get(t); | ||
if (v !== undefined) { | ||
super.set(tt, v); | ||
super.delete(t); | ||
return v; | ||
} | ||
constructor(items) { | ||
super(); | ||
if (items) { | ||
for (const [t, v] of items) { | ||
this.set(t, v); | ||
} | ||
return vt; | ||
} | ||
return super.get(t); | ||
} | ||
get(t) { | ||
return super.get(getKey(t)); | ||
} | ||
has(t) { | ||
const tt = t.t; | ||
return super.has(t) || super.has(tt); | ||
return super.has(getKey(t)); | ||
} | ||
set(t, v) { | ||
const tt = t.t; | ||
if (tt !== undefined && tt !== t) { | ||
super.delete(t); | ||
super.set(tt, v); | ||
} | ||
else { | ||
super.set(t, v); | ||
} | ||
return this; | ||
return super.set(getKey(t), v); | ||
} | ||
@@ -39,0 +39,0 @@ } |
@@ -1,3 +0,4 @@ | ||
import type { Base } from '@tapjs/core'; | ||
import { Base } from '@tapjs/core'; | ||
export declare class TestMap<T extends {}> extends Map<Base, T> { | ||
constructor(items?: [Base, T][]); | ||
get(t: Base): T | undefined; | ||
@@ -4,0 +5,0 @@ has(t: Base): boolean; |
// A map of test objects, but make sure that we don't get confused | ||
// if we get the Test proxy or the underlying TestBase. | ||
const kSerializationKey = Symbol.for('@tapjs/node-serialize.key'); | ||
const getKey = (t) => { | ||
const k = t[kSerializationKey]; | ||
if (k) | ||
return k; | ||
const n = String(Math.random()); | ||
Object.defineProperty(t, kSerializationKey, { | ||
value: n, | ||
writable: false, | ||
configurable: true, | ||
enumerable: false, | ||
}); | ||
return n; | ||
}; | ||
export class TestMap extends Map { | ||
get(t) { | ||
const tt = t.t; | ||
if (tt !== undefined && tt !== t) { | ||
let vt = super.get(t.t); | ||
if (vt === undefined) { | ||
const v = super.get(t); | ||
if (v !== undefined) { | ||
super.set(tt, v); | ||
super.delete(t); | ||
return v; | ||
} | ||
constructor(items) { | ||
super(); | ||
if (items) { | ||
for (const [t, v] of items) { | ||
this.set(t, v); | ||
} | ||
return vt; | ||
} | ||
return super.get(t); | ||
} | ||
get(t) { | ||
return super.get(getKey(t)); | ||
} | ||
has(t) { | ||
const tt = t.t; | ||
return super.has(t) || super.has(tt); | ||
return super.has(getKey(t)); | ||
} | ||
set(t, v) { | ||
const tt = t.t; | ||
if (tt !== undefined && tt !== t) { | ||
super.delete(t); | ||
super.set(tt, v); | ||
} | ||
else { | ||
super.set(t, v); | ||
} | ||
return this; | ||
return super.set(getKey(t), v); | ||
} | ||
} | ||
//# sourceMappingURL=test-map.js.map |
{ | ||
"name": "@tapjs/node-serialize", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Stream TAP test data as a serialized node:test stream", | ||
@@ -46,3 +46,3 @@ "tshy": { | ||
"peerDependencies": { | ||
"@tapjs/core": "1.3.5" | ||
"@tapjs/core": "1.3.6" | ||
}, | ||
@@ -49,0 +49,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
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
106827
910