@smithy/util-body-length-browser 4.2.2 → 4.3.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.
package/dist-cjs/index.js CHANGED
@@ -1,30 +1,5 @@
1
- 'use strict';
2
-
3
- const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null;
4
- const calculateBodyLength = (body) => {
5
- if (typeof body === "string") {
6
- if (TEXT_ENCODER) {
7
- return TEXT_ENCODER.encode(body).byteLength;
8
- }
9
- let len = body.length;
10
- for (let i = len - 1; i >= 0; i--) {
11
- const code = body.charCodeAt(i);
12
- if (code > 0x7f && code <= 0x7ff)
13
- len++;
14
- else if (code > 0x7ff && code <= 0xffff)
15
- len += 2;
16
- if (code >= 0xdc00 && code <= 0xdfff)
17
- i--;
18
- }
19
- return len;
20
- }
21
- else if (typeof body.byteLength === "number") {
22
- return body.byteLength;
23
- }
24
- else if (typeof body.size === "number") {
25
- return body.size;
26
- }
27
- throw new Error(`Body Length computation failed for ${body}`);
28
- };
29
-
30
- exports.calculateBodyLength = calculateBodyLength;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateBodyLength = void 0;
4
+ var serde_1 = require("@smithy/core/serde");
5
+ Object.defineProperty(exports, "calculateBodyLength", { enumerable: true, get: function () { return serde_1.calculateBodyLength; } });
package/dist-es/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./calculateBodyLength";
1
+ export { calculateBodyLength } from "@smithy/core/serde";
@@ -1,4 +1,2 @@
1
- /**
2
- * @internal
3
- */
4
- export * from "./calculateBodyLength";
1
+ /** @deprecated Use @smithy/core/serde instead. */
2
+ export { calculateBodyLength } from "@smithy/core/serde";
package/package.json CHANGED
@@ -1,19 +1,12 @@
1
1
  {
2
2
  "name": "@smithy/util-body-length-browser",
3
3
  "description": "Determines the length of a request body in browsers",
4
- "version": "4.2.2",
4
+ "version": "4.3.1",
5
5
  "scripts": {
6
- "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
7
- "build:cjs": "node ../../scripts/inline util-body-length-browser",
8
- "build:es": "yarn g:tsc -p tsconfig.es.json",
6
+ "build": "yarn g:tsc -p tsconfig.cjs.json && yarn g:tsc -p tsconfig.es.json && yarn g:tsc -p tsconfig.types.json",
9
7
  "build:types": "yarn g:tsc -p tsconfig.types.json",
10
- "build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
11
- "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
12
- "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
13
- "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
14
- "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
15
- "test": "yarn g:vitest run",
16
- "test:watch": "yarn g:vitest watch"
8
+ "clean": "rm -rf dist-cjs dist-es dist-types",
9
+ "stage-release": "rm -rf .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz"
17
10
  },
18
11
  "main": "./dist-cjs/index.js",
19
12
  "module": "./dist-es/index.js",
@@ -25,15 +18,9 @@
25
18
  "license": "Apache-2.0",
26
19
  "sideEffects": false,
27
20
  "dependencies": {
21
+ "@smithy/core": "^3.24.1",
28
22
  "tslib": "^2.6.2"
29
23
  },
30
- "typesVersions": {
31
- "<4.5": {
32
- "dist-types/*": [
33
- "dist-types/ts3.4/*"
34
- ]
35
- }
36
- },
37
24
  "files": [
38
25
  "dist-*/**"
39
26
  ],
@@ -43,12 +30,6 @@
43
30
  "url": "https://github.com/smithy-lang/smithy-typescript.git",
44
31
  "directory": "packages/util-body-length-browser"
45
32
  },
46
- "devDependencies": {
47
- "concurrently": "7.0.0",
48
- "downlevel-dts": "0.10.1",
49
- "premove": "4.0.0",
50
- "typedoc": "0.23.23"
51
- },
52
33
  "typedoc": {
53
34
  "entryPoint": "src/index.ts"
54
35
  },
package/README.md DELETED
@@ -1,12 +0,0 @@
1
- # @smithy/util-body-length-browser
2
-
3
- [![NPM version](https://img.shields.io/npm/v/@smithy/util-body-length-browser/latest.svg)](https://www.npmjs.com/package/@smithy/util-body-length-browser)
4
- [![NPM downloads](https://img.shields.io/npm/dm/@smithy/util-body-length-browser.svg)](https://www.npmjs.com/package/@smithy/util-body-length-browser)
5
-
6
- Determines the length of a request body in browsers
7
-
8
- > An internal package
9
-
10
- ## Usage
11
-
12
- You probably shouldn't, at least directly.
@@ -1,26 +0,0 @@
1
- const TEXT_ENCODER = typeof TextEncoder == "function" ? new TextEncoder() : null;
2
- export const calculateBodyLength = (body) => {
3
- if (typeof body === "string") {
4
- if (TEXT_ENCODER) {
5
- return TEXT_ENCODER.encode(body).byteLength;
6
- }
7
- let len = body.length;
8
- for (let i = len - 1; i >= 0; i--) {
9
- const code = body.charCodeAt(i);
10
- if (code > 0x7f && code <= 0x7ff)
11
- len++;
12
- else if (code > 0x7ff && code <= 0xffff)
13
- len += 2;
14
- if (code >= 0xdc00 && code <= 0xdfff)
15
- i--;
16
- }
17
- return len;
18
- }
19
- else if (typeof body.byteLength === "number") {
20
- return body.byteLength;
21
- }
22
- else if (typeof body.size === "number") {
23
- return body.size;
24
- }
25
- throw new Error(`Body Length computation failed for ${body}`);
26
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * @internal
3
- */
4
- export declare const calculateBodyLength: (body: any) => number | undefined;
@@ -1,4 +0,0 @@
1
- /**
2
- * @internal
3
- */
4
- export declare const calculateBodyLength: (body: any) => number | undefined;
@@ -1,4 +0,0 @@
1
- /**
2
- * @internal
3
- */
4
- export * from "./calculateBodyLength";