@tapjs/node-serialize
Version:
Stream TAP test data as a serialized node:test stream
36 lines • 903 B
JavaScript
// 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 {
constructor(items) {
super();
if (items) {
for (const [t, v] of items) {
this.set(t, v);
}
}
}
get(t) {
return super.get(getKey(t));
}
has(t) {
return super.has(getKey(t));
}
set(t, v) {
return super.set(getKey(t), v);
}
}
//# sourceMappingURL=test-map.js.map