Skip to content

Commit a038c54

Browse files
committed
Update package name and readme
1 parent b92d75b commit a038c54

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

Diff for: README.md

+36-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
[![npm version](https://img.shields.io/npm/v/@msgpack/msgpack.svg)](https://www.npmjs.com/package/@msgpack/msgpack) ![CI](https://github.com/msgpack/msgpack-javascript/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/msgpack/msgpack-javascript/branch/master/graphs/badge.svg)](https://codecov.io/gh/msgpack/msgpack-javascript) [![minzip](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) [![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack)
44

5+
> NOTE: This library is a fork of [msgpack/msgpack-javascript](https://github.com/msgpack/msgpack-javascript), with the following changes:
6+
>
7+
> - Improved bigint support. Bigints are no longer solely encoded as int64/uint64, which allows for greater compatibility with other MessagePack libraries. Additional decoding options are available as well.
8+
> - Raw string decoding support. When decoding, strings can be decoded as Uint8Arrays. This supports reading non-UTF-8 encoded strings.
9+
> - Number and binary map key support with Maps.
10+
>
11+
> The exact changes can be viewed [in this comparison](https://github.com/msgpack/msgpack-javascript/compare/1fc7622...algorand:msgpack-javascript:main).
12+
513
This library is an implementation of **MessagePack** for TypeScript and JavaScript, providing a compact and efficient binary serialization format. Learn more about MessagePack at:
614

715
https://msgpack.org/
@@ -115,16 +123,13 @@ console.log(buffer);
115123
| extensionCodec | ExtensionCodec | `ExtensionCodec.defaultCodec` |
116124
| context | user-defined | - |
117125
| forceBigIntToInt64 | boolean | false |
118-
| useRawBinaryStrings | boolean | false |
119126
| maxDepth | number | `100` |
120127
| initialBufferSize | number | `2048` |
121128
| sortKeys | boolean | false |
122129
| forceFloat32 | boolean | false |
123130
| forceIntegerToFloat | boolean | false |
124131
| ignoreUndefined | boolean | false |
125132

126-
To skip UTF-8 decoding of strings, `useRawBinaryStrings` can be set to `true`. In this case, strings are decoded into `Uint8Array`.
127-
128133
### `decode(buffer: ArrayLike<number> | BufferSource, options?: DecoderOptions): unknown`
129134

130135
It decodes `buffer` that includes a MessagePack-encoded object, and returns the decoded object typed `unknown`.
@@ -147,22 +152,30 @@ NodeJS `Buffer` is also acceptable because it is a subclass of `Uint8Array`.
147152

148153
#### `DecoderOptions`
149154

150-
| Name | Type | Default |
151-
| -------------- | -------------- | ------------------------------------------------------------------------------------ |
152-
| extensionCodec | ExtensionCodec | `ExtensionCodec.defaultCodec` |
153-
| context | user-defined | - |
154-
| useBigInt64 | boolean | false |
155-
| intMode | IntMode | `IntMode.AS_ENCODED` if `useBigInt64` is `true` or `IntMode.UNSAFE_NUMBER` otherwise |
156-
| maxStrLength | number | `4_294_967_295` (UINT32_MAX) |
157-
| maxBinLength | number | `4_294_967_295` (UINT32_MAX) |
158-
| maxArrayLength | number | `4_294_967_295` (UINT32_MAX) |
159-
| maxMapLength | number | `4_294_967_295` (UINT32_MAX) |
160-
| maxExtLength | number | `4_294_967_295` (UINT32_MAX) |
155+
| Name | Type | Default |
156+
| ----------------------- | -------------- | ------------------------------------------------------------------------------------ |
157+
| extensionCodec | ExtensionCodec | `ExtensionCodec.defaultCodec` |
158+
| context | user-defined | - |
159+
| useBigInt64 | boolean | false |
160+
| intMode | IntMode | `IntMode.AS_ENCODED` if `useBigInt64` is `true` or `IntMode.UNSAFE_NUMBER` otherwise |
161+
| rawBinaryStringKeys | boolean | false |
162+
| rawBinaryStringValues | boolean | false |
163+
| useMap | boolean | false |
164+
| supportObjectNumberKeys | boolean | false |
165+
| maxStrLength | number | `4_294_967_295` (UINT32_MAX) |
166+
| maxBinLength | number | `4_294_967_295` (UINT32_MAX) |
167+
| maxArrayLength | number | `4_294_967_295` (UINT32_MAX) |
168+
| maxMapLength | number | `4_294_967_295` (UINT32_MAX) |
169+
| maxExtLength | number | `4_294_967_295` (UINT32_MAX) |
161170

162171
You can use `max${Type}Length` to limit the length of each type decoded.
163172

164173
`intMode` determines whether decoded integers should be returned as numbers or bigints in different circumstances. The possible values are [described below](#intmode).
165174

175+
To skip UTF-8 decoding of strings, one or both of `rawBinaryStringKeys` and `rawBinaryStringValues` can be set to `true`. If enabled, strings are decoded into `Uint8Array`. `rawBinaryStringKeys` affects only map keys, while `rawBinaryStringValues` affect all other string values.
176+
177+
If `useMap` is enabled, maps are decoded into the `Map` container instead of plain objects. `Map` objects support a wider range of key types. Plain objects only support string keys (though you can enable `supportObjectNumberKeys` to coerce number keys to strings), while `Map` objects support strings, numbers, bigints, and Uint8Arrays.
178+
166179
##### `IntMode`
167180

168181
The `IntMode` enum defines different options for decoding integers. They are described below:
@@ -532,12 +545,12 @@ The mapping of integers varies on the setting of `intMode`.
532545
| Date | timestamp ext family | Date (\*6) |
533546
| bigint | int family | bigint |
534547

535-
* \*1 Both `null` and `undefined` are mapped to `nil` (`0xC0`) type, and are decoded into `null`
536-
* \*2 MessagePack ints are decoded as either numbers or bigints depending on the [IntMode](#intmode) used during decoding.
537-
* \*3 If you'd like to skip UTF-8 decoding of strings, set `useRawBinaryStrings: true`. In this case, strings are decoded into `Uint8Array`.
538-
* \*4 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
539-
* \*5 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
540-
* \*6 MessagePack timestamps may have nanoseconds, which will lost when it is decoded into JavaScript `Date`. This behavior can be overridden by registering `-1` for the extension codec.
548+
- \*1 Both `null` and `undefined` are mapped to `nil` (`0xC0`) type, and are decoded into `null`
549+
- \*2 MessagePack ints are decoded as either numbers or bigints depending on the [IntMode](#intmode) used during decoding.
550+
- \*3 If you'd like to skip UTF-8 decoding of strings, enable one of `rawBinaryStringKeys` or `rawBinaryStringValues`. In that case, strings are decoded into `Uint8Array`.
551+
- \*4 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
552+
- \*5 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
553+
- \*6 MessagePack timestamps may have nanoseconds, which will lost when it is decoded into JavaScript `Date`. This behavior can be overridden by registering `-1` for the extension codec.
541554

542555
If you set `useBigInt64: true`, the following mapping is used:
543556

@@ -554,9 +567,10 @@ If you set `useBigInt64: true`, the following mapping is used:
554567
| Object | map family | Object |
555568
| Date | timestamp ext family | Date |
556569

557-
* \*6 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
570+
- \*6 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
571+
572+
- \*7 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
558573

559-
* \*7 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
560574
## Prerequisites
561575

562576
This is a universal JavaScript library that supports major browsers and NodeJS.

Diff for: package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@msgpack/msgpack",
2+
"name": "algorand-msgpack",
33
"version": "3.0.0-beta2",
44
"description": "MessagePack for ECMA-262/JavaScript/TypeScript",
5-
"author": "The MessagePack community",
5+
"author": "Algorand Technologies & the MessagePack community",
66
"license": "ISC",
77
"main": "./dist/index.js",
88
"module": "./dist.es5+esm/index.mjs",
@@ -35,10 +35,10 @@
3535
"homepage": "https://msgpack.org/",
3636
"repository": {
3737
"type": "git",
38-
"url": "https://github.com/msgpack/msgpack-javascript.git"
38+
"url": "https://github.com/algorand/msgpack-javascript.git"
3939
},
4040
"bugs": {
41-
"url": "https://github.com/msgpack/msgpack-javascript/issues"
41+
"url": "https://github.com/algorand/msgpack-javascript/issues"
4242
},
4343
"keywords": [
4444
"msgpack",

0 commit comments

Comments
 (0)