Skip to content

Commit

Permalink
Use byte-length package - fixes #291
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed May 16, 2022
1 parent cb9e9c1 commit a0b215f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"dependencies": {
"axios": "^0.26.1",
"base-64": "^1.0.0",
"byte-length": "^1.0.2",
"fast-xml-parser": "^3.19.0",
"he": "^1.2.0",
"hot-patcher": "^0.5.0",
Expand Down
3 changes: 2 additions & 1 deletion source/tools/size.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Layerr } from "layerr";
import { byteLength } from "byte-length";
import { isArrayBuffer } from "../compat/arrayBuffer";
import { isBuffer } from "../compat/buffer";
import { BufferLike, ErrorCode } from "../types";
Expand All @@ -9,7 +10,7 @@ export function calculateDataLength(data: string | BufferLike): number {
} else if (isBuffer(data)) {
return (<Buffer>data).length;
} else if (typeof data === "string") {
return Buffer.byteLength(<string>data);
return byteLength(<string>data);
}
throw new Layerr(
{
Expand Down

0 comments on commit a0b215f

Please sign in to comment.