msgpackr 1.5.7 → 1.6.2

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/index.d.ts CHANGED
@@ -1,12 +1,23 @@
1
- export { Unpackr, Decoder, unpack, decode, addExtension, FLOAT32_OPTIONS, clearSource, roundFloat32, isNativeAccelerationEnabled } from './unpack'
2
- import { Options } from './unpack'
3
- export { Packr, Encoder, pack, encode } from './pack'
4
- import { Transform, Readable } from 'stream'
5
-
6
- export as namespace msgpackr;
7
- export class UnpackrStream extends Transform {
8
- constructor(options?: Options | { highWaterMark: number, emitClose: boolean, allowHalfOpen: boolean })
9
- }
10
- export class PackrStream extends Transform {
11
- constructor(options?: Options | { highWaterMark: number, emitClose: boolean, allowHalfOpen: boolean })
12
- }
1
+ export {
2
+ Unpackr,
3
+ Decoder,
4
+ unpack,
5
+ unpackMultiple,
6
+ decode,
7
+ addExtension,
8
+ FLOAT32_OPTIONS,
9
+ clearSource,
10
+ roundFloat32,
11
+ isNativeAccelerationEnabled,
12
+ } from './unpack'
13
+ import { Options } from './unpack'
14
+ export { Packr, Encoder, pack, encode } from './pack'
15
+ import { Transform, Readable } from 'stream'
16
+
17
+ export as namespace msgpackr;
18
+ export class UnpackrStream extends Transform {
19
+ constructor(options?: Options | { highWaterMark: number, emitClose: boolean, allowHalfOpen: boolean })
20
+ }
21
+ export class PackrStream extends Transform {
22
+ constructor(options?: Options | { highWaterMark: number, emitClose: boolean, allowHalfOpen: boolean })
23
+ }
package/node-index.js CHANGED
@@ -1,21 +1,24 @@
1
- export { Packr, Encoder, addExtension, pack, encode, NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } from './pack.js'
2
- export { Unpackr, Decoder, C1, unpack, unpackMultiple, decode, FLOAT32_OPTIONS, clearSource, roundFloat32, isNativeAccelerationEnabled } from './unpack.js'
3
- export { PackrStream, UnpackrStream, PackrStream as EncoderStream, UnpackrStream as DecoderStream } from './stream.js'
4
- export { decodeIter, encodeIter } from './iterators.js'
5
- export const useRecords = false
6
- export const mapsAsObjects = true
7
- import { setExtractor } from './unpack.js'
8
- import { createRequire } from 'module'
9
-
10
- const extractor = tryRequire('msgpackr-extract')
11
- if (extractor)
12
- setExtractor(extractor.extractStrings)
13
-
14
- function tryRequire(moduleId) {
15
- try {
16
- let require = createRequire(import.meta.url)
17
- return require(moduleId)
18
- } catch (error) {
19
- // native module is optional
20
- }
1
+ export { Packr, Encoder, addExtension, pack, encode, NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } from './pack.js'
2
+ export { Unpackr, Decoder, C1, unpack, unpackMultiple, decode, FLOAT32_OPTIONS, clearSource, roundFloat32, isNativeAccelerationEnabled } from './unpack.js'
3
+ export { PackrStream, UnpackrStream, PackrStream as EncoderStream, UnpackrStream as DecoderStream } from './stream.js'
4
+ export { decodeIter, encodeIter } from './iterators.js'
5
+ export const useRecords = false
6
+ export const mapsAsObjects = true
7
+ import { setExtractor } from './unpack.js'
8
+ import { createRequire } from 'module'
9
+
10
+ const nativeAccelerationDisabled = process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED !== undefined && process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase() === 'true';
11
+
12
+ if (!nativeAccelerationDisabled) {
13
+ let extractor
14
+ try {
15
+ if (typeof require == 'function')
16
+ extractor = require('msgpackr-extract')
17
+ else
18
+ extractor = createRequire(import.meta.url)('msgpackr-extract')
19
+ if (extractor)
20
+ setExtractor(extractor.extractStrings)
21
+ } catch (error) {
22
+ // native module is optional
23
+ }
21
24
  }