@protobuf-ts/runtime
Advanced tools
Comparing version 2.1.0 to 2.2.0-alpha.0
@@ -6,6 +6,5 @@ "use strict"; | ||
const pb_long_1 = require("./pb-long"); | ||
const protobufjs_utf8_1 = require("./protobufjs-utf8"); | ||
const goog_varint_1 = require("./goog-varint"); | ||
class BinaryReader { | ||
constructor(buf) { | ||
constructor(buf, textDecoder) { | ||
this.varint64 = goog_varint_1.varint64read; // dirty cast for `this` | ||
@@ -20,2 +19,5 @@ /** | ||
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); | ||
this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder("utf-8", { | ||
fatal: true | ||
}); | ||
} | ||
@@ -168,5 +170,5 @@ /** | ||
string() { | ||
return protobufjs_utf8_1.utf8read(this.bytes()); | ||
return this.textDecoder.decode(this.bytes()); | ||
} | ||
} | ||
exports.BinaryReader = BinaryReader; |
@@ -32,2 +32,7 @@ "use strict"; | ||
/** | ||
* @deprecated This function will no longer be exported with the next major | ||
* release, since protobuf-ts has switch to TextDecoder API. If you need this | ||
* function, please migrate to @protobufjs/utf8. For context, see | ||
* https://github.com/timostamm/protobuf-ts/issues/184 | ||
* | ||
* Reads UTF8 bytes as a string. | ||
@@ -34,0 +39,0 @@ * |
import { WireType } from "./binary-format-contract"; | ||
import { PbLong, PbULong } from "./pb-long"; | ||
import { utf8read } from "./protobufjs-utf8"; | ||
import { varint32read, varint64read } from "./goog-varint"; | ||
export class BinaryReader { | ||
constructor(buf) { | ||
constructor(buf, textDecoder) { | ||
this.varint64 = varint64read; // dirty cast for `this` | ||
@@ -16,2 +15,5 @@ /** | ||
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); | ||
this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder("utf-8", { | ||
fatal: true | ||
}); | ||
} | ||
@@ -164,4 +166,4 @@ /** | ||
string() { | ||
return utf8read(this.bytes()); | ||
return this.textDecoder.decode(this.bytes()); | ||
} | ||
} |
@@ -29,2 +29,7 @@ // Copyright (c) 2016, Daniel Wirtz All rights reserved. | ||
/** | ||
* @deprecated This function will no longer be exported with the next major | ||
* release, since protobuf-ts has switch to TextDecoder API. If you need this | ||
* function, please migrate to @protobufjs/utf8. For context, see | ||
* https://github.com/timostamm/protobuf-ts/issues/184 | ||
* | ||
* Reads UTF8 bytes as a string. | ||
@@ -31,0 +36,0 @@ * |
import type { IBinaryReader } from "./binary-format-contract"; | ||
import { WireType } from "./binary-format-contract"; | ||
import { PbLong, PbULong } from "./pb-long"; | ||
/** | ||
* TextDecoderLike is the subset of the TextDecoder API required by protobuf-ts. | ||
*/ | ||
interface TextDecoderLike { | ||
decode(input?: Uint8Array): string; | ||
} | ||
export declare class BinaryReader implements IBinaryReader { | ||
@@ -15,3 +21,4 @@ /** | ||
private readonly view; | ||
constructor(buf: Uint8Array); | ||
private readonly textDecoder; | ||
constructor(buf: Uint8Array, textDecoder?: TextDecoderLike); | ||
/** | ||
@@ -92,1 +99,2 @@ * Reads a tag - field number and wire type. | ||
} | ||
export {}; |
import type { IBinaryWriter } from "./binary-format-contract"; | ||
import type { WireType } from "./binary-format-contract"; | ||
/** | ||
* TextEncoderLike is the subset of the TextEncoder API required by protobuf-ts. | ||
*/ | ||
interface TextEncoderLike { | ||
encode(input?: string): Uint8Array; | ||
} | ||
export declare class BinaryWriter implements IBinaryWriter { | ||
@@ -29,3 +35,3 @@ /** | ||
private readonly textEncoder; | ||
constructor(textEncoder?: TextEncoder); | ||
constructor(textEncoder?: TextEncoderLike); | ||
/** | ||
@@ -120,1 +126,2 @@ * Return all bytes written and reset this writer. | ||
} | ||
export {}; |
/** | ||
* @deprecated This function will no longer be exported with the next major | ||
* release, since protobuf-ts has switch to TextDecoder API. If you need this | ||
* function, please migrate to @protobufjs/utf8. For context, see | ||
* https://github.com/timostamm/protobuf-ts/issues/184 | ||
* | ||
* Reads UTF8 bytes as a string. | ||
@@ -3,0 +8,0 @@ * |
{ | ||
"name": "@protobuf-ts/runtime", | ||
"version": "2.1.0", | ||
"version": "2.2.0-alpha.0", | ||
"description": "Runtime library for code generated by the protoc plugin \"protobuf-ts\"", | ||
@@ -40,3 +40,3 @@ "license": "(Apache-2.0 AND BSD-3-Clause)", | ||
}, | ||
"gitHead": "bc8be3ac6a109d66d3c602b1309e136980933c1d" | ||
"gitHead": "a5f300a2bcaad58fe20b91952e12bc78743b1153" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
342382
8695
1