extended-buffer 7.4.0 → 7.5.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 +97 -3
- package/dist/ExtendedBuffer.d.ts +0 -1
- package/dist/ExtendedBuffer.js +20 -10
- package/dist/ExtendedBufferOptions.d.ts +0 -1
- package/dist/ExtendedBufferTransaction.d.ts +0 -1
- package/dist/utils/alloc-native-buffer.d.ts +0 -1
- package/dist/utils/alloc-native-buffer.js +31 -27
- package/dist/utils/assert-big-integer.js +1 -2
- package/dist/utils/assert-integer-size.js +1 -2
- package/dist/utils/assert-integer.js +1 -2
- package/dist/utils/assert-support-big-integer.js +14 -8
- package/dist/utils/assert-unsigned-big-integer.js +1 -2
- package/dist/utils/assert-unsigned-integer.js +1 -2
- package/dist/utils/get-global-context.d.ts +1 -0
- package/dist/utils/get-global-context.js +23 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -1
- package/dist/utils/native-buffer-subarray.d.ts +0 -1
- package/dist/utils/native-buffer-subarray.js +1 -2
- package/dist/utils/realloc-native-buffer.d.ts +0 -1
- package/dist/utils/realloc-native-buffer.js +1 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -14,6 +14,99 @@ npm install extended-buffer
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
+
## Browser usage (bundlers)
|
|
18
|
+
|
|
19
|
+
`ExtendedBuffer` works in browsers **as long as a Buffer polyfill is available**. Most bundlers can use the `buffer`
|
|
20
|
+
package as a drop-in implementation.
|
|
21
|
+
|
|
22
|
+
Install the polyfill:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install buffer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If your bundler does not expose `Buffer` globally, add a small shim in your app entry:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { Buffer } from "buffer";
|
|
32
|
+
|
|
33
|
+
const globalScope: any =
|
|
34
|
+
typeof globalThis !== "undefined"
|
|
35
|
+
? globalThis
|
|
36
|
+
: typeof self !== "undefined"
|
|
37
|
+
? self
|
|
38
|
+
: typeof window !== "undefined"
|
|
39
|
+
? window
|
|
40
|
+
: undefined;
|
|
41
|
+
|
|
42
|
+
if (globalScope && !globalScope.Buffer) {
|
|
43
|
+
globalScope.Buffer = Buffer;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Webpack 5
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
// webpack.config.js
|
|
51
|
+
const webpack = require("webpack");
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
resolve: {
|
|
55
|
+
fallback: {
|
|
56
|
+
buffer: require.resolve("buffer/")
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
plugins: [
|
|
60
|
+
new webpack.ProvidePlugin({
|
|
61
|
+
Buffer: ["buffer", "Buffer"]
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Vite
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// vite.config.ts
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
|
|
73
|
+
export default defineConfig({
|
|
74
|
+
resolve: {
|
|
75
|
+
alias: {
|
|
76
|
+
buffer: "buffer/"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
optimizeDeps: {
|
|
80
|
+
include: ["buffer"]
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Rollup
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
// rollup.config.js
|
|
89
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
90
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
91
|
+
import inject from "@rollup/plugin-inject";
|
|
92
|
+
|
|
93
|
+
export default {
|
|
94
|
+
plugins: [
|
|
95
|
+
resolve({ browser: true, preferBuiltins: false }),
|
|
96
|
+
commonjs(),
|
|
97
|
+
inject({
|
|
98
|
+
Buffer: ["buffer", "Buffer"]
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Notes:
|
|
105
|
+
- BigInt read/write methods require a polyfill that supports Node’s BigInt Buffer APIs.
|
|
106
|
+
- If your tooling already provides a Buffer global, you can skip the shim/inject steps.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
17
110
|
## Quick start
|
|
18
111
|
|
|
19
112
|
```ts
|
|
@@ -316,6 +409,7 @@ Rules:
|
|
|
316
409
|
|
|
317
410
|
- If the callback **returns normally**, changes are kept (committed).
|
|
318
411
|
- If the callback **throws**, the buffer is restored (rolled back) and the error is re-thrown.
|
|
412
|
+
- The callback must be **synchronous** (returned Promises are not awaited).
|
|
319
413
|
- Transactions are **re-entrant**: nested `transaction()` calls do not create extra snapshots.
|
|
320
414
|
|
|
321
415
|
What gets rolled back:
|
|
@@ -426,7 +520,7 @@ Common error codes you may see:
|
|
|
426
520
|
- `VALUE_MUST_BE_AN_BIG_INTEGER`: value is not a `bigint`
|
|
427
521
|
- `VALUE_MUST_BE_AN_UNSIGNED_BIG_INTEGER`: value is not a `bigint` or less than 0
|
|
428
522
|
- `EXECUTION_ENVIRONMENT_NOT_SUPPORT_BIG_INT`: BigInt methods are not supported in the current runtime
|
|
429
|
-
- `EXCEEDING_MAXIMUM_BUFFER_SIZE`: allocation exceeds Node’s `kMaxLength` or `os.totalmem()`
|
|
523
|
+
- `EXCEEDING_MAXIMUM_BUFFER_SIZE`: allocation exceeds Node’s maximum buffer size (`kMaxLength` or `os.totalmem()` when available)
|
|
430
524
|
|
|
431
525
|
---
|
|
432
526
|
|
|
@@ -446,8 +540,8 @@ b.writeUInt16BE(123, true);
|
|
|
446
540
|
|
|
447
541
|
### `nodeGc()` is Node-specific
|
|
448
542
|
|
|
449
|
-
`nodeGc()` calls `
|
|
450
|
-
In non-Node runtimes
|
|
543
|
+
`nodeGc()` calls `gc()` on the detected global object if it exists. In Node.js it requires starting the process with `--expose-gc`.
|
|
544
|
+
In browsers/non-Node runtimes it simply no-ops.
|
|
451
545
|
|
|
452
546
|
---
|
|
453
547
|
|
package/dist/ExtendedBuffer.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ExtendedBufferOptions } from './ExtendedBufferOptions';
|
|
3
2
|
import type { ExtendedBufferTransaction } from './ExtendedBufferTransaction';
|
|
4
3
|
export declare class ExtendedBuffer<EBO extends ExtendedBufferOptions = ExtendedBufferOptions> {
|
package/dist/ExtendedBuffer.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.ExtendedBuffer = void 0;
|
|
27
37
|
const buffer_1 = require("buffer");
|
|
@@ -29,6 +39,7 @@ const utils = __importStar(require("./utils"));
|
|
|
29
39
|
const errors_1 = require("./errors");
|
|
30
40
|
const DEFAULT_CAPACITY = 16 * 1024;
|
|
31
41
|
const DEFAULT_CAPACITY_STEP = DEFAULT_CAPACITY;
|
|
42
|
+
const globalScope = utils.getGlobalContext();
|
|
32
43
|
class ExtendedBuffer {
|
|
33
44
|
constructor(options) {
|
|
34
45
|
var _a, _b;
|
|
@@ -121,7 +132,6 @@ class ExtendedBuffer {
|
|
|
121
132
|
if (this._transaction) {
|
|
122
133
|
return callback();
|
|
123
134
|
}
|
|
124
|
-
this.assertInstanceState();
|
|
125
135
|
this._transaction = {
|
|
126
136
|
pointer: this._pointer,
|
|
127
137
|
pointerEnd: this._pointerEnd,
|
|
@@ -213,8 +223,8 @@ class ExtendedBuffer {
|
|
|
213
223
|
return this;
|
|
214
224
|
}
|
|
215
225
|
nodeGc() {
|
|
216
|
-
if (typeof
|
|
217
|
-
|
|
226
|
+
if (typeof (globalScope === null || globalScope === void 0 ? void 0 : globalScope.gc) === 'function') {
|
|
227
|
+
globalScope.gc();
|
|
218
228
|
}
|
|
219
229
|
return this;
|
|
220
230
|
}
|
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
2
|
+
var _a;
|
|
25
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.allocNativeBuffer =
|
|
27
|
-
const os = __importStar(require("os"));
|
|
4
|
+
exports.allocNativeBuffer = allocNativeBuffer;
|
|
28
5
|
const buffer_1 = require("buffer");
|
|
29
6
|
const errors_1 = require("../errors");
|
|
30
7
|
const assert_unsigned_integer_1 = require("./assert-unsigned-integer");
|
|
31
|
-
const
|
|
8
|
+
const totalMem = (function () {
|
|
9
|
+
try {
|
|
10
|
+
const req = typeof module !== 'undefined' && typeof module.require === 'function'
|
|
11
|
+
? module.require.bind(module)
|
|
12
|
+
: typeof require === 'function'
|
|
13
|
+
? require
|
|
14
|
+
: undefined;
|
|
15
|
+
if (!req) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const os = req('os');
|
|
19
|
+
if (typeof (os === null || os === void 0 ? void 0 : os.totalmem) !== 'function') {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const result = os.totalmem();
|
|
23
|
+
return Number.isSafeInteger(result) && result > 0 ? result : undefined;
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
})();
|
|
29
|
+
const fallbackMaxLength = typeof buffer_1.kMaxLength === 'number'
|
|
30
|
+
? buffer_1.kMaxLength
|
|
31
|
+
: typeof buffer_1.Buffer.kMaxLength === 'number'
|
|
32
|
+
? buffer_1.Buffer.kMaxLength
|
|
33
|
+
: typeof ((_a = buffer_1.Buffer.constants) === null || _a === void 0 ? void 0 : _a.MAX_LENGTH) === 'number'
|
|
34
|
+
? buffer_1.Buffer.constants.MAX_LENGTH
|
|
35
|
+
: Number.MAX_SAFE_INTEGER;
|
|
36
|
+
const maxBufferSize = typeof totalMem === 'number' ? Math.min(fallbackMaxLength, totalMem) : fallbackMaxLength;
|
|
32
37
|
(0, assert_unsigned_integer_1.assertUnsignedInteger)(maxBufferSize);
|
|
33
38
|
function allocNativeBuffer(size, allocSlow) {
|
|
34
39
|
(0, assert_unsigned_integer_1.assertUnsignedInteger)(size);
|
|
@@ -37,4 +42,3 @@ function allocNativeBuffer(size, allocSlow) {
|
|
|
37
42
|
}
|
|
38
43
|
return allocSlow ? buffer_1.Buffer.allocUnsafeSlow(size) : buffer_1.Buffer.allocUnsafe(size);
|
|
39
44
|
}
|
|
40
|
-
exports.allocNativeBuffer = allocNativeBuffer;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertBigInteger =
|
|
3
|
+
exports.assertBigInteger = assertBigInteger;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
function assertBigInteger(value) {
|
|
6
6
|
if (typeof value !== 'bigint') {
|
|
7
7
|
throw new errors_1.ExtendedBufferTypeError('VALUE_MUST_BE_AN_BIG_INTEGER');
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
exports.assertBigInteger = assertBigInteger;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertIntegerSize =
|
|
3
|
+
exports.assertIntegerSize = assertIntegerSize;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
function assertIntegerSize(value) {
|
|
6
6
|
if (!Number.isSafeInteger(value)) {
|
|
@@ -10,4 +10,3 @@ function assertIntegerSize(value) {
|
|
|
10
10
|
throw new errors_1.ExtendedBufferRangeError('INVALID_INTEGER_SIZE_VALUE_RANGE');
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
exports.assertIntegerSize = assertIntegerSize;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertInteger =
|
|
3
|
+
exports.assertInteger = assertInteger;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
function assertInteger(value) {
|
|
6
6
|
if (!Number.isSafeInteger(value)) {
|
|
7
7
|
throw new errors_1.ExtendedBufferTypeError('VALUE_MUST_BE_AN_INTEGER');
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
exports.assertInteger = assertInteger;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSupportBigInteger =
|
|
3
|
+
exports.assertSupportBigInteger = assertSupportBigInteger;
|
|
4
4
|
const buffer_1 = require("buffer");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
|
+
const requiredMethods = [
|
|
7
|
+
'readBigUInt64LE',
|
|
8
|
+
'readBigUInt64BE',
|
|
9
|
+
'readBigInt64LE',
|
|
10
|
+
'readBigInt64BE',
|
|
11
|
+
'writeBigUInt64LE',
|
|
12
|
+
'writeBigUInt64BE',
|
|
13
|
+
'writeBigInt64LE',
|
|
14
|
+
'writeBigInt64BE'
|
|
15
|
+
];
|
|
16
|
+
const isSupported = typeof BigInt === 'function' &&
|
|
17
|
+
requiredMethods.every(method => typeof buffer_1.Buffer.prototype[method] === 'function');
|
|
6
18
|
function assertSupportBigInteger() {
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
isSupported = typeof BigInt(0) === 'bigint';
|
|
10
|
-
}
|
|
11
|
-
catch (e) { }
|
|
12
|
-
if (!isSupported || typeof buffer_1.Buffer.prototype.readBigUInt64LE !== 'function') {
|
|
19
|
+
if (!isSupported) {
|
|
13
20
|
throw new errors_1.ExtendedBufferUnsupportedError('EXECUTION_ENVIRONMENT_NOT_SUPPORT_BIG_INT');
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
|
-
exports.assertSupportBigInteger = assertSupportBigInteger;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertUnsignedBigInteger =
|
|
3
|
+
exports.assertUnsignedBigInteger = assertUnsignedBigInteger;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
function assertUnsignedBigInteger(value) {
|
|
6
6
|
if (typeof value !== 'bigint' || value < 0) {
|
|
7
7
|
throw new errors_1.ExtendedBufferTypeError('VALUE_MUST_BE_AN_UNSIGNED_BIG_INTEGER');
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
exports.assertUnsignedBigInteger = assertUnsignedBigInteger;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertUnsignedInteger =
|
|
3
|
+
exports.assertUnsignedInteger = assertUnsignedInteger;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
function assertUnsignedInteger(value) {
|
|
6
6
|
if (!Number.isSafeInteger(value) || value < 0) {
|
|
7
7
|
throw new errors_1.ExtendedBufferTypeError('VALUE_MUST_BE_AN_UNSIGNED_INTEGER');
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
exports.assertUnsignedInteger = assertUnsignedInteger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getGlobalContext(): NodeJS.Global | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalContext = getGlobalContext;
|
|
4
|
+
function getGlobalContext() {
|
|
5
|
+
if (typeof globalThis !== 'undefined') {
|
|
6
|
+
return globalThis;
|
|
7
|
+
}
|
|
8
|
+
if (typeof self !== 'undefined') {
|
|
9
|
+
return self;
|
|
10
|
+
}
|
|
11
|
+
if (typeof window !== 'undefined') {
|
|
12
|
+
return window;
|
|
13
|
+
}
|
|
14
|
+
if (typeof global !== 'undefined') {
|
|
15
|
+
return global;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
return Function('return this')();
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { assertInteger } from './assert-integer';
|
|
2
2
|
export { assertBigInteger } from './assert-big-integer';
|
|
3
|
+
export { getGlobalContext } from './get-global-context';
|
|
3
4
|
export { assertIntegerSize } from './assert-integer-size';
|
|
4
5
|
export { allocNativeBuffer } from './alloc-native-buffer';
|
|
5
6
|
export { reallocNativeBuffer } from './realloc-native-buffer';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertUnsignedBigInteger = exports.assertSupportBigInteger = exports.assertUnsignedInteger = exports.nativeBufferSubarray = exports.reallocNativeBuffer = exports.allocNativeBuffer = exports.assertIntegerSize = exports.assertBigInteger = exports.assertInteger = void 0;
|
|
3
|
+
exports.assertUnsignedBigInteger = exports.assertSupportBigInteger = exports.assertUnsignedInteger = exports.nativeBufferSubarray = exports.reallocNativeBuffer = exports.allocNativeBuffer = exports.assertIntegerSize = exports.getGlobalContext = exports.assertBigInteger = exports.assertInteger = void 0;
|
|
4
4
|
var assert_integer_1 = require("./assert-integer");
|
|
5
5
|
Object.defineProperty(exports, "assertInteger", { enumerable: true, get: function () { return assert_integer_1.assertInteger; } });
|
|
6
6
|
var assert_big_integer_1 = require("./assert-big-integer");
|
|
7
7
|
Object.defineProperty(exports, "assertBigInteger", { enumerable: true, get: function () { return assert_big_integer_1.assertBigInteger; } });
|
|
8
|
+
var get_global_context_1 = require("./get-global-context");
|
|
9
|
+
Object.defineProperty(exports, "getGlobalContext", { enumerable: true, get: function () { return get_global_context_1.getGlobalContext; } });
|
|
8
10
|
var assert_integer_size_1 = require("./assert-integer-size");
|
|
9
11
|
Object.defineProperty(exports, "assertIntegerSize", { enumerable: true, get: function () { return assert_integer_size_1.assertIntegerSize; } });
|
|
10
12
|
var alloc_native_buffer_1 = require("./alloc-native-buffer");
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nativeBufferSubarray =
|
|
3
|
+
exports.nativeBufferSubarray = nativeBufferSubarray;
|
|
4
4
|
const buffer_1 = require("buffer");
|
|
5
5
|
const sliceFallback = !(buffer_1.Buffer.allocUnsafe(1).subarray(0) instanceof buffer_1.Buffer);
|
|
6
6
|
function nativeBufferSubarray(buffer, begin, end) {
|
|
7
7
|
return sliceFallback ? buffer.slice(begin, end) : buffer.subarray(begin, end);
|
|
8
8
|
}
|
|
9
|
-
exports.nativeBufferSubarray = nativeBufferSubarray;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reallocNativeBuffer =
|
|
3
|
+
exports.reallocNativeBuffer = reallocNativeBuffer;
|
|
4
4
|
const alloc_native_buffer_1 = require("./alloc-native-buffer");
|
|
5
5
|
const assert_unsigned_integer_1 = require("./assert-unsigned-integer");
|
|
6
6
|
function reallocNativeBuffer(buffer, newSize, allocSlow) {
|
|
@@ -12,4 +12,3 @@ function reallocNativeBuffer(buffer, newSize, allocSlow) {
|
|
|
12
12
|
buffer.copy(newBuffer, 0, 0, Math.min(buffer.length, newBuffer.length));
|
|
13
13
|
return newBuffer;
|
|
14
14
|
}
|
|
15
|
-
exports.reallocNativeBuffer = reallocNativeBuffer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extended-buffer",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.1",
|
|
4
4
|
"description": "Node JS extended Buffer",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "npm run clean && node ./node_modules/.bin/tsc",
|
|
18
18
|
"test": "node ./node_modules/.bin/mocha",
|
|
19
|
-
"coverage": "node ./node_modules/.bin/nyc --reporter=html --reporter=text ./node_modules/.bin/mocha",
|
|
19
|
+
"coverage": "node ./node_modules/.bin/nyc --reporter=lcov --reporter=html --reporter=text ./node_modules/.bin/mocha",
|
|
20
20
|
"clean": "node -e \"['./dist', './coverage', './.nyc_output'].forEach(item => require('fs').rmSync(item, {recursive:true,force:true}));\"",
|
|
21
|
-
"prepack": "npm run build"
|
|
21
|
+
"prepack": "npm run build && npm run test"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=6.0.0"
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"chai": "^4.5.0",
|
|
60
60
|
"mocha": "^6.2.3",
|
|
61
61
|
"nyc": "^11.9.0",
|
|
62
|
-
"typescript": "^
|
|
62
|
+
"typescript": "^5.9.3"
|
|
63
63
|
}
|
|
64
64
|
}
|