ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / isomorphic / stringInternPool.js
Blame History Raw 70 lines
1
"use strict";
2
var __defProp = Object.defineProperty;
3
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
var __getOwnPropNames = Object.getOwnPropertyNames;
5
var __hasOwnProp = Object.prototype.hasOwnProperty;
6
var __export = (target, all) => {
7
for (var name in all)
8
__defProp(target, name, { get: all[name], enumerable: true });
9
};
10
var __copyProps = (to, from, except, desc) => {
11
if (from && typeof from === "object" || typeof from === "function") {
12
for (let key of __getOwnPropNames(from))
13
if (!__hasOwnProp.call(to, key) && key !== except)
14
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
}
16
return to;
17
};
18
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
var stringInternPool_exports = {};
20
__export(stringInternPool_exports, {
21
JsonStringInternalizer: () => JsonStringInternalizer,
22
StringInternPool: () => StringInternPool
23
});
24
module.exports = __toCommonJS(stringInternPool_exports);
25
class StringInternPool {
26
constructor() {
27
this._stringCache = /* @__PURE__ */ new Map();
28
}
29
internString(s) {
30
let result = this._stringCache.get(s);
31
if (!result) {
32
this._stringCache.set(s, s);
33
result = s;
34
}
35
return result;
36
}
37
}
38
class JsonStringInternalizer {
39
constructor(pool) {
40
this._pool = pool;
41
}
42
traverse(value) {
43
if (typeof value !== "object")
44
return;
45
if (Array.isArray(value)) {
46
for (let i = 0; i < value.length; i++) {
47
if (typeof value[i] === "string")
48
value[i] = this.intern(value[i]);
49
else
50
this.traverse(value[i]);
51
}
52
} else {
53
for (const name in value) {
54
if (typeof value[name] === "string")
55
value[name] = this.intern(value[name]);
56
else
57
this.traverse(value[name]);
58
}
59
}
60
}
61
intern(value) {
62
return this._pool.internString(value);
63
}
64
}
65
// Annotate the CommonJS export names for ESM import in node:
66
0 && (module.exports = {
67
JsonStringInternalizer,
68
StringInternPool
69
});
70

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button