Sha256: c230d25d8e7fbb50960c634b636b71327c409e9a77e67fe9446b566bdcea362d

Contents?: true

Size: 1.08 KB

Versions: 182

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

182 entries across 157 versions & 20 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/iconv-lite/lib/bom-handling.js
immosquare-cleaner-0.1.51 node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
immosquare-cleaner-0.1.50 node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
immosquare-cleaner-0.1.49 node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
immosquare-cleaner-0.1.48 node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/iconv-lite/lib/bom-handling.js