Skip to content

Commit

Permalink
Merge pull request #1 from dreamershl/string-support
Browse files Browse the repository at this point in the history
add string support to fix the protobufjs#508
  • Loading branch information
dreamershl authored Dec 1, 2016
2 parents b233c43 + 5260ba9 commit e052d79
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 e052d79

Please sign in to comment.