Sha256: f555ca207ea33413e1e802636c9c33968168eade1ae991bd3b98280a984bb2da

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

"use strict"

var BOMChar = '\uFEFF';

exports.PrependBOM = PrependBOMWrapper
function PrependBOMWrapper(encoder, options) {
    this.encoder = encoder;
    this.addBOM = true;
}

PrependBOMWrapper.prototype.write = function(str) {
    if (this.addBOM) {
        str = BOMChar + str;
        this.addBOM = false;
    }

    return this.encoder.write(str);
}

PrependBOMWrapper.prototype.end = function() {
    return this.encoder.end();
}


//------------------------------------------------------------------------------

exports.StripBOM = StripBOMWrapper;
function StripBOMWrapper(decoder, options) {
    this.decoder = decoder;
    this.pass = false;
    this.options = options || {};
}

StripBOMWrapper.prototype.write = function(buf) {
    var res = this.decoder.write(buf);
    if (this.pass || !res)
        return res;

    if (res[0] === BOMChar) {
        res = res.slice(1);
        if (typeof this.options.stripBOM === 'function')
            this.options.stripBOM();
    }

    this.pass = true;
    return res;
}

StripBOMWrapper.prototype.end = function() {
    return this.decoder.end();
}

Version data entries

12 entries across 10 versions & 5 rubygems

Version Path
lanes-0.8.0 node_modules/encoding/node_modules/iconv-lite/lib/bom-handling.js
lanes-0.8.0 node_modules/iconv-lite/lib/bom-handling.js
select_all-rails-0.3.1 node_modules/whatwg-encoding/node_modules/iconv-lite/lib/bom-handling.js
select_all-rails-0.3.1 node_modules/iconv-lite/lib/bom-handling.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/iconv-lite/lib/bom-handling.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/iconv-lite/lib/bom-handling.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/iconv-lite/lib/bom-handling.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/iconv-lite/lib/bom-handling.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/iconv-lite/lib/bom-handling.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/regenerator/node_modules/commoner/node_modules/iconv-lite/lib/bom-handling.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/regenerator/node_modules/commoner/node_modules/iconv-lite/lib/bom-handling.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/regenerator/node_modules/commoner/node_modules/iconv-lite/lib/bom-handling.js