When node began using the OneByte API (f150d56) it also switched to officially supporting ISO-8859-1. Though at the time no new encoding string was introduced. Introduce the new encoding string 'latin1' to be more explicit. The previous 'binary' and documented as an alias to 'latin1'. While many tests have switched to use 'latin1', there are still plenty that do both 'binary' and 'latin1' checks side-by-side to ensure there is no regression. PR-URL: https://github.com/nodejs/node/pull/7111 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
// LazyTransform is a special type of Transform stream that is lazily loaded.
|
|
// This is used for performance with bi-API-ship: when two APIs are available
|
|
// for the stream, one conventional and one non-conventional.
|
|
'use strict';
|
|
|
|
const stream = require('stream');
|
|
const util = require('util');
|
|
|
|
module.exports = LazyTransform;
|
|
|
|
function LazyTransform(options) {
|
|
this._options = options;
|
|
}
|
|
util.inherits(LazyTransform, stream.Transform);
|
|
|
|
[
|
|
'_readableState',
|
|
'_writableState',
|
|
'_transformState'
|
|
].forEach(function(prop, i, props) {
|
|
Object.defineProperty(LazyTransform.prototype, prop, {
|
|
get: function() {
|
|
stream.Transform.call(this, this._options);
|
|
this._writableState.decodeStrings = false;
|
|
this._writableState.defaultEncoding = 'latin1';
|
|
return this[prop];
|
|
},
|
|
set: function(val) {
|
|
Object.defineProperty(this, prop, {
|
|
value: val,
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true
|
|
});
|
|
},
|
|
configurable: true,
|
|
enumerable: true
|
|
});
|
|
});
|