Node.js SlowBuffer detection
Node.js SlowBuffer detection
我向缓冲区类添加了一个xor方法,以确保argument instanceof Buffer
。require('crypto')
有一个randomBytes方法,它给出一个看起来是慢速缓冲区的对象。
我试图允许Buffer的xor方法只允许Buffer对象和SlowBuffers,但key instanceof SlowBuffer
给出了一个错误。有人知道我如何检测key是否是SlowBuffer的实例吗?
var key;
crypto.randomBytes(10,function(err,bytes) {
key = bytes;
});
//key instanceof SlowBuffer
http://nodejs.org/api/buffer.html#buffer_class_method_buffer_isbuffer_obj对于SlowBuffer和Buffer对象,Buffer.isBuffer
方法将返回true。
相关文章:
- Collsioin Detection of Javascript 2d Box
- 从画布中的Canny Edge Detection创建形状
- Collision Detection Javascript
- JavaScript Circle Collision Detection Bug
- XPathEvaluator Detection in IE11
- Node.js SlowBuffer detection
- “detection"特性;让我失望.一个浏览器检测的案例,或者有更好的方法
- mobile detection in webpage Uncaught SyntaxError: Unexpected