Skip to content

Commit cb5abc9

Browse files
committed
Vendor lz4js
This allows the browser tests to run fine, also convert to TS code for more type accuracy
1 parent e7639a4 commit cb5abc9

File tree

8 files changed

+695
-22
lines changed

8 files changed

+695
-22
lines changed

packages/hub/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
22
sha256.js
3+
src/vendor

packages/hub/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@
5959
"author": "Hugging Face",
6060
"license": "MIT",
6161
"devDependencies": {
62-
"@types/lz4js": "^0.2.1",
6362
"@types/node": "^20.11.28"
6463
},
6564
"dependencies": {
66-
"@huggingface/tasks": "workspace:^",
67-
"lz4js": "^0.2.0"
65+
"@huggingface/tasks": "workspace:^"
6866
}
6967
}

packages/hub/pnpm-lock.yaml

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/hub/src/utils/XetBlob.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createApiError } from "../error";
33
import type { CredentialsParams, RepoDesignation, RepoId } from "../types/public";
44
import { checkCredentials } from "./checkCredentials";
55
import { toRepoId } from "./toRepoId";
6-
import lz4 from "lz4js";
6+
import { decompress as lz4Decompress } from "../vendor/lz4js";
77

88
const JWT_SAFETY_PERIOD = 60_000;
99
const JWT_CACHE_SIZE = 1_000;
@@ -272,10 +272,7 @@ export class XetBlob extends Blob {
272272

273273
const uncompressed =
274274
chunkHeader.compression_scheme === CompressionScheme.LZ4
275-
? lz4.decompress(
276-
result.value.slice(0, chunkHeader.compressed_length),
277-
chunkHeader.uncompressed_length
278-
)
275+
? lz4Decompress(result.value.slice(0, chunkHeader.compressed_length), chunkHeader.uncompressed_length)
279276
: result.value.slice(0, chunkHeader.compressed_length);
280277

281278
if (readBytesToSkip) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ISC License
2+
3+
Copyright 2019 John Chadwick
4+
5+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8+
9+
---
10+
11+
Note: this license is not actually included in https://github.com/Benzinga/lz4js, but the package.json specifies the ISC license

0 commit comments

Comments
 (0)