Skip to content

Commit afff6d9

Browse files
committed
Merge remote-tracking branch 'origin/main' into webpack5
2 parents e0e73f4 + 0718e10 commit afff6d9

26 files changed

+5269
-11510
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ module.exports = {
4141
{ "selector": "typeLike", "format": ["PascalCase"], "leadingUnderscore": "allow" },
4242
],
4343
"@typescript-eslint/restrict-plus-operands": ["warn", { "checkCompoundAssignments": true }],
44-
"@typescript-eslint/no-non-null-assertion": "warn", // NOTE: pay attention to it because it may cause unexpected behavior
4544
"@typescript-eslint/no-throw-literal": "warn",
4645
"@typescript-eslint/no-extra-semi": "warn",
4746
"@typescript-eslint/no-extra-non-null-assertion": "warn",
@@ -53,6 +52,8 @@ module.exports = {
5352
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
5453
"@typescript-eslint/no-invalid-void-type": "warn",
5554
"@typescript-eslint/no-loss-of-precision": "warn",
55+
"@typescript-eslint/no-confusing-void-expression": "warn",
56+
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
5657
"@typescript-eslint/prefer-for-of": "warn",
5758
"@typescript-eslint/prefer-includes": "warn",
5859
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
@@ -68,6 +69,7 @@ module.exports = {
6869
"@typescript-eslint/no-empty-interface": "off",
6970
"@typescript-eslint/no-empty-function": "off",
7071
"@typescript-eslint/no-var-requires": "off",
72+
"@typescript-eslint/no-non-null-assertion": "off",
7173
"@typescript-eslint/ban-ts-comment": "off",
7274
},
7375
};

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
nodejs:
11+
runs-on: ubuntu-20.04
12+
13+
strategy:
14+
matrix:
15+
node-version: ['12', '14']
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Setup Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- run: npm install -g npm
26+
- run: npm install -g nyc codecov
27+
- run: npm ci
28+
- run: npm run test:cover
29+
- run: codecov -f coverage/*.json
30+
31+
browser:
32+
runs-on: ubuntu-20.04
33+
strategy:
34+
matrix:
35+
browser: [ChromeHeadless, FirefoxHeadless]
36+
steps:
37+
- uses: actions/checkout@v2
38+
39+
- name: Setup Node.js ${{ matrix.node-version }}
40+
uses: actions/setup-node@v1
41+
with:
42+
node-version: '14'
43+
44+
- run: npm install -g npm
45+
- run: npm ci
46+
- run: npm run test:browser -- --browsers ${{ matrix.browser }}
47+

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ matrix:
4141
- env: BROWSER=slAndroid
4242
cache: npm
4343
install: |
44+
npm install -g npm
4445
if [ "${BROWSER}" = "" ]
4546
then npm install -g nyc codecov
4647
fi

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
This is the revision history of @msgpack/msgpack
22

3+
## v2.3.0 2020/10/17
4+
5+
https://github.com/msgpack/msgpack-javascript/compare/v2.2.1...v2.3.0
6+
7+
* Change the extension of ESM files from `.js` to `.mjs` [#144](https://github.com/msgpack/msgpack-javascript/pull/144)
8+
* Make the package work with `strictNullChecks: false` [#139](https://github.com/msgpack/msgpack-javascript/pull/139) by @bananaumai
9+
310
## v2.2.1 2020/10/11
411

512
https://github.com/msgpack/msgpack-javascript/compare/v2.2.0...v2.2.1

README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# MessagePack for JavaScript/ECMA-262
22

3-
[![npm version](https://img.shields.io/npm/v/@msgpack/msgpack.svg)](https://www.npmjs.com/package/@msgpack/msgpack) [![Build Status](https://travis-ci.org/msgpack/msgpack-javascript.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-javascript) [![codecov](https://codecov.io/gh/msgpack/msgpack-javascript/branch/master/graphs/badge.svg)](https://codecov.io/gh/msgpack/msgpack-javascript) [![bundlephobia](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack)
3+
[![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) [![bundlephobia](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack)
44

5-
[![Browser Matrix powered by Sauce Labs](https://saucelabs.com/browser-matrix/gfx2019.svg)](https://saucelabs.com)
5+
<!--
6+
[![Browser Matrix powered by Sauce Labs](https://app.saucelabs.com/browser-matrix/gfx2019.svg)](https://app.saucelabs.com/u/gfx2019) -->
67

78
This is a JavaScript/ECMA-262 implementation of **MessagePack**, an efficient binary serilization format:
89

@@ -57,7 +58,7 @@ deepStrictEqual(decode(encoded), object);
5758
- [Decoding a Blob](#decoding-a-blob)
5859
- [MessagePack Specification](#messagepack-specification)
5960
- [MessagePack Mapping Table](#messagepack-mapping-table)
60-
- [Prerequsites](#prerequsites)
61+
- [Prerequisites](#prerequisites)
6162
- [ECMA-262](#ecma-262)
6263
- [NodeJS](#nodejs)
6364
- [TypeScript](#typescript)
@@ -70,7 +71,6 @@ deepStrictEqual(decode(encoded), object);
7071
- [Continuous Integration](#continuous-integration)
7172
- [Release Engineering](#release-engineering)
7273
- [Updating Dependencies](#updating-dependencies)
73-
- [Big Thanks](#big-thanks)
7474
- [License](#license)
7575

7676
<!-- /TOC -->
@@ -125,9 +125,9 @@ context | user-defined | -
125125

126126
### `decode(buffer: ArrayLike<number> | ArrayBuffer, options?: DecodeOptions): unknown`
127127

128-
It decodes `buffer` encoded in MessagePack, and returns a decoded object as `uknown`.
128+
It decodes `buffer` encoded in MessagePack, and returns a decoded object as `unknown`.
129129

130-
`buffer` must be an array of bytes, which is typically `Uint8Array`, or `ArrayBuffer`.
130+
`buffer` must be an array of bytes, which is typically `Uint8Array` or `ArrayBuffer`, but `Array<number>` is okay.
131131

132132
for example:
133133

@@ -215,6 +215,22 @@ for await (const item of decodeStream(stream)) {
215215
}
216216
```
217217

218+
If you have a multi-values MessagePack binary, you can use `decodeStream()`, but you need to convert it to a stream or an async generator like this:
219+
220+
```typescript
221+
// A function that generates an AsyncGenerator
222+
const createStream = async function* (): AsyncGenerator<Uint8Array> {
223+
yield encoded;
224+
};
225+
226+
const result: Array<unknown> = [];
227+
228+
// Decodes it with for-await
229+
for await (const item of decodeStream(createStream())) {
230+
result.push(item);
231+
}
232+
```
233+
218234
### Reusing Encoder and Decoder instances
219235

220236
`Encoder` and `Decoder` classes is provided for better performance:
@@ -461,7 +477,7 @@ Date|timestamp ext family|Date (*4)
461477
* *3 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
462478
* *4 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.
463479

464-
## Prerequsites
480+
## Prerequisites
465481

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

@@ -519,17 +535,17 @@ Note that `Buffer.from()` for `JSON.stringify()` is necessary to emulate I/O whe
519535

520536
The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files:
521537

522-
* `dist/` is compiled into ES2015+, provided for NodeJS v10 or later
523-
* `dist.es5+umd/` is compiled into ES5 with UMD-style single file
524-
* `dist.es5+umd/msgpack.min.js` - the default, minified file (UMD)
525-
* `dist.es5+umd/msgpack.js` - an optional, non-minified file (UMD)
526-
* `dist.es5+esm/` is compiled into ES5 and placed as ES modules, provided for webpack-like bundlers, not NodeJS
538+
* `dist/` is compiled into ES2019 with CommomJS, provided for NodeJS v10
539+
* `dist.es5+umd/` is compiled into ES5 with UMD
540+
* `dist.es5+umd/msgpack.min.js` - the minified file
541+
* `dist.es5+umd/msgpack.js` - the non-minified file
542+
* `dist.es5+esm/` is compiled into ES5 with ES modules, provided for webpack-like bundlers and NodeJS's ESM-mode
527543

528544
If you use NodeJS and/or webpack, their module resolvers use the suitable one automatically.
529545

530546
### CDN / unpkg.com
531547

532-
This library is availble via CDN:
548+
This library is available via CDN:
533549

534550
```html
535551
<script crossorigin src="https://unpkg.com/@msgpack/msgpack"></script>
@@ -556,7 +572,7 @@ test matrix:
556572
* TypeScript targets
557573
* `target=es2019` / `target=es5`
558574
* JavaScript engines
559-
* NodeJS, borwsers (Chrome, Firefox, Safari, IE11, and so on)
575+
* NodeJS, browsers (Chrome, Firefox, Safari, IE11, and so on)
560576

561577
See [test:* in package.json](./package.json) and [.travis.yml](./.travis.yml) for details.
562578

@@ -582,11 +598,11 @@ make publish
582598
npm run update-dependencies
583599
```
584600

585-
## Big Thanks
601+
<!-- ## Big Thanks
586602
587603
Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs.
588604
589-
<a href="https://saucelabs.com"><img src="./assets/SauceLabs.svg" alt="Sauce Labs" width="280"></a>
605+
<a href="https://saucelabs.com"><img src="./assets/SauceLabs.svg" alt="Sauce Labs" width="280"></a> -->
590606

591607
## License
592608

karma.conf.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ export default function configure(config: any) {
3939
webpack: {
4040
mode: "production",
4141

42-
// Handles NodeJS polyfills
43-
// https://webpack.js.org/configuration/node
44-
// Note that the dependencies in https://github.com/webpack/node-libs-browser are sometimes too old.
45-
node: {
46-
assert: false,
47-
util: false,
48-
},
4942
resolve: {
5043
extensions: [".ts", ".tsx", ".mjs", ".js", ".json", ".wasm"],
5144
alias: {

0 commit comments

Comments
 (0)