UNPKG

node-wad

Version:
39 lines (32 loc) 991 B
// Generated by CoffeeScript 1.12.6 var WLump, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; WLump = (function() { function WLump(wad, data, name) { this.wad = wad; this.write = bind(this.write, this); this.getSize = bind(this.getSize, this); this.data = new Buffer(data); this.name = name.toString('ascii'); while (this.name.endsWith("\x00")) { this.name = this.name.slice(0, -1); } this.strData = this.data.toString('utf-8'); } WLump.prototype.getSize = function() { return this.data.length; }; WLump.prototype.write = function(bf) { var i, j, ref, results; if (this.data.length === 0) { return; } results = []; for (i = j = 0, ref = this.data.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { results.push(bf.writeUInt8(this.data.slice(i, i + 1).readUInt8())); } return results; }; return WLump; })(); module.exports = WLump;