{“ast”:null,“code”:“// Copyright Joyent, Inc. and other Node contributors.n//n// Permission is hereby granted, free of charge, to any person obtaining an// copy of this software and associated documentation files (then// "Software"), to deal in the Software without restriction, includingn// without limitation the rights to use, copy, modify, merge, publish,n// distribute, sublicense, and/or sell copies of the Software, and to permitn// persons to whom the Software is furnished to do so, subject to then// following conditions:n//n// The above copyright notice and this permission notice shall be includedn// in all copies or substantial portions of the Software.n//n// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSn// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFn// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INn// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT ORn// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THEn// USE OR OTHER DEALINGS IN THE SOFTWARE.n'use strict';n/*<replacement>*/nnvar Buffer = require('safe-buffer').Buffer;n/*</replacement>*/nnnvar isEncoding = Buffer.isEncoding || function (encoding) {n encoding = '' + encoding;nn switch (encoding && encoding.toLowerCase()) {n case 'hex':n case 'utf8':n case 'utf-8':n case 'ascii':n case 'binary':n case 'base64':n case 'ucs2':n case 'ucs-2':n case 'utf16le':n case 'utf-16le':n case 'raw':n return true;nn default:n return false;n }n};nnfunction _normalizeEncoding(enc) {n if (!enc) return 'utf8';n var retried;nn while (true) {n switch (enc) {n case 'utf8':n case 'utf-8':n return 'utf8';nn case 'ucs2':n case 'ucs-2':n case 'utf16le':n case 'utf-16le':n return 'utf16le';nn case 'latin1':n case 'binary':n return 'latin1';nn case 'base64':n case 'ascii':n case 'hex':n return enc;nn default:n if (retried) return; // undefinednn enc = ('' + enc).toLowerCase();n retried = true;n }n }n}nn; // Do not cache `Buffer.isEncoding` when checking encoding names as somen// modules monkey-patch it to support additional encodingsnnfunction normalizeEncoding(enc) {n var nenc = _normalizeEncoding(enc);nn if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);n return nenc || enc;n} // StringDecoder provides an interface for efficiently splitting a series ofn// buffers into a series of JS strings without breaking apart multi-byten// characters.nnnexports.StringDecoder = StringDecoder;nnfunction StringDecoder(encoding) {n this.encoding = normalizeEncoding(encoding);n var nb;nn switch (this.encoding) {n case 'utf16le':n this.text = utf16Text;n this.end = utf16End;n nb = 4;n break;nn case 'utf8':n this.fillLast = utf8FillLast;n nb = 4;n break;nn case 'base64':n this.text = base64Text;n this.end = base64End;n nb = 3;n break;nn default:n this.write = simpleWrite;n this.end = simpleEnd;n return;n }nn this.lastNeed = 0;n this.lastTotal = 0;n this.lastChar = Buffer.allocUnsafe(nb);n}nnStringDecoder.prototype.write = function (buf) {n if (buf.length === 0) return '';n var r;n var i;nn if (this.lastNeed) {n r = this.fillLast(buf);n if (r === undefined) return '';n i = this.lastNeed;n this.lastNeed = 0;n } else {n i = 0;n }nn if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);n return r || '';n};nnStringDecoder.prototype.end = utf8End; // Returns only complete characters in a BuffernnStringDecoder.prototype.text = utf8Text; // Attempts to complete a partial non-UTF-8 character using bytes from a BuffernnStringDecoder.prototype.fillLast = function (buf) {n if (this.lastNeed <= buf.length) {n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);n return this.lastChar.toString(this.encoding, 0, this.lastTotal);n }nn buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);n this.lastNeed -= buf.length;n}; // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or an// continuation byte. If an invalid byte is detected, -2 is returned.nnnfunction utf8CheckByte(_byte) {n if (_byte <= 0x7F) return 0;else if (_byte >> 5 === 0x06) return 2;else if (_byte >> 4 === 0x0E) return 3;else if (_byte >> 3 === 0x1E) return 4;n return _byte >> 6 === 0x02 ? -1 : -2;n} // Checks at most 3 bytes at the end of a Buffer in order to detect ann// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)n// needed to complete the UTF-8 character (if applicable) are returned.nnnfunction utf8CheckIncomplete(self, buf, i) {n var j = buf.length - 1;n if (j < i) return 0;n var nb = utf8CheckByte(buf);nn if (nb >= 0) {n if (nb > 0) self.lastNeed = nb - 1;n return nb;n }nn if (–j < i || nb === -2) return 0;n nb = utf8CheckByte(buf);nn if (nb >= 0) {n if (nb > 0) self.lastNeed = nb - 2;n return nb;n }nn if (–j < i || nb === -2) return 0;n nb = utf8CheckByte(buf);nn if (nb >= 0) {n if (nb > 0) {n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;n }nn return nb;n }nn return 0;n} // Validates as many continuation bytes for a multi-byte UTF-8 character asn// needed or are available. If we see a non-continuation byte where we expectn// one, we "replace" the validated continuation bytes we've seen so far withn// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decodingn// behavior. The continuation byte check is included three times in the casen// where all of the continuation bytes for a character exist in the same buffer.n// It is also done this way as a slight performance increase instead of using an// loop.nnnfunction utf8CheckExtraBytes(self, buf, p) {n if ((buf & 0xC0) !== 0x80) {n self.lastNeed = 0;n return "\uFFFD";n }nn if (self.lastNeed > 1 && buf.length > 1) {n if ((buf & 0xC0) !== 0x80) {n self.lastNeed = 1;n return "\uFFFD";n }nn if (self.lastNeed > 2 && buf.length > 2) {n if ((buf & 0xC0) !== 0x80) {n self.lastNeed = 2;n return "\uFFFD";n }n }n }n} // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.nnnfunction utf8FillLast(buf) {n var p = this.lastTotal - this.lastNeed;n var r = utf8CheckExtraBytes(this, buf, p);n if (r !== undefined) return r;nn if (this.lastNeed <= buf.length) {n buf.copy(this.lastChar, p, 0, this.lastNeed);n return this.lastChar.toString(this.encoding, 0, this.lastTotal);n }nn buf.copy(this.lastChar, p, 0, buf.length);n this.lastNeed -= buf.length;n} // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on an// partial character, the character's bytes are buffered until the requiredn// number of bytes are available.nnnfunction utf8Text(buf, i) {n var total = utf8CheckIncomplete(this, buf, i);n if (!this.lastNeed) return buf.toString('utf8', i);n this.lastTotal = total;n var end = buf.length - (total - this.lastNeed);n buf.copy(this.lastChar, 0, end);n return buf.toString('utf8', i, end);n} // For UTF-8, a replacement character is added when ending on a partialn// character.nnnfunction utf8End(buf) {n var r = buf && buf.length ? this.write(buf) : '';n if (this.lastNeed) return r + "\uFFFD";n return r;n} // UTF-16LE typically needs two bytes per character, but even if we have an evenn// number of bytes available, we need to check if we end on a leading/highn// surrogate. In that case, we need to wait for the next two bytes in order ton// decode the last character properly.nnnfunction utf16Text(buf, i) {n if ((buf.length - i) % 2 === 0) {n var r = buf.toString('utf16le', i);nn if ® {n var c = r.charCodeAt(r.length - 1);nn if (c >= 0xD800 && c <= 0xDBFF) {n this.lastNeed = 2;n this.lastTotal = 4;n this.lastChar = buf[buf.length - 2];n this.lastChar = buf[buf.length - 1];n return r.slice(0, -1);n }n }nn return r;n }nn this.lastNeed = 1;n this.lastTotal = 2;n this.lastChar = buf[buf.length - 1];n return buf.toString('utf16le', i, buf.length - 1);n} // For UTF-16LE we do not explicitly append special replacement characters if wen// end on a partial character, we simply let v8 handle that.nnnfunction utf16End(buf) {n var r = buf && buf.length ? this.write(buf) : '';nn if (this.lastNeed) {n var end = this.lastTotal - this.lastNeed;n return r + this.lastChar.toString('utf16le', 0, end);n }nn return r;n}nnfunction base64Text(buf, i) {n var n = (buf.length - i) % 3;n if (n === 0) return buf.toString('base64', i);n this.lastNeed = 3 - n;n this.lastTotal = 3;nn if (n === 1) {n this.lastChar = buf[buf.length - 1];n } else {n this.lastChar = buf[buf.length - 2];n this.lastChar = buf[buf.length - 1];n }nn return buf.toString('base64', i, buf.length - n);n}nnfunction base64End(buf) {n var r = buf && buf.length ? this.write(buf) : '';n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);n return r;n} // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)nnnfunction simpleWrite(buf) {n return buf.toString(this.encoding);n}nnfunction simpleEnd(buf) {n return buf && buf.length ? this.write(buf) : '';n}”,“map”:null,“metadata”:{},“sourceType”:“module”}