ScuttleBot

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

Keyboard Shortcuts

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