From 719d2932c746d3a7d6bcd07913aaf6f655108623 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 8 Aug 2021 11:24:11 -0700 Subject: [PATCH] buffer: add endings option, remove Node.js specific encoding option Signed-off-by: James M Snell --- doc/api/buffer.md | 9 ++++--- lib/internal/blob.js | 51 +++++++++++++++++++++++++++++--------- test/parallel/test-blob.js | 20 ++++++++------- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index f419be1181a61af..4289b76d52b4624 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -465,8 +465,9 @@ added: v15.7.0 of string, {ArrayBuffer}, {TypedArray}, {DataView}, or {Blob} objects, or any mix of such objects, that will be stored within the `Blob`. * `options` {Object} - * `encoding` {string} The character encoding to use for string sources. - **Default:** `'utf8'`. + * `endings` {string} One of either `'transparent'` or `'native'`. When set + to `'native'`, line endings in string source parts will be converted to + the platform native line-ending as specified by `require('os').EOL`. * `type` {string} The Blob content-type. The intent is for `type` to convey the MIME media type of the data, however no validation of the type format is performed. @@ -476,7 +477,9 @@ Creates a new `Blob` object containing a concatenation of the given sources. {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into the 'Blob' and can therefore be safely modified after the 'Blob' is created. -String sources are also copied into the `Blob`. +String sources are encoded as UTF-8 byte sequences and copied into the blob. +Unmatched surrogate pairs within each string part will be replaced by Unicode +0xFFFD replacement characters. ### `blob.arrayBuffer()`