excel-builder
Version:
An easy way of building Excel files with javascript
35 lines (32 loc) • 1.07 kB
JavaScript
;
module.exports = {
/**
* True if this is running in Nodejs, will be undefined in a browser.
* In a browser, browserify won't include this file and the whole module
* will be resolved an empty object.
*/
isNode : typeof Buffer !== "undefined",
/**
* Create a new nodejs Buffer.
* @param {Object} data the data to pass to the constructor.
* @param {String} encoding the encoding to use.
* @return {Buffer} a new Buffer.
*/
newBuffer : function(data, encoding){
return new Buffer(data, encoding);
},
/**
* Find out if an object is a Buffer.
* @param {Object} b the object to test.
* @return {Boolean} true if the object is a Buffer, false otherwise.
*/
isBuffer : function(b){
return Buffer.isBuffer(b);
},
isStream : function (obj) {
return obj &&
typeof obj.on === "function" &&
typeof obj.pause === "function" &&
typeof obj.resume === "function";
}
};