Skip to content

Commit

Permalink
add string support to fix the protobufjs#508
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamershl committed Dec 1, 2016
1 parent d3ae961 commit 5260ba9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/util/longbits.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ LongBits.fromNumber = function fromNumber(value) {
* @returns {util.LongBits} Instance
*/
LongBits.from = function from(value) {
return typeof value === 'number'
? LongBits.fromNumber(value)
: new LongBits(value.low >>> 0, value.high >>> 0);
var type = typeof value, result=zero;
if(type === 'number')
result = LongBits.fromNumber(value);
else if(type === 'string' && util.Long)
result = util.Long.fromString(value);
else
result = new LongBits(value.low >>> 0, value.high >>> 0);
return result;
};

/**
Expand Down

0 comments on commit 5260ba9

Please sign in to comment.