@smithy/util-body-length-browser 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateBodyLength = void 0;
|
|
4
|
+
const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null;
|
|
4
5
|
const calculateBodyLength = (body) => {
|
|
5
6
|
if (typeof body === "string") {
|
|
7
|
+
if (TEXT_ENCODER) {
|
|
8
|
+
return TEXT_ENCODER.encode(body).byteLength;
|
|
9
|
+
}
|
|
6
10
|
let len = body.length;
|
|
7
11
|
for (let i = len - 1; i >= 0; i--) {
|
|
8
12
|
const code = body.charCodeAt(i);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null;
|
|
1
2
|
export const calculateBodyLength = (body) => {
|
|
2
3
|
if (typeof body === "string") {
|
|
4
|
+
if (TEXT_ENCODER) {
|
|
5
|
+
return TEXT_ENCODER.encode(body).byteLength;
|
|
6
|
+
}
|
|
3
7
|
let len = body.length;
|
|
4
8
|
for (let i = len - 1; i >= 0; i--) {
|
|
5
9
|
const code = body.charCodeAt(i);
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/util-body-length-browser",
|
|
3
3
|
"description": "Determines the length of a request body in browsers",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
7
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
8
|
-
"build:es": "tsc -p tsconfig.es.json",
|
|
9
|
-
"build:types": "tsc -p tsconfig.types.json",
|
|
7
|
+
"build:cjs": "yarn g:tsc -p tsconfig.cjs.json",
|
|
8
|
+
"build:es": "yarn g:tsc -p tsconfig.es.json",
|
|
9
|
+
"build:types": "yarn g:tsc -p tsconfig.types.json",
|
|
10
10
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
11
11
|
"stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
|
|
12
|
-
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
|
|
12
|
+
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
|
|
13
13
|
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
|
|
14
14
|
"format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
|
|
15
|
-
"test": "jest"
|
|
15
|
+
"test": "yarn g:jest"
|
|
16
16
|
},
|
|
17
17
|
"main": "./dist-cjs/index.js",
|
|
18
18
|
"module": "./dist-es/index.js",
|
|
@@ -45,10 +45,8 @@
|
|
|
45
45
|
"@tsconfig/recommended": "1.0.1",
|
|
46
46
|
"concurrently": "7.0.0",
|
|
47
47
|
"downlevel-dts": "0.10.1",
|
|
48
|
-
"jest": "28.1.1",
|
|
49
48
|
"rimraf": "3.0.2",
|
|
50
|
-
"typedoc": "0.23.23"
|
|
51
|
-
"typescript": "~4.9.5"
|
|
49
|
+
"typedoc": "0.23.23"
|
|
52
50
|
},
|
|
53
51
|
"typedoc": {
|
|
54
52
|
"entryPoint": "src/index.ts"
|