Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@msgpack/msgpack

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@msgpack/msgpack - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

6

CHANGELOG.md
This is the revision history of @msgpack/msgpack
## v1.3.1 2019/06/01
https://github.com/msgpack/msgpack-javascript/compare/v1.3.0...v1.3.1
* Fix missing exports of `decodeStream()`
## v1.3.0 2019/05/29

@@ -4,0 +10,0 @@

2

dist/decode.d.ts

@@ -31,2 +31,2 @@ import { ExtensionCodecType } from "./ExtensionCodec";

export declare const defaultDecodeOptions: DecodeOptions;
export declare function decode(buffer: ReadonlyArray<number> | Uint8Array, options?: DecodeOptions): unknown;
export declare function decode(buffer: ArrayLike<number>, options?: DecodeOptions): unknown;

@@ -12,4 +12,4 @@ import { DecodeOptions } from "./decode";

}>>;
export declare function decodeAsync(streamLike: ReadableStreamLike<Uint8Array | ArrayLike<number>>, options?: DecodeAsyncOptions): Promise<unknown>;
export declare function decodeArrayStream(streamLike: ReadableStreamLike<Uint8Array | ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterableIterator<unknown>;
export declare function decodeStream(streamLike: ReadableStreamLike<Uint8Array | ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterableIterator<unknown>;
export declare function decodeAsync(streamLike: ReadableStreamLike<ArrayLike<number>>, options?: DecodeAsyncOptions): Promise<unknown>;
export declare function decodeArrayStream(streamLike: ReadableStreamLike<ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterableIterator<unknown>;
export declare function decodeStream(streamLike: ReadableStreamLike<ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterableIterator<unknown>;

@@ -35,10 +35,10 @@ declare enum State {

constructor(extensionCodec?: import("./ExtensionCodec").ExtensionCodecType, maxStrLength?: number, maxBinLength?: number, maxArrayLength?: number, maxMapLength?: number, maxExtLength?: number);
setBuffer(buffer: ArrayLike<number> | Uint8Array): void;
appendBuffer(buffer: Uint8Array | ArrayLike<number>): void;
setBuffer(buffer: ArrayLike<number>): void;
appendBuffer(buffer: ArrayLike<number>): void;
hasRemaining(size?: number): boolean;
createNoExtraBytesError(posToShow: number): RangeError;
decodeOneSync(): unknown;
decodeOneAsync(stream: AsyncIterable<ArrayLike<number> | Uint8Array>): Promise<unknown>;
decodeStream(stream: AsyncIterable<ArrayLike<number> | Uint8Array>): AsyncIterableIterator<unknown>;
decodeArrayStream(stream: AsyncIterable<ArrayLike<number> | Uint8Array>): AsyncIterableIterator<unknown>;
decodeOneAsync(stream: AsyncIterable<ArrayLike<number>>): Promise<unknown>;
decodeStream(stream: AsyncIterable<ArrayLike<number>>): AsyncIterableIterator<unknown>;
decodeArrayStream(stream: AsyncIterable<ArrayLike<number>>): AsyncIterableIterator<unknown>;
decodeSync(): unknown;

@@ -45,0 +45,0 @@ readHeadByte(): number;

export { encode } from "./encode";
export { decode } from "./decode";
export { decodeAsync, decodeArrayStream } from "./decodeAsync";
export { decodeAsync, decodeArrayStream, decodeStream } from "./decodeAsync";
export { Decoder } from "./Decoder";

@@ -5,0 +5,0 @@ export { Encoder } from "./Encoder";

@@ -11,2 +11,3 @@ "use strict";

exports.decodeArrayStream = decodeAsync_1.decodeArrayStream;
exports.decodeStream = decodeAsync_1.decodeStream;
var Decoder_1 = require("./Decoder");

@@ -13,0 +14,0 @@ exports.Decoder = Decoder_1.Decoder;

{
"name": "@msgpack/msgpack",
"version": "1.3.0",
"version": "1.3.1",
"description": "MessagePack for JavaScript/ECMA-262",

@@ -25,3 +25,3 @@ "main": "./dist/index.js",

"cover:clean": "rimraf .nyc_output coverage/",
"cover:report": "nyc report --reporter=lcov --reporter=text-summary --reporter=html",
"cover:report": "nyc report --reporter=text-summary --reporter=html --reporter=json",
"test:browser": "karma start --single-run",

@@ -59,4 +59,4 @@ "test:browser:firefox": "karma start --single-run --browsers FirefoxHeadless",

"@types/base64-js": "^1.2.5",
"@types/mocha": "^5.2.6",
"@types/node": "^11.13.12",
"@types/mocha": "^5.2.7",
"@types/node": "^12.0.4",
"@typescript-eslint/eslint-plugin": "^1.9.0",

@@ -85,6 +85,6 @@ "@typescript-eslint/parser": "^1.9.0",

"rimraf": "^2.6.3",
"ts-loader": "^5.4.5",
"ts-loader": "^6.0.2",
"ts-node": "^8.2.0",
"tsconfig-paths": "^3.8.0",
"typescript": "^3.4.5",
"typescript": "^3.5.1",
"webpack": "^4.30.0",

@@ -91,0 +91,0 @@ "webpack-cli": "^3.3.1"

@@ -49,6 +49,8 @@ # MessagePack for JavaScript/ECMA-262

### `decode(buffer: ArrayLike<number> | Uint8Array, options?: DecodeOptions): unknown`
### `decode(buffer: ArrayLike<number>, options?: DecodeOptions): unknown`
It decodes `buffer` in a byte buffer and returns decoded data as `uknown`.
It decodes `buffer` encoded as MessagePack, and returns a decoded object as `uknown`.
`buffer` must be an array of bytes, which is typically `Uint8Array`.
#### DecodeOptions

@@ -67,10 +69,25 @@

### `decodeAsync(stream: AsyncIterable<Uint8Array | ArrayLike<number>> | ReadableStream<Uint8Array | ArrayLike<number>>, options?: DecodeAsyncOptions): Promise<unknown>`
### `decodeAsync(stream: AsyncIterable<ArrayLike<number>> | ReadableStream<ArrayLike<number>>, options?: DecodeAsyncOptions): Promise<unknown>`
It decodes `stream` in an async iterable of byte arrays and returns decoded data as `uknown` wrapped in `Promise`. This function works asyncronously.
It decodes `stream` in an async iterable of byte arrays, and returns decoded object as `uknown` type, wrapped in `Promise`. This function works asyncronously.
Note that `decodeAsync()` acceps the same options as `decode()`.
`DecodeAsyncOptions` is the same as `DecodeOptions` for `decode()`.
### `decodeArrayStream(stream: AsyncIterable<Uint8Array | ArrayLike<number>> | ReadableStream<Uint8Array | ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`
This function is designed to work with whatwg `fetch()` like this:
```typescript
import { decodeAsync } from "@msgpack/msgpack";
const MSGPACK_TYPE = "application/x-msgpack";
const response = await fetch(url);
const contentType = response.headers.get("Content-Type");
if (contentType && contentType.startsWith(MSGPACK_TYPE) && response.body != null) {
const object = await decodeAsync(response.body);
// do something with object
} else { /* handle errors */ }
```
### `decodeArrayStream(stream: AsyncIterable< ArrayLike<number>> | ReadableStream<ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`
It is alike to `decodeAsync()`, but only accepts an array of items as the input `stream`, and emits the decoded item one by one.

@@ -80,3 +97,3 @@

### `decodeStream(stream: AsyncIterable<Uint8Array | ArrayLike<number>> | ReadableStream<Uint8Array | ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`
### `decodeStream(stream: AsyncIterable<ArrayLike<number>> | ReadableStream<ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`

@@ -172,4 +189,8 @@ It is like to `decodeAsync()` and `decodeArrayStream()`, but the input `stream` consists of independent MessagePack items.

This library maps `Date` to the MessagePack timestamp extension, but you re-map the [temporal module](https://github.com/tc39/proposal-temporal) to the timestamp ext like this:
There is a proposal for a new date/time representations in JavaScript:
* https://github.com/tc39/proposal-temporal
This library maps `Date` to the MessagePack timestamp extension by default, but you can re-map the temporal module (or [@std-proposal/temporal ponyfill](https://github.com/tc39/proposal-temporal)) to the timestamp extension like this:
```typescript

@@ -213,3 +234,3 @@ import { Instant } from "@std-proposal/temporal";

This will be default after the temporal module is implemented in major browsers, which is not a near-future, though.
This will be default once the temporal module is standardizied, which is not a near-future, though.

@@ -304,2 +325,5 @@ ## MessagePack Mapping Table

# bump version
npm version patch|minor|major
# run the publishing task

@@ -306,0 +330,0 @@ make publish

@@ -38,6 +38,3 @@ import { ExtensionCodecType } from "./ExtensionCodec";

export function decode(
buffer: ReadonlyArray<number> | Uint8Array,
options: DecodeOptions = defaultDecodeOptions,
): unknown {
export function decode(buffer: ArrayLike<number>, options: DecodeOptions = defaultDecodeOptions): unknown {
const decoder = new Decoder(

@@ -44,0 +41,0 @@ options.extensionCodec,

@@ -9,3 +9,3 @@ import { Decoder } from "./Decoder";

export async function decodeAsync(
streamLike: ReadableStreamLike<Uint8Array | ArrayLike<number>>,
streamLike: ReadableStreamLike<ArrayLike<number>>,
options: DecodeAsyncOptions = defaultDecodeOptions,

@@ -27,3 +27,3 @@ ): Promise<unknown> {

export function decodeArrayStream(
streamLike: ReadableStreamLike<Uint8Array | ArrayLike<number>>,
streamLike: ReadableStreamLike<ArrayLike<number>>,
options: DecodeAsyncOptions = defaultDecodeOptions,

@@ -46,3 +46,3 @@ ) {

export function decodeStream(
streamLike: ReadableStreamLike<Uint8Array | ArrayLike<number>>,
streamLike: ReadableStreamLike<ArrayLike<number>>,
options: DecodeAsyncOptions = defaultDecodeOptions,

@@ -49,0 +49,0 @@ ) {

@@ -71,3 +71,3 @@ import { prettyByte } from "./utils/prettyByte";

setBuffer(buffer: ArrayLike<number> | Uint8Array): void {
setBuffer(buffer: ArrayLike<number>): void {
this.bytes = ensureUint8Array(buffer);

@@ -78,3 +78,3 @@ this.view = createDataView(this.bytes);

appendBuffer(buffer: Uint8Array | ArrayLike<number>) {
appendBuffer(buffer: ArrayLike<number>) {
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining()) {

@@ -110,3 +110,3 @@ this.setBuffer(buffer);

async decodeOneAsync(stream: AsyncIterable<ArrayLike<number> | Uint8Array>): Promise<unknown> {
async decodeOneAsync(stream: AsyncIterable<ArrayLike<number>>): Promise<unknown> {
let decoded = false;

@@ -146,3 +146,3 @@ let object: unknown;

async *decodeStream(stream: AsyncIterable<ArrayLike<number> | Uint8Array>) {
async *decodeStream(stream: AsyncIterable<ArrayLike<number>>) {
for await (const buffer of stream) {

@@ -166,3 +166,3 @@ this.appendBuffer(buffer);

async *decodeArrayStream(stream: AsyncIterable<ArrayLike<number> | Uint8Array>) {
async *decodeArrayStream(stream: AsyncIterable<ArrayLike<number>>) {
let headerParsed = false;

@@ -169,0 +169,0 @@ let decoded = false;

@@ -5,3 +5,3 @@ // Main Functions:

export { decode } from "./decode";
export { decodeAsync, decodeArrayStream } from "./decodeAsync";
export { decodeAsync, decodeArrayStream, decodeStream } from "./decodeAsync";

@@ -8,0 +8,0 @@ export { Decoder } from "./Decoder";

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc