-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Substitute lodash calls in bitcore-lib #3350
base: master
Are you sure you want to change the base?
Changes from all commits
65d42f3
6f0a0ab
ed75389
9063482
36942f2
3ee7b35
ac1d7b9
ee5e904
4c62827
0262431
0bdc2d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
var BN = require('bn.js'); | ||
var $ = require('../util/preconditions'); | ||
var _ = require('lodash'); | ||
|
||
var reversebuf = function(buf) { | ||
var buf2 = Buffer.alloc(buf.length); | ||
|
@@ -17,17 +16,17 @@ BN.One = new BN(1); | |
BN.Minus1 = new BN(-1); | ||
|
||
BN.fromNumber = function(n) { | ||
$.checkArgument(_.isNumber(n)); | ||
$.checkArgument(typeof n === 'number'); | ||
return new BN(n); | ||
}; | ||
|
||
BN.fromString = function(str, base) { | ||
$.checkArgument(_.isString(str)); | ||
$.checkArgument(typeof str === 'string'); | ||
return new BN(str, base); | ||
}; | ||
|
||
BN.fromBuffer = function(buf, opts) { | ||
if (typeof opts !== 'undefined' && opts.endian === 'little') { | ||
if (opts !== undefined && opts.endian === 'little') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably make
and
Same on line 89 Maybe consider changing all checks for undefined to checks for null as well (i.e. |
||
buf = reversebuf(buf); | ||
} | ||
var hex = buf.toString('hex'); | ||
|
@@ -87,7 +86,7 @@ BN.prototype.toBuffer = function(opts) { | |
buf = Buffer.from(hex, 'hex'); | ||
} | ||
|
||
if (typeof opts !== 'undefined' && opts.endian === 'little') { | ||
if (opts !== undefined && opts.endian === 'little') { | ||
buf = reversebuf(buf); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is false if
data.prevHash instanceof String
, whereas_.isString(new String('')) == true