Commit Graph

43 Commits

Author SHA1 Message Date
Robert Nagy
3800d60c66 buffer: throw when writing beyond buffer"
This reverts commit dd8eeec3f0.

PR-URL: https://github.com/nodejs/node/pull/54588/
Refs: https://github.com/nodejs/node/pull/54524
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-09-28 08:21:43 -07:00
Robert Nagy
dd8eeec3f0
buffer: truncate instead of throw when writing beyond buffer
Fixes: https://github.com/nodejs/node/issues/54523
Fixes: https://github.com/nodejs/node/issues/54518
PR-URL: https://github.com/nodejs/node/pull/54524
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2024-08-27 08:48:52 +00:00
Robert Nagy
ccf05ef751
buffer: use fast API for writing one-byte strings
PR-URL: https://github.com/nodejs/node/pull/54310
PR-URL: https://github.com/nodejs/node/pull/54311
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-08-15 01:01:05 +00:00
Chengzhong Wu
64549731b6
src: throw DataCloneError on transfering untransferable objects
The HTML StructuredSerializeWithTransfer algorithm defines that when
an untransferable object is in the transfer list, a DataCloneError is
thrown.
An array buffer that is already transferred is also considered as
untransferable.

PR-URL: https://github.com/nodejs/node/pull/47604
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-05-05 11:22:42 +00:00
Antoine du Hamel
5f76836277
lib: add trailing commas to more internal files
PR-URL: https://github.com/nodejs/node/pull/46811
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2023-02-26 11:34:02 +01:00
Joyee Cheung
066e77ae8d
util: use private symbols in JS land directly
Instead of calling into C++ to use the private symbols, use an
ObjectTemplate to create an object that holds the symbols and
use them directly from JS land.

PR-URL: https://github.com/nodejs/node/pull/45379
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-11-17 18:54:01 +01:00
Cactysman
14aed60941 buffer,errors: add missing n literal in range error string
PR-URL: https://github.com/nodejs/node/pull/37750
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-17 19:34:42 +02:00
Filip Skokan
f8ab632d56 buffer: add base64url encoding option
PR-URL: https://github.com/nodejs/node/pull/36952
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-01-18 12:08:20 +01:00
Antoine du Hamel
0187716be5 buffer: make FastBuffer safe to construct
Using an explicit constructor is necessary to avoid relying on
`Array.prototype[Symbol.iterator]` and `%ArrayIteratorPrototype%.next`,
which can be mutated by users.

PR-URL: https://github.com/nodejs/node/pull/36587
Refs: https://github.com/nodejs/node/pull/36428
Refs: https://github.com/nodejs/node/pull/36532
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-12-25 18:11:33 +00:00
Michaël Zasso
bf31d3c3b1
tools: enable no-unused-expressions lint rule
Fixes: https://github.com/nodejs/node/issues/36246

PR-URL: https://github.com/nodejs/node/pull/36248
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-12-07 20:33:45 +01:00
Antoine du Hamel
ad0a01caed http2: add support for TypedArray to getUnpackedSettings
PR-URL: https://github.com/nodejs/node/pull/36141
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-19 17:48:02 +00:00
Michaël Zasso
1469984645 lib: use remaining typed arrays from primordials
PR-URL: https://github.com/nodejs/node/pull/35499
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2020-10-07 13:44:21 +00:00
Sebastien Ahkrin
34b7b47849
lib: replace Float64Array global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:51 +02:00
Anna Henningsen
42a793eba3 buffer: also alias BigUInt methods
These were overlooked in 5864fca7bc because of the extra
`Big` in the name. :)

Refs: https://github.com/nodejs/node/pull/34729

PR-URL: https://github.com/nodejs/node/pull/34960
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-09-02 14:22:35 +00:00
Anna Henningsen
5864fca7bc buffer: alias UInt ➡️ Uint in buffer methods
It’s *so* hard to remember that it’s `UintXArray` but not
`(write|read)UintX`. Let’s fix that by just providing aliases. 😊

PR-URL: https://github.com/nodejs/node/pull/34729
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-08-13 19:57:39 -07:00
Joyee Cheung
c943cb4809
src: reset zero fill toggle at pre-execution
The connection between the JS land zero fill toggle and the
C++ one in the NodeArrayBufferAllocator gets lost if the toggle
is deserialized from the snapshot, because V8 owns the underlying
memory of this toggle. This resets the connection at pre-execution.

PR-URL: https://github.com/nodejs/node/pull/32984
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2020-07-18 11:23:16 +08:00
Anna Henningsen
88fb5a5c79
worker: add public method for marking objects as untransferable
We currently mark a number of `ArrayBuffer`s as not transferable,
including the `Buffer` pool and ones with finalizers provided
by C++ addons.

There is no good reason to assume that userland code might not
encounter similar problems, for example when doing `ArrayBuffer`
pooling similar to ours. Therefore, provide an API that lets
userland code also mark objects as not transferable.

PR-URL: https://github.com/nodejs/node/pull/33979
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2020-06-25 08:33:29 -07:00
Sebastien Ahkrin
92cef79779 lib: replace Float32Array global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31195
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-07 15:09:59 -08:00
Michaël Zasso
923d8bc733
lib: enforce use of BigInt from primordials
PR-URL: https://github.com/nodejs/node/pull/30882
Refs: https://github.com/nodejs/node/issues/30697
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-12-13 15:54:53 +01:00
Sebastien Ahkrin
2070d3f8eb
lib: enforce use of primordial Number
PR-URL: https://github.com/nodejs/node/pull/30700
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-30 13:58:25 +01:00
Brian White
c14c476614 buffer: fix 6-byte writeUIntBE() range check
Fixes: https://github.com/nodejs/node/issues/30420

PR-URL: https://github.com/nodejs/node/pull/30459
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-29 19:40:52 -08:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.

PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-25 10:28:15 +01:00
Ruben Bridgewater
ed8fc7e11d
tools: update eslint
This updates eslint from v6.0.0-alpha.2 to v6.0.1

This also removes eslint-disable comments about `bigint` typeof
checks. Those would otherwise have caused linting errors now that
`bigint` is accepted as valid entry.

PR-URL: https://github.com/nodejs/node/pull/28173
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-06-27 11:57:19 +02:00
Ruben Bridgewater
4416127482
buffer,errors: improve bigint, big numbers and more
This improves the error message from `ERR_OUT_OF_RANGE` by closer
inspecting the value and logging numbers above 2 ** 32 by adding
commas to the output for integer and bigint. BigInt is now also
marked if used.

Buffer errors also format the range as 2 ** n instead of showing a
huge number.

PR-URL: https://github.com/nodejs/node/pull/27228
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-05-01 12:29:04 +02:00
Nikolai Vavilov
3d8532f851 buffer: add {read|write}Big[U]Int64{BE|LE} methods
PR-URL: https://github.com/nodejs/node/pull/19691
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-04-06 19:30:23 +02:00
Michaël Zasso
0817840f77 lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it.

PR-URL: https://github.com/nodejs/node/pull/27027
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-03 21:36:08 +08:00
Joyee Cheung
842a35fbac
buffer: move Buffer prototype wiring into internal/buffer.js
Instead of exposing the Buffer prototype methods through an
object in `internal/buffer.js` and then iterating over it
to put the methods on the prototype, create a function
in `internal/buffer.js` to do this.

Also moves the creaton of the `FastBuffer` class into
`internal/buffer.js` and expose it directly instead of
writing it onto that module later.

PR-URL: https://github.com/nodejs/node/pull/25292
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-10 16:59:27 +08:00
Joyee Cheung
97f59b9567
buffer: move initialization of buffer prototype into node.js
Instead of exposing it in `lib/internal/buffer.js` after deleting
it from the binding and then do the initialization in
`lib/buffer.js`, which results in an implicit dependency on
the order in which these modules are loaded.

PR-URL: https://github.com/nodejs/node/pull/25292
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-10 16:59:24 +08:00
cjihrig
adbdaf94be buffer: remove checkNumberType()
checkNumberType() was a very thin wrapper around validateNumber().
This commit removes checkNumberType() and used validateNumber()
directly instead.

PR-URL: https://github.com/nodejs/node/pull/24815
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-12-05 14:46:33 -08:00
Brian White
5c201b6d47 buffer: fix writeUInt16BE range check
Fixes: https://github.com/nodejs/node/issues/24205

PR-URL: https://github.com/nodejs/node/pull/24208
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-11-08 15:22:19 -08:00
Weijia Wang
ac23e6557f buffer: move process.binding('buffer') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/22370
Refs: https://github.com/nodejs/node/issues/22160
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-10-15 19:01:20 +08:00
Jon Moss
3e44b8c91e lib: extract validateNumber validator
Pulls out another common argument validator to `internal/validators`

PR-URL: https://github.com/nodejs/node/pull/22249
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-08-14 11:34:34 -04:00
Ruben Bridgewater
60b5b38b48
buffer: do not always use defaults
The Buffer#(read|write)U?Int(B|L)E functions should not use a default
value. This is very likely a bug and it was never documented that
way.

Besides that this also improves the tests by adding more tests and by
refactoring them to less code lines.

PR-URL: https://github.com/nodejs/node/pull/20054
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2018-04-29 16:52:46 +02:00
Ruben Bridgewater
dca7fb2225
errors: validate input arguments
This makes sure the input arguments get validated so implementation
errors will be caught early. It also improves a couple of error
messages by providing more detailed information and fixes errors
detected by the new functionality. Besides that a error type got
simplified and tests got refactored.

PR-URL: https://github.com/nodejs/node/pull/19924
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-13 19:59:44 +02:00
Ruben Bridgewater
d5495e859c
buffer: use a default offset
If none is provided, use zero as a default offset for all read/write
operations on the buffer.

PR-URL: https://github.com/nodejs/node/pull/19749
Refs: https://github.com/nodejs/node/pull/18395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-04-13 19:58:26 +02:00
Ruben Bridgewater
f4e5f969ba buffer: improve write(U)Int functions
This improves the performance of some write functions by around 5-15%.

PR-URL: https://github.com/nodejs/node/pull/19289
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-24 16:50:01 +01:00
Michaël Zasso
1d2fd8b65b lib: port remaining errors to new system
PR-URL: https://github.com/nodejs/node/pull/19137
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-03-07 14:54:38 +01:00
Ruben Bridgewater
e8bb1f35df
buffer: refactor all read/write functions
There are a lot of changes in this commit:

1) Remove the `noAssert` argument from all read and write functions.
2) Improve the performance of all read floating point functions
   significantly. This is done by switching to TypedArrays as the
   write floating point write functions.
3) No implicit type coercion for offset and byteLength anymore.
4) Adds a lot of tests.
5) Moves the read and write functions to the internal buffer file
   to split the files in smaller chunks.
6) Reworked a lot of existing tests.
7) Improve the performane of all all read write functions by using
   a faster input validation and by improving function logic.
8) Significantly improved the performance of all read int functions.
   This is done by using a implementation without a loop.
9) Improved error handling.
10) Rename test file to use the correct subsystem.

PR-URL: https://github.com/nodejs/node/pull/18395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-03-02 19:29:46 +00:00
Bryan English
8172f4547e buffer: move setupBufferJS to internal
Stashing it away in internal/buffer so that it can't be used in
userland, but can still be used in internals.

PR-URL: https://github.com/nodejs/node/pull/16391
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-25 10:36:17 -07:00
James M Snell
355523fcfb buffer: refactor module.exports, imports
* Move to more efficient module.exports pattern
* Refactor requires
* Eliminate circular dependency on internal/buffer
* Add names to some functions
* Fix circular dependency error in assert.js

PR-URL: https://github.com/nodejs/node/pull/13807
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-24 07:24:53 -07:00
James M Snell
62e96096fa lib: more consistent use of module.exports = {} model
Switch to using the more efficient module.exports = {}
where possible.

PR-URL: https://github.com/nodejs/node/pull/11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-02-22 08:56:08 -08:00
Anna Henningsen
beca3244e2
buffer: allow Uint8Array input to methods
Allow all methods on `buffer` and `Buffer` to take `Uint8Array`
arguments where it makes sense. On the native side, there is
effectively no difference, and as a bonus the `isUint8Array`
check is faster than `instanceof Buffer`.

PR-URL: https://github.com/nodejs/node/pull/10236
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2016-12-21 07:48:14 +01:00
James M Snell
e8eaaa7724 buffer: add buffer.transcode
Add buffer.transcode(source, from, to) method. Primarily uses ICU
to transcode a buffer's content from one of Node.js' supported
encodings to another.

Originally part of a proposal to add a new unicode module. Decided
to refactor the approach towrds individual PRs without a new module.

Refs: https://github.com/nodejs/node/pull/8075
PR-URL: https://github.com/nodejs/node/pull/9038
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-10-25 10:12:02 -07:00