add utils.isBytes.
This commit is contained in:
parent
1754e7ee77
commit
6f86ca2d02
@ -990,12 +990,8 @@ script.size = function size(s) {
|
|||||||
return bcoin.script.encode(s).length;
|
return bcoin.script.encode(s).length;
|
||||||
};
|
};
|
||||||
|
|
||||||
script.isEncoded = function(s) {
|
script.isEncoded = function isEncoded(s) {
|
||||||
for (var i = 0; i < s.length; i++) {
|
return utils.isBytes(s);
|
||||||
if (typeof s[i] !== 'number')
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
script.normalize = function normalize(s) {
|
script.normalize = function normalize(s) {
|
||||||
|
|||||||
@ -701,6 +701,20 @@ utils.toBuffer = function toBuffer(msg) {
|
|||||||
throw new Error('Cannot ensure buffer');
|
throw new Error('Cannot ensure buffer');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
utils.isBytes = function isBytes(data) {
|
||||||
|
var i;
|
||||||
|
|
||||||
|
if (!Array.isArray(data))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (i = 0; i < data.length; i++) {
|
||||||
|
if (typeof data[i] !== 'number')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
utils._inspect = function inspect(obj) {
|
utils._inspect = function inspect(obj) {
|
||||||
return typeof obj !== 'string'
|
return typeof obj !== 'string'
|
||||||
? util.inspect(obj, null, 20, true)
|
? util.inspect(obj, null, 20, true)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user