Restore node_modules to exact state from cli.js.map extraction: - Move .ignored/ and .ignored_* files back to original package paths - Remove pnpm symlinks (replaced by real source-map directories) - Update .gitignore: only exclude /dist/, .pnpm/, .bin/, .ignored* dirs - All package dist/ folders are now preserved as part of source-map files After clone, run `pnpm install` to get pnpm-managed symlinks for building. The committed node_modules contains the original TypeScript/JS source files as bundled in cli.js.
31 lines
934 B
JavaScript
31 lines
934 B
JavaScript
'use strict';
|
|
|
|
const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null;
|
|
const calculateBodyLength = (body) => {
|
|
if (typeof body === "string") {
|
|
if (TEXT_ENCODER) {
|
|
return TEXT_ENCODER.encode(body).byteLength;
|
|
}
|
|
let len = body.length;
|
|
for (let i = len - 1; i >= 0; i--) {
|
|
const code = body.charCodeAt(i);
|
|
if (code > 0x7f && code <= 0x7ff)
|
|
len++;
|
|
else if (code > 0x7ff && code <= 0xffff)
|
|
len += 2;
|
|
if (code >= 0xdc00 && code <= 0xdfff)
|
|
i--;
|
|
}
|
|
return len;
|
|
}
|
|
else if (typeof body.byteLength === "number") {
|
|
return body.byteLength;
|
|
}
|
|
else if (typeof body.size === "number") {
|
|
return body.size;
|
|
}
|
|
throw new Error(`Body Length computation failed for ${body}`);
|
|
};
|
|
|
|
exports.calculateBodyLength = calculateBodyLength;
|