3 var BOMChar = '\uFEFF';
5 exports.PrependBOM = PrependBOMWrapper
6 function PrependBOMWrapper(encoder, options) {
7 this.encoder = encoder;
11 PrependBOMWrapper.prototype.write = function(str) {
17 return this.encoder.write(str);
20 PrependBOMWrapper.prototype.end = function() {
21 return this.encoder.end();
25 //------------------------------------------------------------------------------
27 exports.StripBOM = StripBOMWrapper;
28 function StripBOMWrapper(decoder, options) {
29 this.decoder = decoder;
31 this.options = options || {};
34 StripBOMWrapper.prototype.write = function(buf) {
35 var res = this.decoder.write(buf);
36 if (this.pass || !res)
39 if (res[0] === BOMChar) {
41 if (typeof this.options.stripBOM === 'function')
42 this.options.stripBOM();
49 StripBOMWrapper.prototype.end = function() {
50 return this.decoder.end();