Skip to content

Commit

Permalink
zstd换个wasm的库,方便兼容Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Aug 10, 2022
1 parent 58c695b commit 6d3b698
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 139 deletions.
160 changes: 27 additions & 133 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"homepage": "https://github.com/bangbang93/openbmclapi#readme",
"dependencies": {
"@mongodb-js/zstd": "^1.0.0",
"@oneidentity/zstd-js": "^1.0.2",
"avsc": "^5.7.4",
"bluebird": "^3.5.5",
"colors": "^1.3.3",
Expand Down
11 changes: 6 additions & 5 deletions src/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {decompress} from '@mongodb-js/zstd'
import {ZstdInit} from '@oneidentity/zstd-js'
import {schema, Type} from 'avsc'
import * as Bluebird from 'bluebird'
import {ChildProcess, spawn} from 'child_process'
Expand All @@ -14,16 +14,16 @@ import {dirname, join, sep} from 'path'
import {cwd} from 'process'
import * as ProgressBar from 'progress'
import {createInterface} from 'readline'
import {Socket} from 'socket.io-client'
import * as io from 'socket.io-client'
import {Socket} from 'socket.io-client'
import MeasureRoute from './measure.route'
import http2Express = require('http2-express-bridge')
import morgan = require('morgan')
import ms = require('ms')
import NextFunction = express.NextFunction
import Request = express.Request
import Response = express.Response
import Timeout = NodeJS.Timeout
import http2Express = require('http2-express-bridge')
import RecordType = schema.RecordType

interface IFileList {
Expand Down Expand Up @@ -97,9 +97,10 @@ export class Cluster {
responseType: 'buffer',
cache: this.requestCache,
})
const decompressed = await decompress(res.body)
const {ZstdStream} = await ZstdInit()
const decompressed = ZstdStream.decompress(res.body)
return {
files: FileListSchema.fromBuffer(decompressed),
files: FileListSchema.fromBuffer(Buffer.from(decompressed)),
}
}

Expand Down

0 comments on commit 6d3b698

Please sign in to comment.