pw-buffer 3.0.0 → 3.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.
- package/README.md +2 -0
- package/dist/MppcCompressorTransform.d.ts +1 -1
- package/dist/MppcCompressorTransform.js +15 -2
- package/dist/MppcDecompressorTransform.d.ts +1 -1
- package/dist/MppcDecompressorTransform.js +15 -2
- package/dist/errors/PwBufferError.d.ts +2 -0
- package/dist/errors/PwBufferError.js +6 -0
- package/dist/errors/PwBufferTypeError.d.ts +3 -0
- package/dist/errors/PwBufferTypeError.js +7 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://badge.fury.io/js/pw-buffer)
|
|
2
|
+
|
|
1
3
|
# Perfect World binary utils
|
|
2
4
|
|
|
3
5
|
A small TypeScript/Node.js library built on top of [extended-buffer](https://github.com/mvcbox/node-extended-buffer) that adds helpers commonly found in some Perfect World / PW-style binary protocols:
|
|
@@ -4,5 +4,5 @@ import { Transform, TransformOptions } from 'stream';
|
|
|
4
4
|
export declare class MppcCompressorTransform extends Transform {
|
|
5
5
|
protected readonly _mppcCompressor: MppcCompressor;
|
|
6
6
|
constructor(transformOptions?: TransformOptions);
|
|
7
|
-
_transform(chunk: Buffer
|
|
7
|
+
_transform(chunk: Buffer, encoding: string, callback: Function): void;
|
|
8
8
|
}
|
|
@@ -2,14 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MppcCompressorTransform = void 0;
|
|
4
4
|
const mppc_1 = require("./mppc");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
5
6
|
const stream_1 = require("stream");
|
|
6
7
|
class MppcCompressorTransform extends stream_1.Transform {
|
|
7
8
|
constructor(transformOptions) {
|
|
8
|
-
super(
|
|
9
|
+
super(Object.assign({
|
|
10
|
+
decodeStrings: true
|
|
11
|
+
}, transformOptions !== null && transformOptions !== void 0 ? transformOptions : {}));
|
|
9
12
|
this._mppcCompressor = new mppc_1.MppcCompressor();
|
|
10
13
|
}
|
|
11
14
|
_transform(chunk, encoding, callback) {
|
|
12
|
-
|
|
15
|
+
try {
|
|
16
|
+
if (chunk instanceof Buffer) {
|
|
17
|
+
callback(null, this._mppcCompressor.update(chunk));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
callback(new errors_1.PwBufferTypeError('INVALID_CHUNK_TYPE'));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
callback(e);
|
|
25
|
+
}
|
|
13
26
|
}
|
|
14
27
|
}
|
|
15
28
|
exports.MppcCompressorTransform = MppcCompressorTransform;
|
|
@@ -4,5 +4,5 @@ import { Transform, TransformOptions } from 'stream';
|
|
|
4
4
|
export declare class MppcDecompressorTransform extends Transform {
|
|
5
5
|
protected readonly _mppcDecompressor: MppcDecompressor;
|
|
6
6
|
constructor(transformOptions?: TransformOptions);
|
|
7
|
-
_transform(chunk: Buffer
|
|
7
|
+
_transform(chunk: Buffer, encoding: string, callback: Function): void;
|
|
8
8
|
}
|
|
@@ -2,14 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MppcDecompressorTransform = void 0;
|
|
4
4
|
const mppc_1 = require("./mppc");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
5
6
|
const stream_1 = require("stream");
|
|
6
7
|
class MppcDecompressorTransform extends stream_1.Transform {
|
|
7
8
|
constructor(transformOptions) {
|
|
8
|
-
super(
|
|
9
|
+
super(Object.assign({
|
|
10
|
+
decodeStrings: true
|
|
11
|
+
}, transformOptions !== null && transformOptions !== void 0 ? transformOptions : {}));
|
|
9
12
|
this._mppcDecompressor = new mppc_1.MppcDecompressor();
|
|
10
13
|
}
|
|
11
14
|
_transform(chunk, encoding, callback) {
|
|
12
|
-
|
|
15
|
+
try {
|
|
16
|
+
if (chunk instanceof Buffer) {
|
|
17
|
+
callback(null, this._mppcDecompressor.update(chunk));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
callback(new errors_1.PwBufferTypeError('INVALID_CHUNK_TYPE'));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
callback(e);
|
|
25
|
+
}
|
|
13
26
|
}
|
|
14
27
|
}
|
|
15
28
|
exports.MppcDecompressorTransform = MppcDecompressorTransform;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PwBufferTypeError = void 0;
|
|
4
|
+
const PwBufferError_1 = require("./PwBufferError");
|
|
5
|
+
class PwBufferTypeError extends PwBufferError_1.PwBufferError {
|
|
6
|
+
}
|
|
7
|
+
exports.PwBufferTypeError = PwBufferTypeError;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PwBufferTypeError = exports.PwBufferError = void 0;
|
|
4
|
+
var PwBufferError_1 = require("./PwBufferError");
|
|
5
|
+
Object.defineProperty(exports, "PwBufferError", { enumerable: true, get: function () { return PwBufferError_1.PwBufferError; } });
|
|
6
|
+
var PwBufferTypeError_1 = require("./PwBufferTypeError");
|
|
7
|
+
Object.defineProperty(exports, "PwBufferTypeError", { enumerable: true, get: function () { return PwBufferTypeError_1.PwBufferTypeError; } });
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.MppcDecompressorTransform = exports.MppcCompressorTransform = exports.MppcDecompressor = exports.MppcCompressor = exports.PwBuffer = void 0;
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./errors"), exports);
|
|
19
20
|
var PwBuffer_1 = require("./PwBuffer");
|
|
20
21
|
Object.defineProperty(exports, "PwBuffer", { enumerable: true, get: function () { return PwBuffer_1.PwBuffer; } });
|
|
21
22
|
var mppc_1 = require("./mppc");
|