UNPKG

@tapjs/node-serialize

Version:

Stream TAP test data as a serialized node:test stream

40 lines 1.03 kB
"use strict"; // A map of test objects, but make sure that we don't get confused // if we get the Test proxy or the underlying TestBase. Object.defineProperty(exports, "__esModule", { value: true }); 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 { 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); } } exports.TestMap = TestMap; //# sourceMappingURL=test-map.js.map