Sha256: c230d25d8e7fbb50960c634b636b71327c409e9a77e67fe9446b566bdcea362d

Contents?: true

Size: 1.08 KB

Versions: 181

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

181 entries across 156 versions & 20 rubygems

Version Path
disco_app-0.16.1 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
appmap-0.70.2 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.70.1 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.70.0 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.69.0 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.68.2 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.68.1 ./node_modules/iconv-lite/lib/bom-handling.js
disco_app-0.15.2 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
appmap-0.68.0 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.67.1 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.67.0 ./node_modules/iconv-lite/lib/bom-handling.js
disco_app-0.18.4 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
disco_app-0.18.1 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
disco_app-0.14.0 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/iconv-lite/lib/bom-handling.js
appmap-0.66.2 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.66.1 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.66.0 ./node_modules/iconv-lite/lib/bom-handling.js
appmap-0.65.1 ./node_modules/iconv-lite/lib/bom-handling.js