Commit Graph

130 Commits

Author SHA1 Message Date
Deokjin Kim
c5cad08476
fs: remove redundant code in readableWebStream()
Remove redundant code by moving it to outside of `if/else`. Plus,
make `options` optional in doc.

PR-URL: https://github.com/nodejs/node/pull/49298
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-08-25 15:23:15 +00:00
LiviaMedeiros
6bef80a50b
fs: make mkdtemp accept buffers and URL
PR-URL: https://github.com/nodejs/node/pull/48828
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-07-26 19:32:31 +08:00
Hyunjin Kim
9c5e272dae
typings: sync JSDoc with the actual implementation
JSDoc comment did not match the actual implementation of
`FileHandle#readableWebStream`.

Refs: https://github.com/nodejs/node/pull/46933
PR-URL: https://github.com/nodejs/node/pull/48853
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
2023-07-23 10:05:05 +02:00
Chengzhong Wu
38dee8a1c0
src: distinguish HTML transferable and cloneable
The HTML structured serialize algorithm treats transferable and
serializable as two different bits. A web platform interface can be
both transferable and serializable.

Splits BaseObject::TransferMode to be able to compose the two bits
and distinguishes the transferable and cloneable.

PR-URL: https://github.com/nodejs/node/pull/47956
Refs: cf13b9b465
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
2023-07-07 17:00:00 +00:00
Moshe Atlow
71d7707792
fs, stream: initial Symbol.dispose and Symbol.asyncDispose support
Co-authored-by: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/48518
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-06-25 11:18:54 +00:00
Ethan Arrowood
7b39e8099a
fs: add recursive option to readdir and opendir
Adds a naive, linear recursive algorithm for the following methods:
readdir, readdirSync, opendir, opendirSync, and the promise based
equivalents.

Fixes: https://github.com/nodejs/node/issues/34992
PR-URL: https://github.com/nodejs/node/pull/41439
Refs: https://github.com/nodejs/tooling/issues/130
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2023-04-20 17:50:27 +00:00
Debadree Chatterjee
a9c3d9244f
fs: implement byob mode for readableWebStream()
Fixes: https://github.com/nodejs/node/issues/45853
PR-URL: https://github.com/nodejs/node/pull/46933
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-04-10 07:19:19 +00:00
Antoine du Hamel
9f192530f2
fs: add trailing commas in source files
PR-URL: https://github.com/nodejs/node/pull/46696
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-02-20 01:58:32 +01:00
James M Snell
71fb06fd64 src, lib: fixup lint and format issues for DataQueue/Blob
Co-authored-by: flakey5 <73616808+flakey5@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/45258
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-02-19 16:26:59 -08:00
James M Snell
950cec4c26 src: update Blob implementation to use DataQueue / File-backed Blobs
Co-authored-by: flakey5 <73616808+flakey5@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/45258
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-02-19 16:26:58 -08:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2023-02-14 18:45:16 +01:00
Colin Ihrig
f145766011
fs: add statfs() functions
This commit adds statfs() and statfsSync() to the fs module, and
statfs() to the fsPromises module.

Co-authored-by: cjihrig <cjihrig@gmail.com>
Fixes: https://github.com/nodejs/node/issues/10745
Refs: https://github.com/nodejs/node/pull/31351
PR-URL: https://github.com/nodejs/node/pull/46358
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-01-29 17:43:20 +00:00
Joyee Cheung
265ea1e74e
bootstrap: lazy load non-essential modules
It turns out that even with startup snapshots, there is a non-trivial
overhead for loading internal modules. This patch makes the loading
of the non-essential modules lazy again.

Caveat: we have to make some of the globals lazily-loaded too,
so the WPT runner is updated to test what the state of the global
scope is after the globals are accessed (and replaced with the
loaded value).

PR-URL: https://github.com/nodejs/node/pull/45659
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
2022-12-09 22:37:35 +00:00
Yagiz Nizipli
a5c6f3e8a1
fs: update todo message
PR-URL: https://github.com/nodejs/node/pull/45265
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2022-11-01 18:32:36 +00:00
Yagiz Nizipli
17ae2ab750
fs: add recursive watch to linux
PR-URL: https://github.com/nodejs/node/pull/45098
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-31 23:15:45 +00:00
Antoine du Hamel
eb32a8443a
lib: add lint rule to protect against Object.prototype.then pollution
PR-URL: https://github.com/nodejs/node/pull/45061
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-10-21 03:12:03 +00:00
Antoine du Hamel
a2fb3f9785
fs: add FileHandle.prototype.readLines
PR-URL: https://github.com/nodejs/node/pull/42590
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2022-10-10 02:16:40 +02:00
Ruben Bridgewater
d3dd49fe2b
fs: improve promise based readFile performance for big files
This significantly reduces the peak memory for the promise
based readFile operation by reusing a single memory chunk after
each read and strinigifying that chunk immediately.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: https://github.com/nodejs/node/pull/44295
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-06 17:03:56 +00:00
Livia Medeiros
a4fa526ddc
fs: add directory autodetection to fsPromises.symlink()
PR-URL: https://github.com/nodejs/node/pull/42894
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-10-03 01:04:28 +00:00
Livia Medeiros
950a4411fa
fs: remove coercion to string in writing methods
Moves DEP0162 to End-of-Life.

PR-URL: https://github.com/nodejs/node/pull/42796
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2022-09-12 09:29:43 +00:00
LiviaMedeiros
29953a0b88 fs: harden filehandle.read(params) typecheck
Make sure that first argument is a nullable object

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/42772
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-09-11 10:36:03 +00:00
LiviaMedeiros
c52454fdc3
fs: use kEmptyObject
PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-06-11 12:18:13 +02:00
Feng Yu
f76569356d
fs: export constants from fs/promises
PR-URL: https://github.com/nodejs/node/pull/43177
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-06-03 09:24:08 +01:00
LiviaMedeiros
fe027da1f0
fs: add trailing commas
PR-URL: https://github.com/nodejs/node/pull/43127
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
2022-05-18 12:17:36 +08:00
LiviaMedeiros
c100f9ad29
fs: make params in writing methods optional
This change allows passing objects as "named parameters":
- `fs.write(fd, buffer[, options], callback)`
- `fs.writeSync(fd, buffer[, options])`
- `filehandle.write(buffer[, options])`

Fixes: https://github.com/nodejs/node/issues/41666

PR-URL: https://github.com/nodejs/node/pull/42601
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-05-18 00:49:23 +08:00
Morgan Roderick
4a34ece28f
fs: remove unnecessary ?? operator
This was introduced in 57678e5581

With the `if` conditional around this statement, `options` will always
be evaluated as truthy. That means that the nullish coalescing operator
will always evaluate to the left side, make it unnecessary.

PR-URL: https://github.com/nodejs/node/pull/43073
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
2022-05-15 05:25:53 +01:00
Livia Medeiros
57678e5581
fs: add read(buffer[, options]) versions
This adds the following:
- `fs.read(fd, buffer[, options], callback)`.
- `filehandle.read(buffer[, options])`.

PR-URL: https://github.com/nodejs/node/pull/42768
Refs: https://github.com/nodejs/node/pull/42601
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-05-02 20:01:27 +02:00
Livia Medeiros
0c9273d126
fs: fix write methods param validation and docs
The FS docs wrongfully indicated support for passing object with an own 
`toString` function property to `FileHandle.prototype.appendFile`, 
`FileHandle.prototype.writeFile`, `FileHandle.prototype.write`, 
`fsPromises.writeFile`, and `fs.writeSync`. This commit fixes that, and 
adds some test to ensure the actual behavior is aligned with the docs.
It also fixes a bug that makes the process crash if a non-buffer object 
was passed to `FileHandle.prototype.write`.

Refs: https://github.com/nodejs/node/pull/34993
PR-URL: https://github.com/nodejs/node/pull/41677
Refs: https://github.com/nodejs/node/issues/41666
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-04-04 12:57:59 +02:00
Livia Medeiros
80bfb9b21a
fs: adjust default length for fs.readSync and fsPromises/read
Makes default length reasonable when nonzero offset is set.

PR-URL: https://github.com/nodejs/node/pull/42128
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-02-27 12:56:09 +00:00
Benjamin Gruenbaum
a137eca069
fs: fix writev empty array error behavior
PR-URL: https://github.com/nodejs/node/pull/41919
Fixes: https://github.com/nodejs/node/issues/41910
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-02-12 17:57:52 +00:00
Shinho Ahn
10493b48c7
fs: fix length option being ignored during read()
Currently, `length` in an options object is ignored.

PR-URL: https://github.com/nodejs/node/pull/40906
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-12-10 10:26:37 +00:00
James M Snell
b3f5c3b9d6
fs: propagate abortsignal reason in new AbortSignal constructors
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/41008
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2021-12-02 12:14:13 -08:00
Omar El-Mihilmy
2037ee85a2 fs: nullish coalescing to respect zero positional reads
When the file read position is moved passing zero is
not respected and `null` is used instead. PR fixes the
issues by using nullish coalescing which will return
the rhs only when the lhs is `null` or `undefined`;
respecting the zero.

Fixes: https://github.com/nodejs/node/issues/40715

PR-URL: https://github.com/nodejs/node/pull/40716
Fixes: https://github.com/nodejs/node/issues/40699
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2021-11-12 10:36:26 -08:00
Rich Trott
492d767b6d test: add semicolons for linter update
Add missing semicolons that will be flagged when we update
@babel/eslint-parser to 7.16.0.

PR-URL: https://github.com/nodejs/node/pull/40720
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-11-08 13:16:21 -08:00
Antoine du Hamel
026bd82e30
fs: add stream utilities to FileHandle
PR-URL: https://github.com/nodejs/node/pull/40009
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-09-25 07:57:31 -07:00
bcoe
87d6fd7e69
fs: add recursive cp method
Introduces recursive cp method, based on fs-extra implementation.

PR-URL: https://github.com/nodejs/node/pull/39372
Fixes: https://github.com/nodejs/node/issues/35880
Refs: https://github.com/nodejs/tooling/issues/98
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ian Sutherland <ian@iansutherland.ca>
2021-08-11 19:53:32 -07:00
James M Snell
6cd12be347
fs: add FileHandle.prototype.readableWebStream()
Adds an experimental `readableWebStream()` method to `FileHandle` that
returns a web `ReadableStream`

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/39331
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-07-15 13:43:20 -07:00
James M Snell
a99c230305
stream: implement streams to webstreams adapters
Experimental adapters for the webstreams API

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/39134
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-07-13 10:03:16 -07:00
XadillaX
2de139b5d5 lib: make lazyDOMException more common
PR-URL: https://github.com/nodejs/node/pull/39105
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-06-28 13:44:28 +08:00
Voltrex
1317252dfe fs: allow empty string for temp directory prefix
The `fs` lib module's `mkdtemp()` and `mkdtempSync()` methods were
missing a validator, and weren't allowing the empty string as a valid
prefix.

PR-URL: https://github.com/nodejs/node/pull/39028
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
2021-06-26 16:34:13 +02:00
Antoine du Hamel
2eeb4e1d94
lib: make primordials Promise methods safe
`catch` and `finally` methods on %Promise.prototype% looks up the `then`
property of the instance, making it at risk of prototype pollution.

PR-URL: https://github.com/nodejs/node/pull/38650
Refs: https://tc39.es/ecma262/#sec-promise.prototype.catch
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-05-19 09:21:37 -07:00
Nitzan Uziely
3612229d44
fs: fix async iterator partial writes
fix an issue where chunks might be partially written when
using writeFile with an async iterator.

PR-URL: https://github.com/nodejs/node/pull/38615
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-05-17 12:16:27 -07:00
Rongjian Zhang
8231cc4d42
fs: use assert in fsCall argument checking
In the user perspective, it's not an arguemnt type error. Replace it
with an `assert` expression.

PR-URL: https://github.com/nodejs/node/pull/38519
Refs: https://coverage.nodejs.org/coverage-68e6673224365120/lib/internal/fs/promises.js.html#L268
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-05-06 10:37:14 -07:00
James M Snell
4af15df013
src: fix validation of negative offset to avoid abort
Fixes: https://github.com/nodejs/node/issues/24640
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/38421
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-28 11:04:42 -07:00
Nitzan Uziely
f27b7cf95c
fs: aggregate errors in fsPromises to avoid error swallowing
Add AggregateError support to fsPromises, instead of
swallowing errors if fs.close throws.

PR-URL: https://github.com/nodejs/node/pull/38259
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:53:25 -07:00
Nitzan Uziely
5370220ab2 fs: allow no-params fsPromises fileHandle read
allow no-params read for fsPromises fileHandle read

PR-URL: https://github.com/nodejs/node/pull/38287
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-04-21 23:22:31 +02:00
Michaël Zasso
cb2bdc632a
typings: add types for internalBinding('fs')
PR-URL: https://github.com/nodejs/node/pull/38198
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-14 12:24:23 +02:00
Michaël Zasso
6bbe28552c
fs: use byteLength to handle ArrayBuffer views
Unlike TypedArray, DataView doesn't have a length property.

PR-URL: https://github.com/nodejs/node/pull/38187
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-12 14:39:13 -07:00
cjihrig
8e76397fab
fs: validate encoding to binding.writeString()
The binding layer performs some validation of the encoding and
data passed to WriteString(). This commit adds similar validation
to the JS layer for better error handling.

PR-URL: https://github.com/nodejs/node/pull/38183
Fixes: https://github.com/nodejs/node/issues/38168
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2021-04-11 23:57:29 -04:00
Darshan Sen
24fd791184
fs: move constants to internal/fs/utils.js
Refs: https://github.com/nodejs/node/pull/38004#discussion_r604951958

PR-URL: https://github.com/nodejs/node/pull/38061
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-06 12:24:15 -07:00