2017-04-02 06:47:25 +00:00
|
|
|
var has_buf = (typeof Buffer !== 'undefined' && typeof process !== 'undefined' && typeof process.versions !== 'undefined' && process.versions.node);
|
2015-04-02 20:32:22 +00:00
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
function new_raw_buf(len/*:number*/) {
|
2015-04-02 20:32:22 +00:00
|
|
|
/* jshint -W056 */
|
2017-07-26 08:35:28 +00:00
|
|
|
// $FlowIgnore
|
2015-04-02 20:32:22 +00:00
|
|
|
return new (has_buf ? Buffer : Array)(len);
|
|
|
|
/* jshint +W056 */
|
|
|
|
}
|
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
function s2a(s/*:string*/) {
|
2015-04-02 20:32:22 +00:00
|
|
|
if(has_buf) return new Buffer(s, "binary");
|
|
|
|
return s.split("").map(function(x){ return x.charCodeAt(0) & 0xff; });
|
|
|
|
}
|
|
|
|
|
|
|
|
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
|
|
|
|
|
|
|
|
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/;
|