Permalink
Browse files

Add support for long strings, fixes #509

  • Loading branch information...
dcodeIO committed Dec 1, 2016
1 parent 6e5fdb6 commit 799c1c1a84b255d1831cc84c3d24e61b36fa2530

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -9 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -66,9 +66,10 @@ LongBits.fromNumber = function fromNumber(value) {
};
/**
* Constrcuts new long bits from a number or long.
* @param {Long|number} value Value
* Constructs new long bits from a number, long or string.
* @param {Long|number|string} value Value
* @returns {util.LongBits} Instance
* @throws {TypeError} If `value` is a string and no long library is present.
*/
LongBits.from = function from(value) {
switch (typeof value) {
@@ -214,8 +214,9 @@ function writeVarint64(buf, pos, val) {
/**
* Writes an unsigned 64 bit value as a varint.
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
WriterPrototype.uint64 = function write_uint64(value) {
var bits = LongBits.from(value);
@@ -225,15 +226,17 @@ WriterPrototype.uint64 = function write_uint64(value) {
/**
* Writes a signed 64 bit value as a varint.
* @function
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
WriterPrototype.int64 = WriterPrototype.uint64;
/**
* Writes a signed 64 bit value as a varint, zig-zag encoded.
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
WriterPrototype.sint64 = function sint64(value) {
var bits = LongBits.from(value).zzEncode();
@@ -286,11 +289,13 @@ WriterPrototype.fixed64 = function write_fixed64(value) {
/**
* Writes a 64 bit value as fixed 64 bits, zig-zag encoded.
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
WriterPrototype.sfixed64 = function write_sfixed64(value) {
return this.push(writeFixed64, 8, LongBits.from(value).zzEncode());
var bits = LongBits.from(value).zzEncode();
return this.push(writeFixed32, 4, bits.hi).push(writeFixed32, 4, bits.lo);
};
function writeFloat(buf, pos, val) {
@@ -3,7 +3,7 @@
/*
* protobuf.js v6.0.1 TypeScript definitions
* Generated Wed, 30 Nov 2016 22:50:15 UTC
* Generated Thu, 01 Dec 2016 10:14:01 UTC
*/
declare module protobuf {
@@ -1595,11 +1595,12 @@ declare module protobuf {
static fromNumber(value: number): util.LongBits;
/**
* Constrcuts new long bits from a number or long.
* @param {Long|number} value Value
* Constructs new long bits from a number, long or string.
* @param {Long|number|string} value Value
* @returns {util.LongBits} Instance
* @throws {TypeError} If `value` is a string and no long library is present.
*/
static from(value: (Long|number)): util.LongBits;
static from(value: (Long|number|string)): util.LongBits;
/**
* Converts this long bits to a possibly unsafe JavaScript number.
@@ -1925,25 +1926,28 @@ declare module protobuf {
/**
* Writes an unsigned 64 bit value as a varint.
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
uint64(value: (Long|number)): Writer;
uint64(value: (Long|number|string)): Writer;
/**
* Writes a signed 64 bit value as a varint.
* @function
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
int64(value: (Long|number)): Writer;
int64(value: (Long|number|string)): Writer;
/**
* Writes a signed 64 bit value as a varint, zig-zag encoded.
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
sint64(value: (Long|number)): Writer;
sint64(value: (Long|number|string)): Writer;
/**
* Writes a boolish value as a varint.
@@ -1975,10 +1979,11 @@ declare module protobuf {
/**
* Writes a 64 bit value as fixed 64 bits, zig-zag encoded.
* @param {Long|number} value Value to write
* @param {Long|number|string} value Value to write
* @returns {Writer} `this`
* @throws {TypeError} If `value` is a string and no long library is present.
*/
sfixed64(value: (Long|number)): Writer;
sfixed64(value: (Long|number|string)): Writer;
/**
* Writes a float (32 bit).

0 comments on commit 799c1c1

Please sign in to comment.