the-forest/client/node_modules/.cache/babel-loader/e75eb07f11747f0304f50d9cbfdf6c5a6e93259563cfe1d050cdb989fe47558c.json
2024-09-17 20:35:18 -04:00

1 line
5.0 KiB
JSON

{"ast":null,"code":"'use strict';\n\nconst {\n tokenChars\n} = require('./validation');\n\n/**\n * Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.\n *\n * @param {String} header The field value of the header\n * @return {Set} The subprotocol names\n * @public\n */\nfunction parse(header) {\n const protocols = new Set();\n let start = -1;\n let end = -1;\n let i = 0;\n for (i; i < header.length; i++) {\n const code = header.charCodeAt(i);\n if (end === -1 && tokenChars[code] === 1) {\n if (start === -1) start = i;\n } else if (i !== 0 && (code === 0x20 /* ' ' */ || code === 0x09) /* '\\t' */) {\n if (end === -1 && start !== -1) end = i;\n } else if (code === 0x2c /* ',' */) {\n if (start === -1) {\n throw new SyntaxError(`Unexpected character at index ${i}`);\n }\n if (end === -1) end = i;\n const protocol = header.slice(start, end);\n if (protocols.has(protocol)) {\n throw new SyntaxError(`The \"${protocol}\" subprotocol is duplicated`);\n }\n protocols.add(protocol);\n start = end = -1;\n } else {\n throw new SyntaxError(`Unexpected character at index ${i}`);\n }\n }\n if (start === -1 || end !== -1) {\n throw new SyntaxError('Unexpected end of input');\n }\n const protocol = header.slice(start, i);\n if (protocols.has(protocol)) {\n throw new SyntaxError(`The \"${protocol}\" subprotocol is duplicated`);\n }\n protocols.add(protocol);\n return protocols;\n}\nmodule.exports = {\n parse\n};","map":{"version":3,"names":["tokenChars","require","parse","header","protocols","Set","start","end","i","length","code","charCodeAt","SyntaxError","protocol","slice","has","add","module","exports"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/isomorphic-ws/node_modules/ws/lib/subprotocol.js"],"sourcesContent":["'use strict';\n\nconst { tokenChars } = require('./validation');\n\n/**\n * Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.\n *\n * @param {String} header The field value of the header\n * @return {Set} The subprotocol names\n * @public\n */\nfunction parse(header) {\n const protocols = new Set();\n let start = -1;\n let end = -1;\n let i = 0;\n\n for (i; i < header.length; i++) {\n const code = header.charCodeAt(i);\n\n if (end === -1 && tokenChars[code] === 1) {\n if (start === -1) start = i;\n } else if (\n i !== 0 &&\n (code === 0x20 /* ' ' */ || code === 0x09) /* '\\t' */\n ) {\n if (end === -1 && start !== -1) end = i;\n } else if (code === 0x2c /* ',' */) {\n if (start === -1) {\n throw new SyntaxError(`Unexpected character at index ${i}`);\n }\n\n if (end === -1) end = i;\n\n const protocol = header.slice(start, end);\n\n if (protocols.has(protocol)) {\n throw new SyntaxError(`The \"${protocol}\" subprotocol is duplicated`);\n }\n\n protocols.add(protocol);\n start = end = -1;\n } else {\n throw new SyntaxError(`Unexpected character at index ${i}`);\n }\n }\n\n if (start === -1 || end !== -1) {\n throw new SyntaxError('Unexpected end of input');\n }\n\n const protocol = header.slice(start, i);\n\n if (protocols.has(protocol)) {\n throw new SyntaxError(`The \"${protocol}\" subprotocol is duplicated`);\n }\n\n protocols.add(protocol);\n return protocols;\n}\n\nmodule.exports = { parse };\n"],"mappings":"AAAA,YAAY;;AAEZ,MAAM;EAAEA;AAAW,CAAC,GAAGC,OAAO,CAAC,cAAc,CAAC;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,KAAKA,CAACC,MAAM,EAAE;EACrB,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B,IAAIC,KAAK,GAAG,CAAC,CAAC;EACd,IAAIC,GAAG,GAAG,CAAC,CAAC;EACZ,IAAIC,CAAC,GAAG,CAAC;EAET,KAAKA,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;IAC9B,MAAME,IAAI,GAAGP,MAAM,CAACQ,UAAU,CAACH,CAAC,CAAC;IAEjC,IAAID,GAAG,KAAK,CAAC,CAAC,IAAIP,UAAU,CAACU,IAAI,CAAC,KAAK,CAAC,EAAE;MACxC,IAAIJ,KAAK,K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