Updated the Survey.
This commit is contained in:
		
							parent
							
								
									f59686eae0
								
							
						
					
					
						commit
						6d3ba1a714
					
				
					 1203 changed files with 140782 additions and 5 deletions
				
			
		
							
								
								
									
										52
									
								
								node_modules/iconv-lite/lib/bom-handling.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								node_modules/iconv-lite/lib/bom-handling.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,52 @@
 | 
			
		|||
"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();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										217
									
								
								node_modules/iconv-lite/lib/extend-node.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										217
									
								
								node_modules/iconv-lite/lib/extend-node.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,217 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
var Buffer = require("buffer").Buffer;
 | 
			
		||||
// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer
 | 
			
		||||
 | 
			
		||||
// == Extend Node primitives to use iconv-lite =================================
 | 
			
		||||
 | 
			
		||||
module.exports = function (iconv) {
 | 
			
		||||
    var original = undefined; // Place to keep original methods.
 | 
			
		||||
 | 
			
		||||
    // Node authors rewrote Buffer internals to make it compatible with
 | 
			
		||||
    // Uint8Array and we cannot patch key functions since then.
 | 
			
		||||
    // Note: this does use older Buffer API on a purpose
 | 
			
		||||
    iconv.supportsNodeEncodingsExtension = !(Buffer.from || new Buffer(0) instanceof Uint8Array);
 | 
			
		||||
 | 
			
		||||
    iconv.extendNodeEncodings = function extendNodeEncodings() {
 | 
			
		||||
        if (original) return;
 | 
			
		||||
        original = {};
 | 
			
		||||
 | 
			
		||||
        if (!iconv.supportsNodeEncodingsExtension) {
 | 
			
		||||
            console.error("ACTION NEEDED: require('iconv-lite').extendNodeEncodings() is not supported in your version of Node");
 | 
			
		||||
            console.error("See more info at https://github.com/ashtuchkin/iconv-lite/wiki/Node-v4-compatibility");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var nodeNativeEncodings = {
 | 
			
		||||
            'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, 
 | 
			
		||||
            'base64': true, 'ucs2': true, 'ucs-2': true, 'utf16le': true, 'utf-16le': true,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        Buffer.isNativeEncoding = function(enc) {
 | 
			
		||||
            return enc && nodeNativeEncodings[enc.toLowerCase()];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // -- SlowBuffer -----------------------------------------------------------
 | 
			
		||||
        var SlowBuffer = require('buffer').SlowBuffer;
 | 
			
		||||
 | 
			
		||||
        original.SlowBufferToString = SlowBuffer.prototype.toString;
 | 
			
		||||
        SlowBuffer.prototype.toString = function(encoding, start, end) {
 | 
			
		||||
            encoding = String(encoding || 'utf8').toLowerCase();
 | 
			
		||||
 | 
			
		||||
            // Use native conversion when possible
 | 
			
		||||
            if (Buffer.isNativeEncoding(encoding))
 | 
			
		||||
                return original.SlowBufferToString.call(this, encoding, start, end);
 | 
			
		||||
 | 
			
		||||
            // Otherwise, use our decoding method.
 | 
			
		||||
            if (typeof start == 'undefined') start = 0;
 | 
			
		||||
            if (typeof end == 'undefined') end = this.length;
 | 
			
		||||
            return iconv.decode(this.slice(start, end), encoding);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        original.SlowBufferWrite = SlowBuffer.prototype.write;
 | 
			
		||||
        SlowBuffer.prototype.write = function(string, offset, length, encoding) {
 | 
			
		||||
            // Support both (string, offset, length, encoding)
 | 
			
		||||
            // and the legacy (string, encoding, offset, length)
 | 
			
		||||
            if (isFinite(offset)) {
 | 
			
		||||
                if (!isFinite(length)) {
 | 
			
		||||
                    encoding = length;
 | 
			
		||||
                    length = undefined;
 | 
			
		||||
                }
 | 
			
		||||
            } else {  // legacy
 | 
			
		||||
                var swap = encoding;
 | 
			
		||||
                encoding = offset;
 | 
			
		||||
                offset = length;
 | 
			
		||||
                length = swap;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            offset = +offset || 0;
 | 
			
		||||
            var remaining = this.length - offset;
 | 
			
		||||
            if (!length) {
 | 
			
		||||
                length = remaining;
 | 
			
		||||
            } else {
 | 
			
		||||
                length = +length;
 | 
			
		||||
                if (length > remaining) {
 | 
			
		||||
                    length = remaining;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            encoding = String(encoding || 'utf8').toLowerCase();
 | 
			
		||||
 | 
			
		||||
            // Use native conversion when possible
 | 
			
		||||
            if (Buffer.isNativeEncoding(encoding))
 | 
			
		||||
                return original.SlowBufferWrite.call(this, string, offset, length, encoding);
 | 
			
		||||
 | 
			
		||||
            if (string.length > 0 && (length < 0 || offset < 0))
 | 
			
		||||
                throw new RangeError('attempt to write beyond buffer bounds');
 | 
			
		||||
 | 
			
		||||
            // Otherwise, use our encoding method.
 | 
			
		||||
            var buf = iconv.encode(string, encoding);
 | 
			
		||||
            if (buf.length < length) length = buf.length;
 | 
			
		||||
            buf.copy(this, offset, 0, length);
 | 
			
		||||
            return length;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // -- Buffer ---------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
        original.BufferIsEncoding = Buffer.isEncoding;
 | 
			
		||||
        Buffer.isEncoding = function(encoding) {
 | 
			
		||||
            return Buffer.isNativeEncoding(encoding) || iconv.encodingExists(encoding);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        original.BufferByteLength = Buffer.byteLength;
 | 
			
		||||
        Buffer.byteLength = SlowBuffer.byteLength = function(str, encoding) {
 | 
			
		||||
            encoding = String(encoding || 'utf8').toLowerCase();
 | 
			
		||||
 | 
			
		||||
            // Use native conversion when possible
 | 
			
		||||
            if (Buffer.isNativeEncoding(encoding))
 | 
			
		||||
                return original.BufferByteLength.call(this, str, encoding);
 | 
			
		||||
 | 
			
		||||
            // Slow, I know, but we don't have a better way yet.
 | 
			
		||||
            return iconv.encode(str, encoding).length;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        original.BufferToString = Buffer.prototype.toString;
 | 
			
		||||
        Buffer.prototype.toString = function(encoding, start, end) {
 | 
			
		||||
            encoding = String(encoding || 'utf8').toLowerCase();
 | 
			
		||||
 | 
			
		||||
            // Use native conversion when possible
 | 
			
		||||
            if (Buffer.isNativeEncoding(encoding))
 | 
			
		||||
                return original.BufferToString.call(this, encoding, start, end);
 | 
			
		||||
 | 
			
		||||
            // Otherwise, use our decoding method.
 | 
			
		||||
            if (typeof start == 'undefined') start = 0;
 | 
			
		||||
            if (typeof end == 'undefined') end = this.length;
 | 
			
		||||
            return iconv.decode(this.slice(start, end), encoding);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        original.BufferWrite = Buffer.prototype.write;
 | 
			
		||||
        Buffer.prototype.write = function(string, offset, length, encoding) {
 | 
			
		||||
            var _offset = offset, _length = length, _encoding = encoding;
 | 
			
		||||
            // Support both (string, offset, length, encoding)
 | 
			
		||||
            // and the legacy (string, encoding, offset, length)
 | 
			
		||||
            if (isFinite(offset)) {
 | 
			
		||||
                if (!isFinite(length)) {
 | 
			
		||||
                    encoding = length;
 | 
			
		||||
                    length = undefined;
 | 
			
		||||
                }
 | 
			
		||||
            } else {  // legacy
 | 
			
		||||
                var swap = encoding;
 | 
			
		||||
                encoding = offset;
 | 
			
		||||
                offset = length;
 | 
			
		||||
                length = swap;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            encoding = String(encoding || 'utf8').toLowerCase();
 | 
			
		||||
 | 
			
		||||
            // Use native conversion when possible
 | 
			
		||||
            if (Buffer.isNativeEncoding(encoding))
 | 
			
		||||
                return original.BufferWrite.call(this, string, _offset, _length, _encoding);
 | 
			
		||||
 | 
			
		||||
            offset = +offset || 0;
 | 
			
		||||
            var remaining = this.length - offset;
 | 
			
		||||
            if (!length) {
 | 
			
		||||
                length = remaining;
 | 
			
		||||
            } else {
 | 
			
		||||
                length = +length;
 | 
			
		||||
                if (length > remaining) {
 | 
			
		||||
                    length = remaining;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (string.length > 0 && (length < 0 || offset < 0))
 | 
			
		||||
                throw new RangeError('attempt to write beyond buffer bounds');
 | 
			
		||||
 | 
			
		||||
            // Otherwise, use our encoding method.
 | 
			
		||||
            var buf = iconv.encode(string, encoding);
 | 
			
		||||
            if (buf.length < length) length = buf.length;
 | 
			
		||||
            buf.copy(this, offset, 0, length);
 | 
			
		||||
            return length;
 | 
			
		||||
 | 
			
		||||
            // TODO: Set _charsWritten.
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // -- Readable -------------------------------------------------------------
 | 
			
		||||
        if (iconv.supportsStreams) {
 | 
			
		||||
            var Readable = require('stream').Readable;
 | 
			
		||||
 | 
			
		||||
            original.ReadableSetEncoding = Readable.prototype.setEncoding;
 | 
			
		||||
            Readable.prototype.setEncoding = function setEncoding(enc, options) {
 | 
			
		||||
                // Use our own decoder, it has the same interface.
 | 
			
		||||
                // We cannot use original function as it doesn't handle BOM-s.
 | 
			
		||||
                this._readableState.decoder = iconv.getDecoder(enc, options);
 | 
			
		||||
                this._readableState.encoding = enc;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Readable.prototype.collect = iconv._collect;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Remove iconv-lite Node primitive extensions.
 | 
			
		||||
    iconv.undoExtendNodeEncodings = function undoExtendNodeEncodings() {
 | 
			
		||||
        if (!iconv.supportsNodeEncodingsExtension)
 | 
			
		||||
            return;
 | 
			
		||||
        if (!original)
 | 
			
		||||
            throw new Error("require('iconv-lite').undoExtendNodeEncodings(): Nothing to undo; extendNodeEncodings() is not called.")
 | 
			
		||||
 | 
			
		||||
        delete Buffer.isNativeEncoding;
 | 
			
		||||
 | 
			
		||||
        var SlowBuffer = require('buffer').SlowBuffer;
 | 
			
		||||
 | 
			
		||||
        SlowBuffer.prototype.toString = original.SlowBufferToString;
 | 
			
		||||
        SlowBuffer.prototype.write = original.SlowBufferWrite;
 | 
			
		||||
 | 
			
		||||
        Buffer.isEncoding = original.BufferIsEncoding;
 | 
			
		||||
        Buffer.byteLength = original.BufferByteLength;
 | 
			
		||||
        Buffer.prototype.toString = original.BufferToString;
 | 
			
		||||
        Buffer.prototype.write = original.BufferWrite;
 | 
			
		||||
 | 
			
		||||
        if (iconv.supportsStreams) {
 | 
			
		||||
            var Readable = require('stream').Readable;
 | 
			
		||||
 | 
			
		||||
            Readable.prototype.setEncoding = original.ReadableSetEncoding;
 | 
			
		||||
            delete Readable.prototype.collect;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        original = undefined;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										24
									
								
								node_modules/iconv-lite/lib/index.d.ts
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								node_modules/iconv-lite/lib/index.d.ts
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
/*---------------------------------------------------------------------------------------------
 | 
			
		||||
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 | 
			
		||||
 *  Licensed under the MIT License.
 | 
			
		||||
 *  REQUIREMENT: This definition is dependent on the @types/node definition.
 | 
			
		||||
 *  Install with `npm install @types/node --save-dev`
 | 
			
		||||
 *--------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
declare module 'iconv-lite' {
 | 
			
		||||
	export function decode(buffer: Buffer, encoding: string, options?: Options): string;
 | 
			
		||||
 | 
			
		||||
	export function encode(content: string, encoding: string, options?: Options): Buffer;
 | 
			
		||||
 | 
			
		||||
	export function encodingExists(encoding: string): boolean;
 | 
			
		||||
 | 
			
		||||
	export function decodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
 | 
			
		||||
 | 
			
		||||
	export function encodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface Options {
 | 
			
		||||
    stripBOM?: boolean;
 | 
			
		||||
    addBOM?: boolean;
 | 
			
		||||
    defaultEncoding?: string;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										153
									
								
								node_modules/iconv-lite/lib/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								node_modules/iconv-lite/lib/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,153 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
// Some environments don't have global Buffer (e.g. React Native).
 | 
			
		||||
// Solution would be installing npm modules "buffer" and "stream" explicitly.
 | 
			
		||||
var Buffer = require("safer-buffer").Buffer;
 | 
			
		||||
 | 
			
		||||
var bomHandling = require("./bom-handling"),
 | 
			
		||||
    iconv = module.exports;
 | 
			
		||||
 | 
			
		||||
// All codecs and aliases are kept here, keyed by encoding name/alias.
 | 
			
		||||
// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`.
 | 
			
		||||
iconv.encodings = null;
 | 
			
		||||
 | 
			
		||||
// Characters emitted in case of error.
 | 
			
		||||
iconv.defaultCharUnicode = '<27>';
 | 
			
		||||
iconv.defaultCharSingleByte = '?';
 | 
			
		||||
 | 
			
		||||
// Public API.
 | 
			
		||||
iconv.encode = function encode(str, encoding, options) {
 | 
			
		||||
    str = "" + (str || ""); // Ensure string.
 | 
			
		||||
 | 
			
		||||
    var encoder = iconv.getEncoder(encoding, options);
 | 
			
		||||
 | 
			
		||||
    var res = encoder.write(str);
 | 
			
		||||
    var trail = encoder.end();
 | 
			
		||||
    
 | 
			
		||||
    return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
iconv.decode = function decode(buf, encoding, options) {
 | 
			
		||||
    if (typeof buf === 'string') {
 | 
			
		||||
        if (!iconv.skipDecodeWarning) {
 | 
			
		||||
            console.error('Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding');
 | 
			
		||||
            iconv.skipDecodeWarning = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer.
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var decoder = iconv.getDecoder(encoding, options);
 | 
			
		||||
 | 
			
		||||
    var res = decoder.write(buf);
 | 
			
		||||
    var trail = decoder.end();
 | 
			
		||||
 | 
			
		||||
    return trail ? (res + trail) : res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
iconv.encodingExists = function encodingExists(enc) {
 | 
			
		||||
    try {
 | 
			
		||||
        iconv.getCodec(enc);
 | 
			
		||||
        return true;
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Legacy aliases to convert functions
 | 
			
		||||
iconv.toEncoding = iconv.encode;
 | 
			
		||||
iconv.fromEncoding = iconv.decode;
 | 
			
		||||
 | 
			
		||||
// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache.
 | 
			
		||||
iconv._codecDataCache = {};
 | 
			
		||||
iconv.getCodec = function getCodec(encoding) {
 | 
			
		||||
    if (!iconv.encodings)
 | 
			
		||||
        iconv.encodings = require("../encodings"); // Lazy load all encoding definitions.
 | 
			
		||||
    
 | 
			
		||||
    // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
 | 
			
		||||
    var enc = iconv._canonicalizeEncoding(encoding);
 | 
			
		||||
 | 
			
		||||
    // Traverse iconv.encodings to find actual codec.
 | 
			
		||||
    var codecOptions = {};
 | 
			
		||||
    while (true) {
 | 
			
		||||
        var codec = iconv._codecDataCache[enc];
 | 
			
		||||
        if (codec)
 | 
			
		||||
            return codec;
 | 
			
		||||
 | 
			
		||||
        var codecDef = iconv.encodings[enc];
 | 
			
		||||
 | 
			
		||||
        switch (typeof codecDef) {
 | 
			
		||||
            case "string": // Direct alias to other encoding.
 | 
			
		||||
                enc = codecDef;
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case "object": // Alias with options. Can be layered.
 | 
			
		||||
                for (var key in codecDef)
 | 
			
		||||
                    codecOptions[key] = codecDef[key];
 | 
			
		||||
 | 
			
		||||
                if (!codecOptions.encodingName)
 | 
			
		||||
                    codecOptions.encodingName = enc;
 | 
			
		||||
                
 | 
			
		||||
                enc = codecDef.type;
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case "function": // Codec itself.
 | 
			
		||||
                if (!codecOptions.encodingName)
 | 
			
		||||
                    codecOptions.encodingName = enc;
 | 
			
		||||
 | 
			
		||||
                // The codec function must load all tables and return object with .encoder and .decoder methods.
 | 
			
		||||
                // It'll be called only once (for each different options object).
 | 
			
		||||
                codec = new codecDef(codecOptions, iconv);
 | 
			
		||||
 | 
			
		||||
                iconv._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later.
 | 
			
		||||
                return codec;
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
iconv._canonicalizeEncoding = function(encoding) {
 | 
			
		||||
    // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
 | 
			
		||||
    return (''+encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
iconv.getEncoder = function getEncoder(encoding, options) {
 | 
			
		||||
    var codec = iconv.getCodec(encoding),
 | 
			
		||||
        encoder = new codec.encoder(options, codec);
 | 
			
		||||
 | 
			
		||||
    if (codec.bomAware && options && options.addBOM)
 | 
			
		||||
        encoder = new bomHandling.PrependBOM(encoder, options);
 | 
			
		||||
 | 
			
		||||
    return encoder;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
iconv.getDecoder = function getDecoder(encoding, options) {
 | 
			
		||||
    var codec = iconv.getCodec(encoding),
 | 
			
		||||
        decoder = new codec.decoder(options, codec);
 | 
			
		||||
 | 
			
		||||
    if (codec.bomAware && !(options && options.stripBOM === false))
 | 
			
		||||
        decoder = new bomHandling.StripBOM(decoder, options);
 | 
			
		||||
 | 
			
		||||
    return decoder;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Load extensions in Node. All of them are omitted in Browserify build via 'browser' field in package.json.
 | 
			
		||||
var nodeVer = typeof process !== 'undefined' && process.versions && process.versions.node;
 | 
			
		||||
if (nodeVer) {
 | 
			
		||||
 | 
			
		||||
    // Load streaming support in Node v0.10+
 | 
			
		||||
    var nodeVerArr = nodeVer.split(".").map(Number);
 | 
			
		||||
    if (nodeVerArr[0] > 0 || nodeVerArr[1] >= 10) {
 | 
			
		||||
        require("./streams")(iconv);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Load Node primitive extensions.
 | 
			
		||||
    require("./extend-node")(iconv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ("Ā" != "\u0100") {
 | 
			
		||||
    console.error("iconv-lite warning: javascript files use encoding different from utf-8. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info.");
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										121
									
								
								node_modules/iconv-lite/lib/streams.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								node_modules/iconv-lite/lib/streams.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,121 @@
 | 
			
		|||
"use strict";
 | 
			
		||||
 | 
			
		||||
var Buffer = require("buffer").Buffer,
 | 
			
		||||
    Transform = require("stream").Transform;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// == Exports ==================================================================
 | 
			
		||||
module.exports = function(iconv) {
 | 
			
		||||
    
 | 
			
		||||
    // Additional Public API.
 | 
			
		||||
    iconv.encodeStream = function encodeStream(encoding, options) {
 | 
			
		||||
        return new IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    iconv.decodeStream = function decodeStream(encoding, options) {
 | 
			
		||||
        return new IconvLiteDecoderStream(iconv.getDecoder(encoding, options), options);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    iconv.supportsStreams = true;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // Not published yet.
 | 
			
		||||
    iconv.IconvLiteEncoderStream = IconvLiteEncoderStream;
 | 
			
		||||
    iconv.IconvLiteDecoderStream = IconvLiteDecoderStream;
 | 
			
		||||
    iconv._collect = IconvLiteDecoderStream.prototype.collect;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// == Encoder stream =======================================================
 | 
			
		||||
function IconvLiteEncoderStream(conv, options) {
 | 
			
		||||
    this.conv = conv;
 | 
			
		||||
    options = options || {};
 | 
			
		||||
    options.decodeStrings = false; // We accept only strings, so we don't need to decode them.
 | 
			
		||||
    Transform.call(this, options);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {
 | 
			
		||||
    constructor: { value: IconvLiteEncoderStream }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
IconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {
 | 
			
		||||
    if (typeof chunk != 'string')
 | 
			
		||||
        return done(new Error("Iconv encoding stream needs strings as its input."));
 | 
			
		||||
    try {
 | 
			
		||||
        var res = this.conv.write(chunk);
 | 
			
		||||
        if (res && res.length) this.push(res);
 | 
			
		||||
        done();
 | 
			
		||||
    }
 | 
			
		||||
    catch (e) {
 | 
			
		||||
        done(e);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IconvLiteEncoderStream.prototype._flush = function(done) {
 | 
			
		||||
    try {
 | 
			
		||||
        var res = this.conv.end();
 | 
			
		||||
        if (res && res.length) this.push(res);
 | 
			
		||||
        done();
 | 
			
		||||
    }
 | 
			
		||||
    catch (e) {
 | 
			
		||||
        done(e);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IconvLiteEncoderStream.prototype.collect = function(cb) {
 | 
			
		||||
    var chunks = [];
 | 
			
		||||
    this.on('error', cb);
 | 
			
		||||
    this.on('data', function(chunk) { chunks.push(chunk); });
 | 
			
		||||
    this.on('end', function() {
 | 
			
		||||
        cb(null, Buffer.concat(chunks));
 | 
			
		||||
    });
 | 
			
		||||
    return this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// == Decoder stream =======================================================
 | 
			
		||||
function IconvLiteDecoderStream(conv, options) {
 | 
			
		||||
    this.conv = conv;
 | 
			
		||||
    options = options || {};
 | 
			
		||||
    options.encoding = this.encoding = 'utf8'; // We output strings.
 | 
			
		||||
    Transform.call(this, options);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {
 | 
			
		||||
    constructor: { value: IconvLiteDecoderStream }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
 | 
			
		||||
    if (!Buffer.isBuffer(chunk))
 | 
			
		||||
        return done(new Error("Iconv decoding stream needs buffers as its input."));
 | 
			
		||||
    try {
 | 
			
		||||
        var res = this.conv.write(chunk);
 | 
			
		||||
        if (res && res.length) this.push(res, this.encoding);
 | 
			
		||||
        done();
 | 
			
		||||
    }
 | 
			
		||||
    catch (e) {
 | 
			
		||||
        done(e);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IconvLiteDecoderStream.prototype._flush = function(done) {
 | 
			
		||||
    try {
 | 
			
		||||
        var res = this.conv.end();
 | 
			
		||||
        if (res && res.length) this.push(res, this.encoding);                
 | 
			
		||||
        done();
 | 
			
		||||
    }
 | 
			
		||||
    catch (e) {
 | 
			
		||||
        done(e);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IconvLiteDecoderStream.prototype.collect = function(cb) {
 | 
			
		||||
    var res = '';
 | 
			
		||||
    this.on('error', cb);
 | 
			
		||||
    this.on('data', function(chunk) { res += chunk; });
 | 
			
		||||
    this.on('end', function() {
 | 
			
		||||
        cb(null, res);
 | 
			
		||||
    });
 | 
			
		||||
    return this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue