sheetjs/bits/05_buf.js
SheetJS f277ebe140 version bump 0.11.16: refresh
- HTML whitespace (fixes #849 h/t @laurentauthier)
- XLML number format write (fixes #904 h/t @james-boswell)
- XLAM/XLA write
- 'array' write type
- XLSX/XLSB/XLS/XLML RTL read/write
- XLS merge cells write
- demo and typing refresh
2017-12-30 03:20:00 -05:00

30 lines
1007 B
JavaScript

var has_buf = (typeof Buffer !== 'undefined' && typeof process !== 'undefined' && typeof process.versions !== 'undefined' && process.versions.node);
function new_raw_buf(len/*:number*/) {
/* jshint -W056 */
// $FlowIgnore
return new (has_buf ? Buffer : Array)(len);
/* jshint +W056 */
}
function s2a(s/*:string*/) {
if(has_buf) return new Buffer(s, "binary");
return s.split("").map(function(x){ return x.charCodeAt(0) & 0xff; });
}
function s2ab(s/*:string*/) {
if(typeof ArrayBuffer === 'undefined') return s2a(s);
var buf = new ArrayBuffer(s.length), view = new Uint8Array(buf);
for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
function arr2str(data/*:any*/)/*:string*/ {
if(Array.isArray(data)) return data.map(_chr).join("");
var o/*:Array<string>*/ = []; for(var i = 0; i < data.length; ++i) o[i] = _chr(data[i]); return o.join("");
}
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;