123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 'use strict';
-
- module.exports = {
-
-
- isNode : typeof Buffer !== "undefined",
-
-
- newBufferFrom: function(data, encoding) {
- if (Buffer.from && Buffer.from !== Uint8Array.from) {
- return Buffer.from(data, encoding);
- } else {
- if (typeof data === "number") {
-
-
- throw new Error("The \"data\" argument must not be a number");
- }
- return new Buffer(data, encoding);
- }
- },
-
-
- allocBuffer: function (size) {
- if (Buffer.alloc) {
- return Buffer.alloc(size);
- } else {
- var buf = new Buffer(size);
- buf.fill(0);
- return buf;
- }
- },
-
-
- isBuffer : function(b){
- return Buffer.isBuffer(b);
- },
-
- isStream : function (obj) {
- return obj &&
- typeof obj.on === "function" &&
- typeof obj.pause === "function" &&
- typeof obj.resume === "function";
- }
- };
|