cloudstructs 0.1.38 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +19 -19
- package/.jsii +75 -31
- package/lib/codecommit-mirror/index.js +2 -2
- package/lib/ecs-service-roller/index.js +2 -2
- package/lib/email-receiver/receiver.js +1 -1
- package/lib/saml-identity-provider/index.js +2 -2
- package/lib/slack-events/index.js +1 -1
- package/lib/slack-textract/index.js +1 -1
- package/lib/state-machine-cr-provider/index.js +1 -1
- package/lib/static-website/index.js +1 -1
- package/lib/url-shortener/index.handler.js +2 -1
- package/lib/url-shortener/index.js +1 -1
- package/node_modules/@sindresorhus/is/dist/index.d.ts +9 -4
- package/node_modules/@sindresorhus/is/dist/index.js +9 -0
- package/node_modules/@sindresorhus/is/package.json +1 -1
- package/node_modules/@sindresorhus/is/readme.md +26 -0
- package/node_modules/@slack/logger/node_modules/@types/node/README.md +3 -3
- package/node_modules/@slack/logger/node_modules/@types/node/assert/strict.d.ts +0 -1
- package/node_modules/@slack/logger/node_modules/@types/node/assert.d.ts +823 -40
- package/node_modules/@slack/logger/node_modules/@types/node/async_hooks.d.ts +359 -90
- package/node_modules/@slack/logger/node_modules/@types/node/buffer.d.ts +1895 -113
- package/node_modules/@slack/logger/node_modules/@types/node/child_process.d.ts +1080 -247
- package/node_modules/@slack/logger/node_modules/@types/node/cluster.d.ts +327 -101
- package/node_modules/@slack/logger/node_modules/@types/node/console.d.ts +310 -32
- package/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +2454 -742
- package/node_modules/@slack/logger/node_modules/@types/node/dgram.d.ts +463 -63
- package/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +109 -13
- package/node_modules/@slack/logger/node_modules/@types/node/dns/promises.d.ts +303 -36
- package/node_modules/@slack/logger/node_modules/@types/node/dns.d.ts +425 -97
- package/node_modules/@slack/logger/node_modules/@types/node/domain.d.ts +154 -10
- package/node_modules/@slack/logger/node_modules/@types/node/events.d.ts +559 -34
- package/node_modules/@slack/logger/node_modules/@types/node/fs/promises.d.ts +812 -269
- package/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +2408 -874
- package/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +24 -14
- package/node_modules/@slack/logger/node_modules/@types/node/http.d.ts +1031 -98
- package/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +1579 -459
- package/node_modules/@slack/logger/node_modules/@types/node/https.d.ts +363 -12
- package/node_modules/@slack/logger/node_modules/@types/node/index.d.ts +88 -15
- package/node_modules/@slack/logger/node_modules/@types/node/inspector.d.ts +360 -661
- package/node_modules/@slack/logger/node_modules/@types/node/module.d.ts +52 -11
- package/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +557 -142
- package/node_modules/@slack/logger/node_modules/@types/node/os.d.ts +236 -26
- package/node_modules/@slack/logger/node_modules/@types/node/package.json +23 -25
- package/node_modules/@slack/logger/node_modules/@types/node/path.d.ts +9 -5
- package/node_modules/@slack/logger/node_modules/@types/node/perf_hooks.d.ts +289 -91
- package/node_modules/@slack/logger/node_modules/@types/node/process.d.ts +1173 -155
- package/node_modules/@slack/logger/node_modules/@types/node/punycode.d.ts +64 -26
- package/node_modules/@slack/logger/node_modules/@types/node/querystring.d.ts +107 -8
- package/node_modules/@slack/logger/node_modules/@types/node/readline.d.ts +426 -79
- package/node_modules/@slack/logger/node_modules/@types/node/repl.d.ts +135 -110
- package/node_modules/@slack/logger/node_modules/@types/node/stream/consumers.d.ts +24 -0
- package/node_modules/@slack/logger/node_modules/@types/node/stream/promises.d.ts +15 -44
- package/node_modules/@slack/logger/node_modules/@types/node/stream/web.d.ts +391 -0
- package/node_modules/@slack/logger/node_modules/@types/node/stream.d.ts +998 -225
- package/node_modules/@slack/logger/node_modules/@types/node/string_decoder.d.ts +57 -1
- package/node_modules/@slack/logger/node_modules/@types/node/timers/promises.d.ts +52 -9
- package/node_modules/@slack/logger/node_modules/@types/node/timers.d.ts +30 -11
- package/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +447 -225
- package/node_modules/@slack/logger/node_modules/@types/node/trace_events.d.ts +107 -11
- package/node_modules/@slack/logger/node_modules/@types/node/tty.d.ts +157 -23
- package/node_modules/@slack/logger/node_modules/@types/node/url.d.ts +724 -30
- package/node_modules/@slack/logger/node_modules/@types/node/util.d.ts +1399 -73
- package/node_modules/@slack/logger/node_modules/@types/node/v8.d.ts +254 -78
- package/node_modules/@slack/logger/node_modules/@types/node/vm.d.ts +384 -33
- package/node_modules/@slack/logger/node_modules/@types/node/wasi.d.ts +92 -24
- package/node_modules/@slack/logger/node_modules/@types/node/worker_threads.d.ts +494 -131
- package/node_modules/@slack/logger/node_modules/@types/node/zlib.d.ts +215 -63
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +3 -3
- package/node_modules/@slack/web-api/node_modules/@types/node/assert/strict.d.ts +0 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/assert.d.ts +823 -40
- package/node_modules/@slack/web-api/node_modules/@types/node/async_hooks.d.ts +359 -90
- package/node_modules/@slack/web-api/node_modules/@types/node/buffer.d.ts +1895 -113
- package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +1080 -247
- package/node_modules/@slack/web-api/node_modules/@types/node/cluster.d.ts +327 -101
- package/node_modules/@slack/web-api/node_modules/@types/node/console.d.ts +310 -32
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +2454 -742
- package/node_modules/@slack/web-api/node_modules/@types/node/dgram.d.ts +463 -63
- package/node_modules/@slack/web-api/node_modules/@types/node/diagnostics_channel.d.ts +109 -13
- package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +303 -36
- package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +425 -97
- package/node_modules/@slack/web-api/node_modules/@types/node/domain.d.ts +154 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/events.d.ts +559 -34
- package/node_modules/@slack/web-api/node_modules/@types/node/fs/promises.d.ts +812 -269
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +2408 -874
- package/node_modules/@slack/web-api/node_modules/@types/node/globals.d.ts +24 -14
- package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +1031 -98
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +1579 -459
- package/node_modules/@slack/web-api/node_modules/@types/node/https.d.ts +363 -12
- package/node_modules/@slack/web-api/node_modules/@types/node/index.d.ts +88 -15
- package/node_modules/@slack/web-api/node_modules/@types/node/inspector.d.ts +360 -661
- package/node_modules/@slack/web-api/node_modules/@types/node/module.d.ts +52 -11
- package/node_modules/@slack/web-api/node_modules/@types/node/net.d.ts +557 -142
- package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +236 -26
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +23 -25
- package/node_modules/@slack/web-api/node_modules/@types/node/path.d.ts +9 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +289 -91
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +1173 -155
- package/node_modules/@slack/web-api/node_modules/@types/node/punycode.d.ts +64 -26
- package/node_modules/@slack/web-api/node_modules/@types/node/querystring.d.ts +107 -8
- package/node_modules/@slack/web-api/node_modules/@types/node/readline.d.ts +426 -79
- package/node_modules/@slack/web-api/node_modules/@types/node/repl.d.ts +135 -110
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/consumers.d.ts +24 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/promises.d.ts +15 -44
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/web.d.ts +391 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/stream.d.ts +998 -225
- package/node_modules/@slack/web-api/node_modules/@types/node/string_decoder.d.ts +57 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/timers/promises.d.ts +52 -9
- package/node_modules/@slack/web-api/node_modules/@types/node/timers.d.ts +30 -11
- package/node_modules/@slack/web-api/node_modules/@types/node/tls.d.ts +447 -225
- package/node_modules/@slack/web-api/node_modules/@types/node/trace_events.d.ts +107 -11
- package/node_modules/@slack/web-api/node_modules/@types/node/tty.d.ts +157 -23
- package/node_modules/@slack/web-api/node_modules/@types/node/url.d.ts +724 -30
- package/node_modules/@slack/web-api/node_modules/@types/node/util.d.ts +1399 -73
- package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +254 -78
- package/node_modules/@slack/web-api/node_modules/@types/node/vm.d.ts +384 -33
- package/node_modules/@slack/web-api/node_modules/@types/node/wasi.d.ts +92 -24
- package/node_modules/@slack/web-api/node_modules/@types/node/worker_threads.d.ts +494 -131
- package/node_modules/@slack/web-api/node_modules/@types/node/zlib.d.ts +215 -63
- package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +3 -3
- package/node_modules/@types/cacheable-request/node_modules/@types/node/assert/strict.d.ts +0 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/assert.d.ts +823 -40
- package/node_modules/@types/cacheable-request/node_modules/@types/node/async_hooks.d.ts +359 -90
- package/node_modules/@types/cacheable-request/node_modules/@types/node/buffer.d.ts +1895 -113
- package/node_modules/@types/cacheable-request/node_modules/@types/node/child_process.d.ts +1080 -247
- package/node_modules/@types/cacheable-request/node_modules/@types/node/cluster.d.ts +327 -101
- package/node_modules/@types/cacheable-request/node_modules/@types/node/console.d.ts +310 -32
- package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +2454 -742
- package/node_modules/@types/cacheable-request/node_modules/@types/node/dgram.d.ts +463 -63
- package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostics_channel.d.ts +109 -13
- package/node_modules/@types/cacheable-request/node_modules/@types/node/dns/promises.d.ts +303 -36
- package/node_modules/@types/cacheable-request/node_modules/@types/node/dns.d.ts +425 -97
- package/node_modules/@types/cacheable-request/node_modules/@types/node/domain.d.ts +154 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/events.d.ts +559 -34
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs/promises.d.ts +812 -269
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +2408 -874
- package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.d.ts +24 -14
- package/node_modules/@types/cacheable-request/node_modules/@types/node/http.d.ts +1031 -98
- package/node_modules/@types/cacheable-request/node_modules/@types/node/http2.d.ts +1579 -459
- package/node_modules/@types/cacheable-request/node_modules/@types/node/https.d.ts +363 -12
- package/node_modules/@types/cacheable-request/node_modules/@types/node/index.d.ts +88 -15
- package/node_modules/@types/cacheable-request/node_modules/@types/node/inspector.d.ts +360 -661
- package/node_modules/@types/cacheable-request/node_modules/@types/node/module.d.ts +52 -11
- package/node_modules/@types/cacheable-request/node_modules/@types/node/net.d.ts +557 -142
- package/node_modules/@types/cacheable-request/node_modules/@types/node/os.d.ts +236 -26
- package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +23 -25
- package/node_modules/@types/cacheable-request/node_modules/@types/node/path.d.ts +9 -5
- package/node_modules/@types/cacheable-request/node_modules/@types/node/perf_hooks.d.ts +289 -91
- package/node_modules/@types/cacheable-request/node_modules/@types/node/process.d.ts +1173 -155
- package/node_modules/@types/cacheable-request/node_modules/@types/node/punycode.d.ts +64 -26
- package/node_modules/@types/cacheable-request/node_modules/@types/node/querystring.d.ts +107 -8
- package/node_modules/@types/cacheable-request/node_modules/@types/node/readline.d.ts +426 -79
- package/node_modules/@types/cacheable-request/node_modules/@types/node/repl.d.ts +135 -110
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/consumers.d.ts +24 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/promises.d.ts +15 -44
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/web.d.ts +391 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream.d.ts +998 -225
- package/node_modules/@types/cacheable-request/node_modules/@types/node/string_decoder.d.ts +57 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/timers/promises.d.ts +52 -9
- package/node_modules/@types/cacheable-request/node_modules/@types/node/timers.d.ts +30 -11
- package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +447 -225
- package/node_modules/@types/cacheable-request/node_modules/@types/node/trace_events.d.ts +107 -11
- package/node_modules/@types/cacheable-request/node_modules/@types/node/tty.d.ts +157 -23
- package/node_modules/@types/cacheable-request/node_modules/@types/node/url.d.ts +724 -30
- package/node_modules/@types/cacheable-request/node_modules/@types/node/util.d.ts +1399 -73
- package/node_modules/@types/cacheable-request/node_modules/@types/node/v8.d.ts +254 -78
- package/node_modules/@types/cacheable-request/node_modules/@types/node/vm.d.ts +384 -33
- package/node_modules/@types/cacheable-request/node_modules/@types/node/wasi.d.ts +92 -24
- package/node_modules/@types/cacheable-request/node_modules/@types/node/worker_threads.d.ts +494 -131
- package/node_modules/@types/cacheable-request/node_modules/@types/node/zlib.d.ts +215 -63
- package/node_modules/@types/is-stream/node_modules/@types/node/README.md +3 -3
- package/node_modules/@types/is-stream/node_modules/@types/node/assert/strict.d.ts +0 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/assert.d.ts +823 -40
- package/node_modules/@types/is-stream/node_modules/@types/node/async_hooks.d.ts +359 -90
- package/node_modules/@types/is-stream/node_modules/@types/node/buffer.d.ts +1895 -113
- package/node_modules/@types/is-stream/node_modules/@types/node/child_process.d.ts +1080 -247
- package/node_modules/@types/is-stream/node_modules/@types/node/cluster.d.ts +327 -101
- package/node_modules/@types/is-stream/node_modules/@types/node/console.d.ts +310 -32
- package/node_modules/@types/is-stream/node_modules/@types/node/crypto.d.ts +2454 -742
- package/node_modules/@types/is-stream/node_modules/@types/node/dgram.d.ts +463 -63
- package/node_modules/@types/is-stream/node_modules/@types/node/diagnostics_channel.d.ts +109 -13
- package/node_modules/@types/is-stream/node_modules/@types/node/dns/promises.d.ts +303 -36
- package/node_modules/@types/is-stream/node_modules/@types/node/dns.d.ts +425 -97
- package/node_modules/@types/is-stream/node_modules/@types/node/domain.d.ts +154 -10
- package/node_modules/@types/is-stream/node_modules/@types/node/events.d.ts +559 -34
- package/node_modules/@types/is-stream/node_modules/@types/node/fs/promises.d.ts +812 -269
- package/node_modules/@types/is-stream/node_modules/@types/node/fs.d.ts +2408 -874
- package/node_modules/@types/is-stream/node_modules/@types/node/globals.d.ts +24 -14
- package/node_modules/@types/is-stream/node_modules/@types/node/http.d.ts +1031 -98
- package/node_modules/@types/is-stream/node_modules/@types/node/http2.d.ts +1579 -459
- package/node_modules/@types/is-stream/node_modules/@types/node/https.d.ts +363 -12
- package/node_modules/@types/is-stream/node_modules/@types/node/index.d.ts +88 -15
- package/node_modules/@types/is-stream/node_modules/@types/node/inspector.d.ts +360 -661
- package/node_modules/@types/is-stream/node_modules/@types/node/module.d.ts +52 -11
- package/node_modules/@types/is-stream/node_modules/@types/node/net.d.ts +557 -142
- package/node_modules/@types/is-stream/node_modules/@types/node/os.d.ts +236 -26
- package/node_modules/@types/is-stream/node_modules/@types/node/package.json +23 -25
- package/node_modules/@types/is-stream/node_modules/@types/node/path.d.ts +9 -5
- package/node_modules/@types/is-stream/node_modules/@types/node/perf_hooks.d.ts +289 -91
- package/node_modules/@types/is-stream/node_modules/@types/node/process.d.ts +1173 -155
- package/node_modules/@types/is-stream/node_modules/@types/node/punycode.d.ts +64 -26
- package/node_modules/@types/is-stream/node_modules/@types/node/querystring.d.ts +107 -8
- package/node_modules/@types/is-stream/node_modules/@types/node/readline.d.ts +426 -79
- package/node_modules/@types/is-stream/node_modules/@types/node/repl.d.ts +135 -110
- package/node_modules/@types/is-stream/node_modules/@types/node/stream/consumers.d.ts +24 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/stream/promises.d.ts +15 -44
- package/node_modules/@types/is-stream/node_modules/@types/node/stream/web.d.ts +391 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/stream.d.ts +998 -225
- package/node_modules/@types/is-stream/node_modules/@types/node/string_decoder.d.ts +57 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/timers/promises.d.ts +52 -9
- package/node_modules/@types/is-stream/node_modules/@types/node/timers.d.ts +30 -11
- package/node_modules/@types/is-stream/node_modules/@types/node/tls.d.ts +447 -225
- package/node_modules/@types/is-stream/node_modules/@types/node/trace_events.d.ts +107 -11
- package/node_modules/@types/is-stream/node_modules/@types/node/tty.d.ts +157 -23
- package/node_modules/@types/is-stream/node_modules/@types/node/url.d.ts +724 -30
- package/node_modules/@types/is-stream/node_modules/@types/node/util.d.ts +1399 -73
- package/node_modules/@types/is-stream/node_modules/@types/node/v8.d.ts +254 -78
- package/node_modules/@types/is-stream/node_modules/@types/node/vm.d.ts +384 -33
- package/node_modules/@types/is-stream/node_modules/@types/node/wasi.d.ts +92 -24
- package/node_modules/@types/is-stream/node_modules/@types/node/worker_threads.d.ts +494 -131
- package/node_modules/@types/is-stream/node_modules/@types/node/zlib.d.ts +215 -63
- package/node_modules/@types/keyv/README.md +1 -1
- package/node_modules/@types/keyv/index.d.ts +10 -3
- package/node_modules/@types/keyv/node_modules/@types/node/README.md +3 -3
- package/node_modules/@types/keyv/node_modules/@types/node/assert/strict.d.ts +0 -1
- package/node_modules/@types/keyv/node_modules/@types/node/assert.d.ts +823 -40
- package/node_modules/@types/keyv/node_modules/@types/node/async_hooks.d.ts +359 -90
- package/node_modules/@types/keyv/node_modules/@types/node/buffer.d.ts +1895 -113
- package/node_modules/@types/keyv/node_modules/@types/node/child_process.d.ts +1080 -247
- package/node_modules/@types/keyv/node_modules/@types/node/cluster.d.ts +327 -101
- package/node_modules/@types/keyv/node_modules/@types/node/console.d.ts +310 -32
- package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +2454 -742
- package/node_modules/@types/keyv/node_modules/@types/node/dgram.d.ts +463 -63
- package/node_modules/@types/keyv/node_modules/@types/node/diagnostics_channel.d.ts +109 -13
- package/node_modules/@types/keyv/node_modules/@types/node/dns/promises.d.ts +303 -36
- package/node_modules/@types/keyv/node_modules/@types/node/dns.d.ts +425 -97
- package/node_modules/@types/keyv/node_modules/@types/node/domain.d.ts +154 -10
- package/node_modules/@types/keyv/node_modules/@types/node/events.d.ts +559 -34
- package/node_modules/@types/keyv/node_modules/@types/node/fs/promises.d.ts +812 -269
- package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +2408 -874
- package/node_modules/@types/keyv/node_modules/@types/node/globals.d.ts +24 -14
- package/node_modules/@types/keyv/node_modules/@types/node/http.d.ts +1031 -98
- package/node_modules/@types/keyv/node_modules/@types/node/http2.d.ts +1579 -459
- package/node_modules/@types/keyv/node_modules/@types/node/https.d.ts +363 -12
- package/node_modules/@types/keyv/node_modules/@types/node/index.d.ts +88 -15
- package/node_modules/@types/keyv/node_modules/@types/node/inspector.d.ts +360 -661
- package/node_modules/@types/keyv/node_modules/@types/node/module.d.ts +52 -11
- package/node_modules/@types/keyv/node_modules/@types/node/net.d.ts +557 -142
- package/node_modules/@types/keyv/node_modules/@types/node/os.d.ts +236 -26
- package/node_modules/@types/keyv/node_modules/@types/node/package.json +23 -25
- package/node_modules/@types/keyv/node_modules/@types/node/path.d.ts +9 -5
- package/node_modules/@types/keyv/node_modules/@types/node/perf_hooks.d.ts +289 -91
- package/node_modules/@types/keyv/node_modules/@types/node/process.d.ts +1173 -155
- package/node_modules/@types/keyv/node_modules/@types/node/punycode.d.ts +64 -26
- package/node_modules/@types/keyv/node_modules/@types/node/querystring.d.ts +107 -8
- package/node_modules/@types/keyv/node_modules/@types/node/readline.d.ts +426 -79
- package/node_modules/@types/keyv/node_modules/@types/node/repl.d.ts +135 -110
- package/node_modules/@types/keyv/node_modules/@types/node/stream/consumers.d.ts +24 -0
- package/node_modules/@types/keyv/node_modules/@types/node/stream/promises.d.ts +15 -44
- package/node_modules/@types/keyv/node_modules/@types/node/stream/web.d.ts +391 -0
- package/node_modules/@types/keyv/node_modules/@types/node/stream.d.ts +998 -225
- package/node_modules/@types/keyv/node_modules/@types/node/string_decoder.d.ts +57 -1
- package/node_modules/@types/keyv/node_modules/@types/node/timers/promises.d.ts +52 -9
- package/node_modules/@types/keyv/node_modules/@types/node/timers.d.ts +30 -11
- package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +447 -225
- package/node_modules/@types/keyv/node_modules/@types/node/trace_events.d.ts +107 -11
- package/node_modules/@types/keyv/node_modules/@types/node/tty.d.ts +157 -23
- package/node_modules/@types/keyv/node_modules/@types/node/url.d.ts +724 -30
- package/node_modules/@types/keyv/node_modules/@types/node/util.d.ts +1399 -73
- package/node_modules/@types/keyv/node_modules/@types/node/v8.d.ts +254 -78
- package/node_modules/@types/keyv/node_modules/@types/node/vm.d.ts +384 -33
- package/node_modules/@types/keyv/node_modules/@types/node/wasi.d.ts +92 -24
- package/node_modules/@types/keyv/node_modules/@types/node/worker_threads.d.ts +494 -131
- package/node_modules/@types/keyv/node_modules/@types/node/zlib.d.ts +215 -63
- package/node_modules/@types/keyv/package.json +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/README.md +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/assert/strict.d.ts +0 -1
- package/node_modules/@types/responselike/node_modules/@types/node/assert.d.ts +823 -40
- package/node_modules/@types/responselike/node_modules/@types/node/async_hooks.d.ts +359 -90
- package/node_modules/@types/responselike/node_modules/@types/node/buffer.d.ts +1895 -113
- package/node_modules/@types/responselike/node_modules/@types/node/child_process.d.ts +1080 -247
- package/node_modules/@types/responselike/node_modules/@types/node/cluster.d.ts +327 -101
- package/node_modules/@types/responselike/node_modules/@types/node/console.d.ts +310 -32
- package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +2454 -742
- package/node_modules/@types/responselike/node_modules/@types/node/dgram.d.ts +463 -63
- package/node_modules/@types/responselike/node_modules/@types/node/diagnostics_channel.d.ts +109 -13
- package/node_modules/@types/responselike/node_modules/@types/node/dns/promises.d.ts +303 -36
- package/node_modules/@types/responselike/node_modules/@types/node/dns.d.ts +425 -97
- package/node_modules/@types/responselike/node_modules/@types/node/domain.d.ts +154 -10
- package/node_modules/@types/responselike/node_modules/@types/node/events.d.ts +559 -34
- package/node_modules/@types/responselike/node_modules/@types/node/fs/promises.d.ts +812 -269
- package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +2408 -874
- package/node_modules/@types/responselike/node_modules/@types/node/globals.d.ts +24 -14
- package/node_modules/@types/responselike/node_modules/@types/node/http.d.ts +1031 -98
- package/node_modules/@types/responselike/node_modules/@types/node/http2.d.ts +1579 -459
- package/node_modules/@types/responselike/node_modules/@types/node/https.d.ts +363 -12
- package/node_modules/@types/responselike/node_modules/@types/node/index.d.ts +88 -15
- package/node_modules/@types/responselike/node_modules/@types/node/inspector.d.ts +360 -661
- package/node_modules/@types/responselike/node_modules/@types/node/module.d.ts +52 -11
- package/node_modules/@types/responselike/node_modules/@types/node/net.d.ts +557 -142
- package/node_modules/@types/responselike/node_modules/@types/node/os.d.ts +236 -26
- package/node_modules/@types/responselike/node_modules/@types/node/package.json +23 -25
- package/node_modules/@types/responselike/node_modules/@types/node/path.d.ts +9 -5
- package/node_modules/@types/responselike/node_modules/@types/node/perf_hooks.d.ts +289 -91
- package/node_modules/@types/responselike/node_modules/@types/node/process.d.ts +1173 -155
- package/node_modules/@types/responselike/node_modules/@types/node/punycode.d.ts +64 -26
- package/node_modules/@types/responselike/node_modules/@types/node/querystring.d.ts +107 -8
- package/node_modules/@types/responselike/node_modules/@types/node/readline.d.ts +426 -79
- package/node_modules/@types/responselike/node_modules/@types/node/repl.d.ts +135 -110
- package/node_modules/@types/responselike/node_modules/@types/node/stream/consumers.d.ts +24 -0
- package/node_modules/@types/responselike/node_modules/@types/node/stream/promises.d.ts +15 -44
- package/node_modules/@types/responselike/node_modules/@types/node/stream/web.d.ts +391 -0
- package/node_modules/@types/responselike/node_modules/@types/node/stream.d.ts +998 -225
- package/node_modules/@types/responselike/node_modules/@types/node/string_decoder.d.ts +57 -1
- package/node_modules/@types/responselike/node_modules/@types/node/timers/promises.d.ts +52 -9
- package/node_modules/@types/responselike/node_modules/@types/node/timers.d.ts +30 -11
- package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +447 -225
- package/node_modules/@types/responselike/node_modules/@types/node/trace_events.d.ts +107 -11
- package/node_modules/@types/responselike/node_modules/@types/node/tty.d.ts +157 -23
- package/node_modules/@types/responselike/node_modules/@types/node/url.d.ts +724 -30
- package/node_modules/@types/responselike/node_modules/@types/node/util.d.ts +1399 -73
- package/node_modules/@types/responselike/node_modules/@types/node/v8.d.ts +254 -78
- package/node_modules/@types/responselike/node_modules/@types/node/vm.d.ts +384 -33
- package/node_modules/@types/responselike/node_modules/@types/node/wasi.d.ts +92 -24
- package/node_modules/@types/responselike/node_modules/@types/node/worker_threads.d.ts +494 -131
- package/node_modules/@types/responselike/node_modules/@types/node/zlib.d.ts +215 -63
- package/node_modules/axios/CHANGELOG.md +98 -8
- package/node_modules/axios/README.md +74 -6
- package/node_modules/axios/SECURITY.md +5 -0
- package/node_modules/axios/dist/axios.js +2028 -1591
- package/node_modules/axios/dist/axios.map +1 -1
- package/node_modules/axios/dist/axios.min.js +2 -2
- package/node_modules/axios/dist/axios.min.map +1 -1
- package/node_modules/axios/index.d.ts +8 -1
- package/node_modules/axios/lib/adapters/http.js +33 -5
- package/node_modules/axios/lib/adapters/xhr.js +35 -25
- package/node_modules/axios/lib/core/Axios.js +60 -7
- package/node_modules/axios/lib/core/InterceptorManager.js +4 -2
- package/node_modules/axios/lib/core/README.md +1 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +6 -3
- package/node_modules/axios/lib/core/transformData.js +3 -1
- package/node_modules/axios/lib/defaults.js +43 -7
- package/node_modules/axios/lib/helpers/validator.js +105 -0
- package/node_modules/axios/lib/utils.js +1 -3
- package/node_modules/axios/package.json +19 -21
- package/node_modules/follow-redirects/debug.js +2 -1
- package/node_modules/follow-redirects/index.js +59 -21
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/got/dist/source/as-promise/parse-body.d.ts +1 -1
- package/node_modules/got/dist/source/as-promise/types.js +2 -0
- package/node_modules/got/dist/source/core/index.d.ts +1 -1
- package/node_modules/got/dist/source/core/index.js +9 -3
- package/node_modules/got/dist/source/types.d.ts +14 -12
- package/node_modules/got/package.json +2 -2
- package/node_modules/got/readme.md +11 -10
- package/node_modules/keyv/LICENSE +1 -1
- package/node_modules/keyv/README.md +12 -10
- package/node_modules/keyv/package.json +17 -12
- package/node_modules/keyv/src/index.js +14 -16
- package/node_modules/mime-db/HISTORY.md +19 -0
- package/node_modules/mime-db/db.json +93 -1
- package/node_modules/mime-db/package.json +7 -7
- package/node_modules/mime-types/HISTORY.md +20 -3
- package/node_modules/mime-types/package.json +7 -7
- package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/index.d.ts +0 -0
- package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/index.js +0 -0
- package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/license +0 -0
- package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/package.json +0 -0
- package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/readme.md +0 -0
- package/node_modules/resolve-alpn/README.md +8 -1
- package/node_modules/resolve-alpn/index.js +14 -4
- package/node_modules/resolve-alpn/package.json +1 -1
- package/package.json +33 -34
- package/node_modules/@slack/logger/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/assert.d.ts +0 -103
- package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/base.d.ts +0 -67
- package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/index.d.ts +0 -7
- package/node_modules/@slack/web-api/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/assert.d.ts +0 -103
- package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/base.d.ts +0 -67
- package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/index.d.ts +0 -7
- package/node_modules/@types/cacheable-request/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/assert.d.ts +0 -103
- package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/base.d.ts +0 -67
- package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/index.d.ts +0 -7
- package/node_modules/@types/is-stream/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/assert.d.ts +0 -103
- package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/base.d.ts +0 -67
- package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/index.d.ts +0 -7
- package/node_modules/@types/keyv/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/assert.d.ts +0 -103
- package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/base.d.ts +0 -67
- package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/index.d.ts +0 -7
- package/node_modules/@types/responselike/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/assert.d.ts +0 -103
- package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/base.d.ts +0 -67
- package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/index.d.ts +0 -7
|
@@ -1,33 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `fs` module enables interacting with the file system in a
|
|
3
|
+
* way modeled on standard POSIX functions.
|
|
4
|
+
*
|
|
5
|
+
* To use the promise-based APIs:
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* import * as fs from 'fs/promises';
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* To use the callback and sync APIs:
|
|
12
|
+
*
|
|
13
|
+
* ```js
|
|
14
|
+
* import * as fs from 'fs';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* All file system operations have synchronous, callback, and promise-based
|
|
18
|
+
* forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
|
|
19
|
+
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/fs.js)
|
|
20
|
+
*/
|
|
1
21
|
declare module 'fs' {
|
|
2
22
|
import * as stream from 'node:stream';
|
|
3
23
|
import { Abortable, EventEmitter } from 'node:events';
|
|
4
24
|
import { URL } from 'node:url';
|
|
5
25
|
import * as promises from 'node:fs/promises';
|
|
6
|
-
|
|
7
26
|
export { promises };
|
|
8
27
|
/**
|
|
9
28
|
* Valid types for path values in "fs".
|
|
10
29
|
*/
|
|
11
30
|
export type PathLike = string | Buffer | URL;
|
|
12
|
-
|
|
13
31
|
export type PathOrFileDescriptor = PathLike | number;
|
|
14
|
-
|
|
15
32
|
export type TimeLike = string | number | Date;
|
|
16
|
-
|
|
17
33
|
export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
export type BufferEncodingOption =
|
|
35
|
+
| 'buffer'
|
|
36
|
+
| {
|
|
37
|
+
encoding: 'buffer';
|
|
38
|
+
};
|
|
21
39
|
export interface ObjectEncodingOptions {
|
|
22
40
|
encoding?: BufferEncoding | null | undefined;
|
|
23
41
|
}
|
|
24
|
-
|
|
25
42
|
export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null;
|
|
26
|
-
|
|
27
43
|
export type OpenMode = number | string;
|
|
28
|
-
|
|
29
44
|
export type Mode = number | string;
|
|
30
|
-
|
|
31
45
|
export interface StatsBase<T> {
|
|
32
46
|
isFile(): boolean;
|
|
33
47
|
isDirectory(): boolean;
|
|
@@ -36,7 +50,6 @@ declare module 'fs' {
|
|
|
36
50
|
isSymbolicLink(): boolean;
|
|
37
51
|
isFIFO(): boolean;
|
|
38
52
|
isSocket(): boolean;
|
|
39
|
-
|
|
40
53
|
dev: T;
|
|
41
54
|
ino: T;
|
|
42
55
|
mode: T;
|
|
@@ -56,237 +69,437 @@ declare module 'fs' {
|
|
|
56
69
|
ctime: Date;
|
|
57
70
|
birthtime: Date;
|
|
58
71
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
export interface Stats extends StatsBase<number> {}
|
|
73
|
+
/**
|
|
74
|
+
* A `fs.Stats` object provides information about a file.
|
|
75
|
+
*
|
|
76
|
+
* Objects returned from {@link stat}, {@link lstat} and {@link fstat} and
|
|
77
|
+
* their synchronous counterparts are of this type.
|
|
78
|
+
* If `bigint` in the `options` passed to those methods is true, the numeric values
|
|
79
|
+
* will be `bigint` instead of `number`, and the object will contain additional
|
|
80
|
+
* nanosecond-precision properties suffixed with `Ns`.
|
|
81
|
+
*
|
|
82
|
+
* ```console
|
|
83
|
+
* Stats {
|
|
84
|
+
* dev: 2114,
|
|
85
|
+
* ino: 48064969,
|
|
86
|
+
* mode: 33188,
|
|
87
|
+
* nlink: 1,
|
|
88
|
+
* uid: 85,
|
|
89
|
+
* gid: 100,
|
|
90
|
+
* rdev: 0,
|
|
91
|
+
* size: 527,
|
|
92
|
+
* blksize: 4096,
|
|
93
|
+
* blocks: 8,
|
|
94
|
+
* atimeMs: 1318289051000.1,
|
|
95
|
+
* mtimeMs: 1318289051000.1,
|
|
96
|
+
* ctimeMs: 1318289051000.1,
|
|
97
|
+
* birthtimeMs: 1318289051000.1,
|
|
98
|
+
* atime: Mon, 10 Oct 2011 23:24:11 GMT,
|
|
99
|
+
* mtime: Mon, 10 Oct 2011 23:24:11 GMT,
|
|
100
|
+
* ctime: Mon, 10 Oct 2011 23:24:11 GMT,
|
|
101
|
+
* birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* `bigint` version:
|
|
105
|
+
*
|
|
106
|
+
* ```console
|
|
107
|
+
* BigIntStats {
|
|
108
|
+
* dev: 2114n,
|
|
109
|
+
* ino: 48064969n,
|
|
110
|
+
* mode: 33188n,
|
|
111
|
+
* nlink: 1n,
|
|
112
|
+
* uid: 85n,
|
|
113
|
+
* gid: 100n,
|
|
114
|
+
* rdev: 0n,
|
|
115
|
+
* size: 527n,
|
|
116
|
+
* blksize: 4096n,
|
|
117
|
+
* blocks: 8n,
|
|
118
|
+
* atimeMs: 1318289051000n,
|
|
119
|
+
* mtimeMs: 1318289051000n,
|
|
120
|
+
* ctimeMs: 1318289051000n,
|
|
121
|
+
* birthtimeMs: 1318289051000n,
|
|
122
|
+
* atimeNs: 1318289051000000000n,
|
|
123
|
+
* mtimeNs: 1318289051000000000n,
|
|
124
|
+
* ctimeNs: 1318289051000000000n,
|
|
125
|
+
* birthtimeNs: 1318289051000000000n,
|
|
126
|
+
* atime: Mon, 10 Oct 2011 23:24:11 GMT,
|
|
127
|
+
* mtime: Mon, 10 Oct 2011 23:24:11 GMT,
|
|
128
|
+
* ctime: Mon, 10 Oct 2011 23:24:11 GMT,
|
|
129
|
+
* birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
|
|
130
|
+
* ```
|
|
131
|
+
* @since v0.1.21
|
|
132
|
+
*/
|
|
133
|
+
export class Stats {}
|
|
134
|
+
/**
|
|
135
|
+
* A representation of a directory entry, which can be a file or a subdirectory
|
|
136
|
+
* within the directory, as returned by reading from an `fs.Dir`. The
|
|
137
|
+
* directory entry is a combination of the file name and file type pairs.
|
|
138
|
+
*
|
|
139
|
+
* Additionally, when {@link readdir} or {@link readdirSync} is called with
|
|
140
|
+
* the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.
|
|
141
|
+
* @since v10.10.0
|
|
142
|
+
*/
|
|
66
143
|
export class Dirent {
|
|
144
|
+
/**
|
|
145
|
+
* Returns `true` if the `fs.Dirent` object describes a regular file.
|
|
146
|
+
* @since v10.10.0
|
|
147
|
+
*/
|
|
67
148
|
isFile(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Returns `true` if the `fs.Dirent` object describes a file system
|
|
151
|
+
* directory.
|
|
152
|
+
* @since v10.10.0
|
|
153
|
+
*/
|
|
68
154
|
isDirectory(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Returns `true` if the `fs.Dirent` object describes a block device.
|
|
157
|
+
* @since v10.10.0
|
|
158
|
+
*/
|
|
69
159
|
isBlockDevice(): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Returns `true` if the `fs.Dirent` object describes a character device.
|
|
162
|
+
* @since v10.10.0
|
|
163
|
+
*/
|
|
70
164
|
isCharacterDevice(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Returns `true` if the `fs.Dirent` object describes a symbolic link.
|
|
167
|
+
* @since v10.10.0
|
|
168
|
+
*/
|
|
71
169
|
isSymbolicLink(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Returns `true` if the `fs.Dirent` object describes a first-in-first-out
|
|
172
|
+
* (FIFO) pipe.
|
|
173
|
+
* @since v10.10.0
|
|
174
|
+
*/
|
|
72
175
|
isFIFO(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Returns `true` if the `fs.Dirent` object describes a socket.
|
|
178
|
+
* @since v10.10.0
|
|
179
|
+
*/
|
|
73
180
|
isSocket(): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* The file name that this `fs.Dirent` object refers to. The type of this
|
|
183
|
+
* value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.
|
|
184
|
+
* @since v10.10.0
|
|
185
|
+
*/
|
|
74
186
|
name: string;
|
|
75
187
|
}
|
|
76
|
-
|
|
77
188
|
/**
|
|
78
189
|
* A class representing a directory stream.
|
|
190
|
+
*
|
|
191
|
+
* Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`.
|
|
192
|
+
*
|
|
193
|
+
* ```js
|
|
194
|
+
* import { opendir } from 'fs/promises';
|
|
195
|
+
*
|
|
196
|
+
* try {
|
|
197
|
+
* const dir = await opendir('./');
|
|
198
|
+
* for await (const dirent of dir)
|
|
199
|
+
* console.log(dirent.name);
|
|
200
|
+
* } catch (err) {
|
|
201
|
+
* console.error(err);
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* When using the async iterator, the `fs.Dir` object will be automatically
|
|
206
|
+
* closed after the iterator exits.
|
|
207
|
+
* @since v12.12.0
|
|
79
208
|
*/
|
|
80
209
|
export class Dir implements AsyncIterable<Dirent> {
|
|
210
|
+
/**
|
|
211
|
+
* The read-only path of this directory as was provided to {@link opendir},{@link opendirSync}, or `fsPromises.opendir()`.
|
|
212
|
+
* @since v12.12.0
|
|
213
|
+
*/
|
|
81
214
|
readonly path: string;
|
|
82
|
-
|
|
83
215
|
/**
|
|
84
216
|
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
|
|
85
217
|
*/
|
|
86
218
|
[Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
|
|
87
|
-
|
|
88
219
|
/**
|
|
89
220
|
* Asynchronously close the directory's underlying resource handle.
|
|
90
221
|
* Subsequent reads will result in errors.
|
|
222
|
+
*
|
|
223
|
+
* A promise is returned that will be resolved after the resource has been
|
|
224
|
+
* closed.
|
|
225
|
+
* @since v12.12.0
|
|
91
226
|
*/
|
|
92
227
|
close(): Promise<void>;
|
|
93
228
|
close(cb: NoParamCallback): void;
|
|
94
|
-
|
|
95
229
|
/**
|
|
96
230
|
* Synchronously close the directory's underlying resource handle.
|
|
97
231
|
* Subsequent reads will result in errors.
|
|
232
|
+
* @since v12.12.0
|
|
98
233
|
*/
|
|
99
234
|
closeSync(): void;
|
|
100
|
-
|
|
101
235
|
/**
|
|
102
|
-
* Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
|
|
103
|
-
*
|
|
104
|
-
*
|
|
236
|
+
* Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
|
|
237
|
+
*
|
|
238
|
+
* A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read.
|
|
239
|
+
*
|
|
240
|
+
* Directory entries returned by this function are in no particular order as
|
|
241
|
+
* provided by the operating system's underlying directory mechanisms.
|
|
242
|
+
* Entries added or removed while iterating over the directory might not be
|
|
243
|
+
* included in the iteration results.
|
|
244
|
+
* @since v12.12.0
|
|
245
|
+
* @return containing {fs.Dirent|null}
|
|
105
246
|
*/
|
|
106
247
|
read(): Promise<Dirent | null>;
|
|
107
248
|
read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
|
|
108
|
-
|
|
109
249
|
/**
|
|
110
|
-
* Synchronously read the next directory entry
|
|
111
|
-
*
|
|
112
|
-
*
|
|
250
|
+
* Synchronously read the next directory entry as an `fs.Dirent`. See the
|
|
251
|
+
* POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.
|
|
252
|
+
*
|
|
253
|
+
* If there are no more directory entries to read, `null` will be returned.
|
|
254
|
+
*
|
|
255
|
+
* Directory entries returned by this function are in no particular order as
|
|
256
|
+
* provided by the operating system's underlying directory mechanisms.
|
|
257
|
+
* Entries added or removed while iterating over the directory might not be
|
|
258
|
+
* included in the iteration results.
|
|
259
|
+
* @since v12.12.0
|
|
113
260
|
*/
|
|
114
261
|
readSync(): Dirent | null;
|
|
115
262
|
}
|
|
116
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Class: fs.StatWatcher
|
|
265
|
+
* @since v14.3.0, v12.20.0
|
|
266
|
+
* Extends `EventEmitter`
|
|
267
|
+
* A successful call to {@link watchFile} method will return a new fs.StatWatcher object.
|
|
268
|
+
*/
|
|
269
|
+
export interface StatWatcher extends EventEmitter {
|
|
270
|
+
/**
|
|
271
|
+
* @since v14.3.0, v12.20.0
|
|
272
|
+
* When called, requests that the Node.js event loop not exit so long as the `fs.StatWatcher` is active.
|
|
273
|
+
* Calling `watcher.ref()` multiple times will have no effect.
|
|
274
|
+
* By default, all `fs.StatWatcher`` objects are "ref'ed", making it normally unnecessary to call `watcher.ref()`
|
|
275
|
+
* unless `watcher.unref()` had been called previously.
|
|
276
|
+
*/
|
|
277
|
+
ref(): this;
|
|
278
|
+
/**
|
|
279
|
+
* @since v14.3.0, v12.20.0
|
|
280
|
+
* When called, the active `fs.StatWatcher`` object will not require the Node.js event loop to remain active.
|
|
281
|
+
* If there is no other activity keeping the event loop running, the process may exit before the `fs.StatWatcher`` object's callback is invoked.
|
|
282
|
+
* `Calling watcher.unref()` multiple times will have no effect.
|
|
283
|
+
*/
|
|
284
|
+
unref(): this;
|
|
285
|
+
}
|
|
117
286
|
export interface FSWatcher extends EventEmitter {
|
|
287
|
+
/**
|
|
288
|
+
* Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable.
|
|
289
|
+
* @since v0.5.8
|
|
290
|
+
*/
|
|
118
291
|
close(): void;
|
|
119
|
-
|
|
120
292
|
/**
|
|
121
293
|
* events.EventEmitter
|
|
122
294
|
* 1. change
|
|
123
295
|
* 2. error
|
|
124
296
|
*/
|
|
125
297
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
126
|
-
addListener(event:
|
|
127
|
-
addListener(event:
|
|
128
|
-
addListener(event:
|
|
129
|
-
|
|
298
|
+
addListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
|
|
299
|
+
addListener(event: 'error', listener: (error: Error) => void): this;
|
|
300
|
+
addListener(event: 'close', listener: () => void): this;
|
|
130
301
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
131
|
-
on(event:
|
|
132
|
-
on(event:
|
|
133
|
-
on(event:
|
|
134
|
-
|
|
302
|
+
on(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
|
|
303
|
+
on(event: 'error', listener: (error: Error) => void): this;
|
|
304
|
+
on(event: 'close', listener: () => void): this;
|
|
135
305
|
once(event: string, listener: (...args: any[]) => void): this;
|
|
136
|
-
once(event:
|
|
137
|
-
once(event:
|
|
138
|
-
once(event:
|
|
139
|
-
|
|
306
|
+
once(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
|
|
307
|
+
once(event: 'error', listener: (error: Error) => void): this;
|
|
308
|
+
once(event: 'close', listener: () => void): this;
|
|
140
309
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
141
|
-
prependListener(event:
|
|
142
|
-
prependListener(event:
|
|
143
|
-
prependListener(event:
|
|
144
|
-
|
|
310
|
+
prependListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
|
|
311
|
+
prependListener(event: 'error', listener: (error: Error) => void): this;
|
|
312
|
+
prependListener(event: 'close', listener: () => void): this;
|
|
145
313
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
146
|
-
prependOnceListener(event:
|
|
147
|
-
prependOnceListener(event:
|
|
148
|
-
prependOnceListener(event:
|
|
314
|
+
prependOnceListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
|
|
315
|
+
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
|
316
|
+
prependOnceListener(event: 'close', listener: () => void): this;
|
|
149
317
|
}
|
|
150
|
-
|
|
318
|
+
/**
|
|
319
|
+
* Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
|
|
320
|
+
* @since v0.1.93
|
|
321
|
+
*/
|
|
151
322
|
export class ReadStream extends stream.Readable {
|
|
152
|
-
close(): void;
|
|
323
|
+
close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
|
|
324
|
+
/**
|
|
325
|
+
* The number of bytes that have been read so far.
|
|
326
|
+
* @since v6.4.0
|
|
327
|
+
*/
|
|
153
328
|
bytesRead: number;
|
|
329
|
+
/**
|
|
330
|
+
* The path to the file the stream is reading from as specified in the first
|
|
331
|
+
* argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a
|
|
332
|
+
* `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.
|
|
333
|
+
* @since v0.1.93
|
|
334
|
+
*/
|
|
154
335
|
path: string | Buffer;
|
|
336
|
+
/**
|
|
337
|
+
* This property is `true` if the underlying file has not been opened yet,
|
|
338
|
+
* i.e. before the `'ready'` event is emitted.
|
|
339
|
+
* @since v11.2.0, v10.16.0
|
|
340
|
+
*/
|
|
155
341
|
pending: boolean;
|
|
156
|
-
|
|
157
342
|
/**
|
|
158
343
|
* events.EventEmitter
|
|
159
344
|
* 1. open
|
|
160
345
|
* 2. close
|
|
161
346
|
* 3. ready
|
|
162
347
|
*/
|
|
163
|
-
addListener(event:
|
|
164
|
-
addListener(event:
|
|
165
|
-
addListener(event:
|
|
166
|
-
addListener(event:
|
|
167
|
-
addListener(event:
|
|
168
|
-
addListener(event:
|
|
169
|
-
addListener(event:
|
|
170
|
-
addListener(event:
|
|
171
|
-
addListener(event:
|
|
348
|
+
addListener(event: 'close', listener: () => void): this;
|
|
349
|
+
addListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
|
|
350
|
+
addListener(event: 'end', listener: () => void): this;
|
|
351
|
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
|
352
|
+
addListener(event: 'open', listener: (fd: number) => void): this;
|
|
353
|
+
addListener(event: 'pause', listener: () => void): this;
|
|
354
|
+
addListener(event: 'readable', listener: () => void): this;
|
|
355
|
+
addListener(event: 'ready', listener: () => void): this;
|
|
356
|
+
addListener(event: 'resume', listener: () => void): this;
|
|
172
357
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
173
|
-
|
|
174
|
-
on(event:
|
|
175
|
-
on(event:
|
|
176
|
-
on(event:
|
|
177
|
-
on(event:
|
|
178
|
-
on(event:
|
|
179
|
-
on(event:
|
|
180
|
-
on(event:
|
|
181
|
-
on(event:
|
|
182
|
-
on(event: "resume", listener: () => void): this;
|
|
358
|
+
on(event: 'close', listener: () => void): this;
|
|
359
|
+
on(event: 'data', listener: (chunk: Buffer | string) => void): this;
|
|
360
|
+
on(event: 'end', listener: () => void): this;
|
|
361
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
362
|
+
on(event: 'open', listener: (fd: number) => void): this;
|
|
363
|
+
on(event: 'pause', listener: () => void): this;
|
|
364
|
+
on(event: 'readable', listener: () => void): this;
|
|
365
|
+
on(event: 'ready', listener: () => void): this;
|
|
366
|
+
on(event: 'resume', listener: () => void): this;
|
|
183
367
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
184
|
-
|
|
185
|
-
once(event:
|
|
186
|
-
once(event:
|
|
187
|
-
once(event:
|
|
188
|
-
once(event:
|
|
189
|
-
once(event:
|
|
190
|
-
once(event:
|
|
191
|
-
once(event:
|
|
192
|
-
once(event:
|
|
193
|
-
once(event: "resume", listener: () => void): this;
|
|
368
|
+
once(event: 'close', listener: () => void): this;
|
|
369
|
+
once(event: 'data', listener: (chunk: Buffer | string) => void): this;
|
|
370
|
+
once(event: 'end', listener: () => void): this;
|
|
371
|
+
once(event: 'error', listener: (err: Error) => void): this;
|
|
372
|
+
once(event: 'open', listener: (fd: number) => void): this;
|
|
373
|
+
once(event: 'pause', listener: () => void): this;
|
|
374
|
+
once(event: 'readable', listener: () => void): this;
|
|
375
|
+
once(event: 'ready', listener: () => void): this;
|
|
376
|
+
once(event: 'resume', listener: () => void): this;
|
|
194
377
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
195
|
-
|
|
196
|
-
prependListener(event:
|
|
197
|
-
prependListener(event:
|
|
198
|
-
prependListener(event:
|
|
199
|
-
prependListener(event:
|
|
200
|
-
prependListener(event:
|
|
201
|
-
prependListener(event:
|
|
202
|
-
prependListener(event:
|
|
203
|
-
prependListener(event:
|
|
204
|
-
prependListener(event: "resume", listener: () => void): this;
|
|
378
|
+
prependListener(event: 'close', listener: () => void): this;
|
|
379
|
+
prependListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
|
|
380
|
+
prependListener(event: 'end', listener: () => void): this;
|
|
381
|
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
|
382
|
+
prependListener(event: 'open', listener: (fd: number) => void): this;
|
|
383
|
+
prependListener(event: 'pause', listener: () => void): this;
|
|
384
|
+
prependListener(event: 'readable', listener: () => void): this;
|
|
385
|
+
prependListener(event: 'ready', listener: () => void): this;
|
|
386
|
+
prependListener(event: 'resume', listener: () => void): this;
|
|
205
387
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
206
|
-
|
|
207
|
-
prependOnceListener(event:
|
|
208
|
-
prependOnceListener(event:
|
|
209
|
-
prependOnceListener(event:
|
|
210
|
-
prependOnceListener(event:
|
|
211
|
-
prependOnceListener(event:
|
|
212
|
-
prependOnceListener(event:
|
|
213
|
-
prependOnceListener(event:
|
|
214
|
-
prependOnceListener(event:
|
|
215
|
-
prependOnceListener(event: "resume", listener: () => void): this;
|
|
388
|
+
prependOnceListener(event: 'close', listener: () => void): this;
|
|
389
|
+
prependOnceListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
|
|
390
|
+
prependOnceListener(event: 'end', listener: () => void): this;
|
|
391
|
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
|
392
|
+
prependOnceListener(event: 'open', listener: (fd: number) => void): this;
|
|
393
|
+
prependOnceListener(event: 'pause', listener: () => void): this;
|
|
394
|
+
prependOnceListener(event: 'readable', listener: () => void): this;
|
|
395
|
+
prependOnceListener(event: 'ready', listener: () => void): this;
|
|
396
|
+
prependOnceListener(event: 'resume', listener: () => void): this;
|
|
216
397
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
217
398
|
}
|
|
218
|
-
|
|
399
|
+
/**
|
|
400
|
+
* * Extends `stream.Writable`
|
|
401
|
+
*
|
|
402
|
+
* Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function.
|
|
403
|
+
* @since v0.1.93
|
|
404
|
+
*/
|
|
219
405
|
export class WriteStream extends stream.Writable {
|
|
220
|
-
|
|
406
|
+
/**
|
|
407
|
+
* Closes `writeStream`. Optionally accepts a
|
|
408
|
+
* callback that will be executed once the `writeStream`is closed.
|
|
409
|
+
* @since v0.9.4
|
|
410
|
+
*/
|
|
411
|
+
close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
|
|
412
|
+
/**
|
|
413
|
+
* The number of bytes written so far. Does not include data that is still queued
|
|
414
|
+
* for writing.
|
|
415
|
+
* @since v0.4.7
|
|
416
|
+
*/
|
|
221
417
|
bytesWritten: number;
|
|
418
|
+
/**
|
|
419
|
+
* The path to the file the stream is writing to as specified in the first
|
|
420
|
+
* argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a
|
|
421
|
+
* `Buffer`.
|
|
422
|
+
* @since v0.1.93
|
|
423
|
+
*/
|
|
222
424
|
path: string | Buffer;
|
|
425
|
+
/**
|
|
426
|
+
* This property is `true` if the underlying file has not been opened yet,
|
|
427
|
+
* i.e. before the `'ready'` event is emitted.
|
|
428
|
+
* @since v11.2.0
|
|
429
|
+
*/
|
|
223
430
|
pending: boolean;
|
|
224
|
-
|
|
225
431
|
/**
|
|
226
432
|
* events.EventEmitter
|
|
227
433
|
* 1. open
|
|
228
434
|
* 2. close
|
|
229
435
|
* 3. ready
|
|
230
436
|
*/
|
|
231
|
-
addListener(event:
|
|
232
|
-
addListener(event:
|
|
233
|
-
addListener(event:
|
|
234
|
-
addListener(event:
|
|
235
|
-
addListener(event:
|
|
236
|
-
addListener(event:
|
|
237
|
-
addListener(event:
|
|
238
|
-
addListener(event:
|
|
437
|
+
addListener(event: 'close', listener: () => void): this;
|
|
438
|
+
addListener(event: 'drain', listener: () => void): this;
|
|
439
|
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
|
440
|
+
addListener(event: 'finish', listener: () => void): this;
|
|
441
|
+
addListener(event: 'open', listener: (fd: number) => void): this;
|
|
442
|
+
addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
|
443
|
+
addListener(event: 'ready', listener: () => void): this;
|
|
444
|
+
addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
|
239
445
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
240
|
-
|
|
241
|
-
on(event:
|
|
242
|
-
on(event:
|
|
243
|
-
on(event:
|
|
244
|
-
on(event:
|
|
245
|
-
on(event:
|
|
246
|
-
on(event:
|
|
247
|
-
on(event:
|
|
248
|
-
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
|
446
|
+
on(event: 'close', listener: () => void): this;
|
|
447
|
+
on(event: 'drain', listener: () => void): this;
|
|
448
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
449
|
+
on(event: 'finish', listener: () => void): this;
|
|
450
|
+
on(event: 'open', listener: (fd: number) => void): this;
|
|
451
|
+
on(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
|
452
|
+
on(event: 'ready', listener: () => void): this;
|
|
453
|
+
on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
|
249
454
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
250
|
-
|
|
251
|
-
once(event:
|
|
252
|
-
once(event:
|
|
253
|
-
once(event:
|
|
254
|
-
once(event:
|
|
255
|
-
once(event:
|
|
256
|
-
once(event:
|
|
257
|
-
once(event:
|
|
258
|
-
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
|
455
|
+
once(event: 'close', listener: () => void): this;
|
|
456
|
+
once(event: 'drain', listener: () => void): this;
|
|
457
|
+
once(event: 'error', listener: (err: Error) => void): this;
|
|
458
|
+
once(event: 'finish', listener: () => void): this;
|
|
459
|
+
once(event: 'open', listener: (fd: number) => void): this;
|
|
460
|
+
once(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
|
461
|
+
once(event: 'ready', listener: () => void): this;
|
|
462
|
+
once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
|
259
463
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
260
|
-
|
|
261
|
-
prependListener(event:
|
|
262
|
-
prependListener(event:
|
|
263
|
-
prependListener(event:
|
|
264
|
-
prependListener(event:
|
|
265
|
-
prependListener(event:
|
|
266
|
-
prependListener(event:
|
|
267
|
-
prependListener(event:
|
|
268
|
-
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
|
464
|
+
prependListener(event: 'close', listener: () => void): this;
|
|
465
|
+
prependListener(event: 'drain', listener: () => void): this;
|
|
466
|
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
|
467
|
+
prependListener(event: 'finish', listener: () => void): this;
|
|
468
|
+
prependListener(event: 'open', listener: (fd: number) => void): this;
|
|
469
|
+
prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
|
470
|
+
prependListener(event: 'ready', listener: () => void): this;
|
|
471
|
+
prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
|
269
472
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
270
|
-
|
|
271
|
-
prependOnceListener(event:
|
|
272
|
-
prependOnceListener(event:
|
|
273
|
-
prependOnceListener(event:
|
|
274
|
-
prependOnceListener(event:
|
|
275
|
-
prependOnceListener(event:
|
|
276
|
-
prependOnceListener(event:
|
|
277
|
-
prependOnceListener(event:
|
|
278
|
-
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
|
473
|
+
prependOnceListener(event: 'close', listener: () => void): this;
|
|
474
|
+
prependOnceListener(event: 'drain', listener: () => void): this;
|
|
475
|
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
|
476
|
+
prependOnceListener(event: 'finish', listener: () => void): this;
|
|
477
|
+
prependOnceListener(event: 'open', listener: (fd: number) => void): this;
|
|
478
|
+
prependOnceListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
|
479
|
+
prependOnceListener(event: 'ready', listener: () => void): this;
|
|
480
|
+
prependOnceListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
|
279
481
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
280
482
|
}
|
|
281
|
-
|
|
282
483
|
/**
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
484
|
+
* Asynchronously rename file at `oldPath` to the pathname provided
|
|
485
|
+
* as `newPath`. In the case that `newPath` already exists, it will
|
|
486
|
+
* be overwritten. If there is a directory at `newPath`, an error will
|
|
487
|
+
* be raised instead. No arguments other than a possible exception are
|
|
488
|
+
* given to the completion callback.
|
|
489
|
+
*
|
|
490
|
+
* See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).
|
|
491
|
+
*
|
|
492
|
+
* ```js
|
|
493
|
+
* import { rename } from 'fs';
|
|
494
|
+
*
|
|
495
|
+
* rename('oldFile.txt', 'newFile.txt', (err) => {
|
|
496
|
+
* if (err) throw err;
|
|
497
|
+
* console.log('Rename complete!');
|
|
498
|
+
* });
|
|
499
|
+
* ```
|
|
500
|
+
* @since v0.0.2
|
|
286
501
|
*/
|
|
287
502
|
export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
|
|
288
|
-
|
|
289
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
290
503
|
export namespace rename {
|
|
291
504
|
/**
|
|
292
505
|
* Asynchronous rename(2) - Change the name or location of a file or directory.
|
|
@@ -297,28 +510,40 @@ declare module 'fs' {
|
|
|
297
510
|
*/
|
|
298
511
|
function __promisify__(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
|
299
512
|
}
|
|
300
|
-
|
|
301
513
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
514
|
+
* Renames the file from `oldPath` to `newPath`. Returns `undefined`.
|
|
515
|
+
*
|
|
516
|
+
* See the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details.
|
|
517
|
+
* @since v0.1.21
|
|
305
518
|
*/
|
|
306
519
|
export function renameSync(oldPath: PathLike, newPath: PathLike): void;
|
|
307
|
-
|
|
308
520
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
521
|
+
* Truncates the file. No arguments other than a possible exception are
|
|
522
|
+
* given to the completion callback. A file descriptor can also be passed as the
|
|
523
|
+
* first argument. In this case, `fs.ftruncate()` is called.
|
|
524
|
+
*
|
|
525
|
+
* ```js
|
|
526
|
+
* import { truncate } from 'fs';
|
|
527
|
+
* // Assuming that 'path/file.txt' is a regular file.
|
|
528
|
+
* truncate('path/file.txt', (err) => {
|
|
529
|
+
* if (err) throw err;
|
|
530
|
+
* console.log('path/file.txt was truncated');
|
|
531
|
+
* });
|
|
532
|
+
* ```
|
|
533
|
+
*
|
|
534
|
+
* Passing a file descriptor is deprecated and may result in an error being thrown
|
|
535
|
+
* in the future.
|
|
536
|
+
*
|
|
537
|
+
* See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details.
|
|
538
|
+
* @since v0.8.6
|
|
539
|
+
* @param [len=0]
|
|
312
540
|
*/
|
|
313
541
|
export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
|
|
314
|
-
|
|
315
542
|
/**
|
|
316
543
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
|
317
544
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
318
545
|
*/
|
|
319
546
|
export function truncate(path: PathLike, callback: NoParamCallback): void;
|
|
320
|
-
|
|
321
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
322
547
|
export namespace truncate {
|
|
323
548
|
/**
|
|
324
549
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
|
@@ -327,28 +552,65 @@ declare module 'fs' {
|
|
|
327
552
|
*/
|
|
328
553
|
function __promisify__(path: PathLike, len?: number | null): Promise<void>;
|
|
329
554
|
}
|
|
330
|
-
|
|
331
555
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
556
|
+
* Truncates the file. Returns `undefined`. A file descriptor can also be
|
|
557
|
+
* passed as the first argument. In this case, `fs.ftruncateSync()` is called.
|
|
558
|
+
*
|
|
559
|
+
* Passing a file descriptor is deprecated and may result in an error being thrown
|
|
560
|
+
* in the future.
|
|
561
|
+
* @since v0.8.6
|
|
562
|
+
* @param [len=0]
|
|
335
563
|
*/
|
|
336
564
|
export function truncateSync(path: PathLike, len?: number | null): void;
|
|
337
|
-
|
|
338
565
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
566
|
+
* Truncates the file descriptor. No arguments other than a possible exception are
|
|
567
|
+
* given to the completion callback.
|
|
568
|
+
*
|
|
569
|
+
* See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail.
|
|
570
|
+
*
|
|
571
|
+
* If the file referred to by the file descriptor was larger than `len` bytes, only
|
|
572
|
+
* the first `len` bytes will be retained in the file.
|
|
573
|
+
*
|
|
574
|
+
* For example, the following program retains only the first four bytes of the
|
|
575
|
+
* file:
|
|
576
|
+
*
|
|
577
|
+
* ```js
|
|
578
|
+
* import { open, close, ftruncate } from 'fs';
|
|
579
|
+
*
|
|
580
|
+
* function closeFd(fd) {
|
|
581
|
+
* close(fd, (err) => {
|
|
582
|
+
* if (err) throw err;
|
|
583
|
+
* });
|
|
584
|
+
* }
|
|
585
|
+
*
|
|
586
|
+
* open('temp.txt', 'r+', (err, fd) => {
|
|
587
|
+
* if (err) throw err;
|
|
588
|
+
*
|
|
589
|
+
* try {
|
|
590
|
+
* ftruncate(fd, 4, (err) => {
|
|
591
|
+
* closeFd(fd);
|
|
592
|
+
* if (err) throw err;
|
|
593
|
+
* });
|
|
594
|
+
* } catch (err) {
|
|
595
|
+
* closeFd(fd);
|
|
596
|
+
* if (err) throw err;
|
|
597
|
+
* }
|
|
598
|
+
* });
|
|
599
|
+
* ```
|
|
600
|
+
*
|
|
601
|
+
* If the file previously was shorter than `len` bytes, it is extended, and the
|
|
602
|
+
* extended part is filled with null bytes (`'\0'`):
|
|
603
|
+
*
|
|
604
|
+
* If `len` is negative then `0` will be used.
|
|
605
|
+
* @since v0.8.6
|
|
606
|
+
* @param [len=0]
|
|
342
607
|
*/
|
|
343
608
|
export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
|
|
344
|
-
|
|
345
609
|
/**
|
|
346
610
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
|
347
611
|
* @param fd A file descriptor.
|
|
348
612
|
*/
|
|
349
613
|
export function ftruncate(fd: number, callback: NoParamCallback): void;
|
|
350
|
-
|
|
351
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
352
614
|
export namespace ftruncate {
|
|
353
615
|
/**
|
|
354
616
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
|
@@ -357,21 +619,23 @@ declare module 'fs' {
|
|
|
357
619
|
*/
|
|
358
620
|
function __promisify__(fd: number, len?: number | null): Promise<void>;
|
|
359
621
|
}
|
|
360
|
-
|
|
361
622
|
/**
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
623
|
+
* Truncates the file descriptor. Returns `undefined`.
|
|
624
|
+
*
|
|
625
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
626
|
+
* this API: {@link ftruncate}.
|
|
627
|
+
* @since v0.8.6
|
|
628
|
+
* @param [len=0]
|
|
365
629
|
*/
|
|
366
630
|
export function ftruncateSync(fd: number, len?: number | null): void;
|
|
367
|
-
|
|
368
631
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
632
|
+
* Asynchronously changes owner and group of a file. No arguments other than a
|
|
633
|
+
* possible exception are given to the completion callback.
|
|
634
|
+
*
|
|
635
|
+
* See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
|
|
636
|
+
* @since v0.1.97
|
|
371
637
|
*/
|
|
372
638
|
export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
|
|
373
|
-
|
|
374
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
375
639
|
export namespace chown {
|
|
376
640
|
/**
|
|
377
641
|
* Asynchronous chown(2) - Change ownership of a file.
|
|
@@ -379,20 +643,22 @@ declare module 'fs' {
|
|
|
379
643
|
*/
|
|
380
644
|
function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
|
|
381
645
|
}
|
|
382
|
-
|
|
383
646
|
/**
|
|
384
|
-
*
|
|
385
|
-
*
|
|
647
|
+
* Synchronously changes owner and group of a file. Returns `undefined`.
|
|
648
|
+
* This is the synchronous version of {@link chown}.
|
|
649
|
+
*
|
|
650
|
+
* See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
|
|
651
|
+
* @since v0.1.97
|
|
386
652
|
*/
|
|
387
653
|
export function chownSync(path: PathLike, uid: number, gid: number): void;
|
|
388
|
-
|
|
389
654
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
655
|
+
* Sets the owner of the file. No arguments other than a possible exception are
|
|
656
|
+
* given to the completion callback.
|
|
657
|
+
*
|
|
658
|
+
* See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
|
|
659
|
+
* @since v0.4.7
|
|
392
660
|
*/
|
|
393
661
|
export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
|
|
394
|
-
|
|
395
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
396
662
|
export namespace fchown {
|
|
397
663
|
/**
|
|
398
664
|
* Asynchronous fchown(2) - Change ownership of a file.
|
|
@@ -400,20 +666,22 @@ declare module 'fs' {
|
|
|
400
666
|
*/
|
|
401
667
|
function __promisify__(fd: number, uid: number, gid: number): Promise<void>;
|
|
402
668
|
}
|
|
403
|
-
|
|
404
669
|
/**
|
|
405
|
-
*
|
|
406
|
-
*
|
|
670
|
+
* Sets the owner of the file. Returns `undefined`.
|
|
671
|
+
*
|
|
672
|
+
* See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
|
|
673
|
+
* @since v0.4.7
|
|
674
|
+
* @param uid The file's new owner's user id.
|
|
675
|
+
* @param gid The file's new group's group id.
|
|
407
676
|
*/
|
|
408
677
|
export function fchownSync(fd: number, uid: number, gid: number): void;
|
|
409
|
-
|
|
410
678
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
679
|
+
* Set the owner of the symbolic link. No arguments other than a possible
|
|
680
|
+
* exception are given to the completion callback.
|
|
681
|
+
*
|
|
682
|
+
* See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail.
|
|
413
683
|
*/
|
|
414
684
|
export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
|
|
415
|
-
|
|
416
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
417
685
|
export namespace lchown {
|
|
418
686
|
/**
|
|
419
687
|
* Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
|
|
@@ -421,24 +689,24 @@ declare module 'fs' {
|
|
|
421
689
|
*/
|
|
422
690
|
function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
|
|
423
691
|
}
|
|
424
|
-
|
|
425
692
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
693
|
+
* Set the owner for the path. Returns `undefined`.
|
|
694
|
+
*
|
|
695
|
+
* See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details.
|
|
696
|
+
* @param uid The file's new owner's user id.
|
|
697
|
+
* @param gid The file's new group's group id.
|
|
428
698
|
*/
|
|
429
699
|
export function lchownSync(path: PathLike, uid: number, gid: number): void;
|
|
430
|
-
|
|
431
700
|
/**
|
|
432
|
-
* Changes the access and modification times of a file in the same way as
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
701
|
+
* Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic
|
|
702
|
+
* link, then the link is not dereferenced: instead, the timestamps of the
|
|
703
|
+
* symbolic link itself are changed.
|
|
704
|
+
*
|
|
705
|
+
* No arguments other than a possible exception are given to the completion
|
|
706
|
+
* callback.
|
|
707
|
+
* @since v14.5.0, v12.19.0
|
|
438
708
|
*/
|
|
439
709
|
export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
|
440
|
-
|
|
441
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
442
710
|
export namespace lutimes {
|
|
443
711
|
/**
|
|
444
712
|
* Changes the access and modification times of a file in the same way as `fsPromises.utimes()`,
|
|
@@ -450,25 +718,30 @@ declare module 'fs' {
|
|
|
450
718
|
*/
|
|
451
719
|
function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
|
452
720
|
}
|
|
453
|
-
|
|
454
721
|
/**
|
|
455
|
-
* Change the file system timestamps of the symbolic link referenced by `path`.
|
|
456
|
-
* or throws an exception when parameters are incorrect or
|
|
457
|
-
* This is the synchronous version of
|
|
458
|
-
* @
|
|
459
|
-
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
460
|
-
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
722
|
+
* Change the file system timestamps of the symbolic link referenced by `path`.
|
|
723
|
+
* Returns `undefined`, or throws an exception when parameters are incorrect or
|
|
724
|
+
* the operation fails. This is the synchronous version of {@link lutimes}.
|
|
725
|
+
* @since v14.5.0, v12.19.0
|
|
461
726
|
*/
|
|
462
727
|
export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
|
|
463
|
-
|
|
464
728
|
/**
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
729
|
+
* Asynchronously changes the permissions of a file. No arguments other than a
|
|
730
|
+
* possible exception are given to the completion callback.
|
|
731
|
+
*
|
|
732
|
+
* See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
|
|
733
|
+
*
|
|
734
|
+
* ```js
|
|
735
|
+
* import { chmod } from 'fs';
|
|
736
|
+
*
|
|
737
|
+
* chmod('my_file.txt', 0o775, (err) => {
|
|
738
|
+
* if (err) throw err;
|
|
739
|
+
* console.log('The permissions for file "my_file.txt" have been changed!');
|
|
740
|
+
* });
|
|
741
|
+
* ```
|
|
742
|
+
* @since v0.1.30
|
|
468
743
|
*/
|
|
469
744
|
export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
|
|
470
|
-
|
|
471
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
472
745
|
export namespace chmod {
|
|
473
746
|
/**
|
|
474
747
|
* Asynchronous chmod(2) - Change permissions of a file.
|
|
@@ -477,22 +750,22 @@ declare module 'fs' {
|
|
|
477
750
|
*/
|
|
478
751
|
function __promisify__(path: PathLike, mode: Mode): Promise<void>;
|
|
479
752
|
}
|
|
480
|
-
|
|
481
753
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
754
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
755
|
+
* this API: {@link chmod}.
|
|
756
|
+
*
|
|
757
|
+
* See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
|
|
758
|
+
* @since v0.6.7
|
|
485
759
|
*/
|
|
486
760
|
export function chmodSync(path: PathLike, mode: Mode): void;
|
|
487
|
-
|
|
488
761
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
762
|
+
* Sets the permissions on the file. No arguments other than a possible exception
|
|
763
|
+
* are given to the completion callback.
|
|
764
|
+
*
|
|
765
|
+
* See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
|
|
766
|
+
* @since v0.4.7
|
|
492
767
|
*/
|
|
493
768
|
export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
|
|
494
|
-
|
|
495
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
496
769
|
export namespace fchmod {
|
|
497
770
|
/**
|
|
498
771
|
* Asynchronous fchmod(2) - Change permissions of a file.
|
|
@@ -501,22 +774,24 @@ declare module 'fs' {
|
|
|
501
774
|
*/
|
|
502
775
|
function __promisify__(fd: number, mode: Mode): Promise<void>;
|
|
503
776
|
}
|
|
504
|
-
|
|
505
777
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
778
|
+
* Sets the permissions on the file. Returns `undefined`.
|
|
779
|
+
*
|
|
780
|
+
* See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
|
|
781
|
+
* @since v0.4.7
|
|
509
782
|
*/
|
|
510
783
|
export function fchmodSync(fd: number, mode: Mode): void;
|
|
511
|
-
|
|
512
784
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
785
|
+
* Changes the permissions on a symbolic link. No arguments other than a possible
|
|
786
|
+
* exception are given to the completion callback.
|
|
787
|
+
*
|
|
788
|
+
* This method is only implemented on macOS.
|
|
789
|
+
*
|
|
790
|
+
* See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
|
|
791
|
+
* @deprecated Since v0.4.7
|
|
516
792
|
*/
|
|
517
793
|
export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
|
|
518
|
-
|
|
519
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
794
|
+
/** @deprecated */
|
|
520
795
|
export namespace lchmod {
|
|
521
796
|
/**
|
|
522
797
|
* Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
|
|
@@ -525,109 +800,294 @@ declare module 'fs' {
|
|
|
525
800
|
*/
|
|
526
801
|
function __promisify__(path: PathLike, mode: Mode): Promise<void>;
|
|
527
802
|
}
|
|
528
|
-
|
|
529
803
|
/**
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
804
|
+
* Changes the permissions on a symbolic link. Returns `undefined`.
|
|
805
|
+
*
|
|
806
|
+
* This method is only implemented on macOS.
|
|
807
|
+
*
|
|
808
|
+
* See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
|
|
809
|
+
* @deprecated Since v0.4.7
|
|
533
810
|
*/
|
|
534
811
|
export function lchmodSync(path: PathLike, mode: Mode): void;
|
|
535
|
-
|
|
536
812
|
/**
|
|
537
|
-
* Asynchronous stat(2)
|
|
538
|
-
*
|
|
813
|
+
* Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object.
|
|
814
|
+
*
|
|
815
|
+
* In case of an error, the `err.code` will be one of `Common System Errors`.
|
|
816
|
+
*
|
|
817
|
+
* Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended.
|
|
818
|
+
* Instead, user code should open/read/write the file directly and handle the
|
|
819
|
+
* error raised if the file is not available.
|
|
820
|
+
*
|
|
821
|
+
* To check if a file exists without manipulating it afterwards, {@link access} is recommended.
|
|
822
|
+
*
|
|
823
|
+
* For example, given the following directory structure:
|
|
824
|
+
*
|
|
825
|
+
* ```text
|
|
826
|
+
* - txtDir
|
|
827
|
+
* -- file.txt
|
|
828
|
+
* - app.js
|
|
829
|
+
* ```
|
|
830
|
+
*
|
|
831
|
+
* The next program will check for the stats of the given paths:
|
|
832
|
+
*
|
|
833
|
+
* ```js
|
|
834
|
+
* import { stat } from 'fs';
|
|
835
|
+
*
|
|
836
|
+
* const pathsToCheck = ['./txtDir', './txtDir/file.txt'];
|
|
837
|
+
*
|
|
838
|
+
* for (let i = 0; i < pathsToCheck.length; i++) {
|
|
839
|
+
* stat(pathsToCheck[i], (err, stats) => {
|
|
840
|
+
* console.log(stats.isDirectory());
|
|
841
|
+
* console.log(stats);
|
|
842
|
+
* });
|
|
843
|
+
* }
|
|
844
|
+
* ```
|
|
845
|
+
*
|
|
846
|
+
* The resulting output will resemble:
|
|
847
|
+
*
|
|
848
|
+
* ```console
|
|
849
|
+
* true
|
|
850
|
+
* Stats {
|
|
851
|
+
* dev: 16777220,
|
|
852
|
+
* mode: 16877,
|
|
853
|
+
* nlink: 3,
|
|
854
|
+
* uid: 501,
|
|
855
|
+
* gid: 20,
|
|
856
|
+
* rdev: 0,
|
|
857
|
+
* blksize: 4096,
|
|
858
|
+
* ino: 14214262,
|
|
859
|
+
* size: 96,
|
|
860
|
+
* blocks: 0,
|
|
861
|
+
* atimeMs: 1561174653071.963,
|
|
862
|
+
* mtimeMs: 1561174614583.3518,
|
|
863
|
+
* ctimeMs: 1561174626623.5366,
|
|
864
|
+
* birthtimeMs: 1561174126937.2893,
|
|
865
|
+
* atime: 2019-06-22T03:37:33.072Z,
|
|
866
|
+
* mtime: 2019-06-22T03:36:54.583Z,
|
|
867
|
+
* ctime: 2019-06-22T03:37:06.624Z,
|
|
868
|
+
* birthtime: 2019-06-22T03:28:46.937Z
|
|
869
|
+
* }
|
|
870
|
+
* false
|
|
871
|
+
* Stats {
|
|
872
|
+
* dev: 16777220,
|
|
873
|
+
* mode: 33188,
|
|
874
|
+
* nlink: 1,
|
|
875
|
+
* uid: 501,
|
|
876
|
+
* gid: 20,
|
|
877
|
+
* rdev: 0,
|
|
878
|
+
* blksize: 4096,
|
|
879
|
+
* ino: 14214074,
|
|
880
|
+
* size: 8,
|
|
881
|
+
* blocks: 8,
|
|
882
|
+
* atimeMs: 1561174616618.8555,
|
|
883
|
+
* mtimeMs: 1561174614584,
|
|
884
|
+
* ctimeMs: 1561174614583.8145,
|
|
885
|
+
* birthtimeMs: 1561174007710.7478,
|
|
886
|
+
* atime: 2019-06-22T03:36:56.619Z,
|
|
887
|
+
* mtime: 2019-06-22T03:36:54.584Z,
|
|
888
|
+
* ctime: 2019-06-22T03:36:54.584Z,
|
|
889
|
+
* birthtime: 2019-06-22T03:26:47.711Z
|
|
890
|
+
* }
|
|
891
|
+
* ```
|
|
892
|
+
* @since v0.0.2
|
|
539
893
|
*/
|
|
540
894
|
export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
541
|
-
export function stat(
|
|
542
|
-
|
|
895
|
+
export function stat(
|
|
896
|
+
path: PathLike,
|
|
897
|
+
options:
|
|
898
|
+
| (StatOptions & {
|
|
899
|
+
bigint?: false | undefined;
|
|
900
|
+
})
|
|
901
|
+
| undefined,
|
|
902
|
+
callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void
|
|
903
|
+
): void;
|
|
904
|
+
export function stat(
|
|
905
|
+
path: PathLike,
|
|
906
|
+
options: StatOptions & {
|
|
907
|
+
bigint: true;
|
|
908
|
+
},
|
|
909
|
+
callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void
|
|
910
|
+
): void;
|
|
543
911
|
export function stat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
|
|
544
|
-
|
|
545
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
546
912
|
export namespace stat {
|
|
547
913
|
/**
|
|
548
914
|
* Asynchronous stat(2) - Get file status.
|
|
549
915
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
550
916
|
*/
|
|
551
|
-
function __promisify__(
|
|
552
|
-
|
|
917
|
+
function __promisify__(
|
|
918
|
+
path: PathLike,
|
|
919
|
+
options?: StatOptions & {
|
|
920
|
+
bigint?: false | undefined;
|
|
921
|
+
}
|
|
922
|
+
): Promise<Stats>;
|
|
923
|
+
function __promisify__(
|
|
924
|
+
path: PathLike,
|
|
925
|
+
options: StatOptions & {
|
|
926
|
+
bigint: true;
|
|
927
|
+
}
|
|
928
|
+
): Promise<BigIntStats>;
|
|
553
929
|
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
554
930
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
931
|
+
export interface StatSyncFn extends Function {
|
|
932
|
+
(path: PathLike, options?: undefined): Stats;
|
|
933
|
+
(
|
|
934
|
+
path: PathLike,
|
|
935
|
+
options?: StatSyncOptions & {
|
|
936
|
+
bigint?: false | undefined;
|
|
937
|
+
throwIfNoEntry: false;
|
|
938
|
+
}
|
|
939
|
+
): Stats | undefined;
|
|
940
|
+
(
|
|
941
|
+
path: PathLike,
|
|
942
|
+
options: StatSyncOptions & {
|
|
943
|
+
bigint: true;
|
|
944
|
+
throwIfNoEntry: false;
|
|
945
|
+
}
|
|
946
|
+
): BigIntStats | undefined;
|
|
947
|
+
(
|
|
948
|
+
path: PathLike,
|
|
949
|
+
options?: StatSyncOptions & {
|
|
950
|
+
bigint?: false | undefined;
|
|
951
|
+
}
|
|
952
|
+
): Stats;
|
|
953
|
+
(
|
|
954
|
+
path: PathLike,
|
|
955
|
+
options: StatSyncOptions & {
|
|
956
|
+
bigint: true;
|
|
957
|
+
}
|
|
958
|
+
): BigIntStats;
|
|
959
|
+
(
|
|
960
|
+
path: PathLike,
|
|
961
|
+
options: StatSyncOptions & {
|
|
962
|
+
bigint: boolean;
|
|
963
|
+
throwIfNoEntry?: false | undefined;
|
|
964
|
+
}
|
|
965
|
+
): Stats | BigIntStats;
|
|
966
|
+
(path: PathLike, options?: StatSyncOptions): Stats | BigIntStats | undefined;
|
|
564
967
|
}
|
|
565
|
-
|
|
566
968
|
/**
|
|
567
969
|
* Synchronous stat(2) - Get file status.
|
|
568
970
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
569
971
|
*/
|
|
570
972
|
export const statSync: StatSyncFn;
|
|
571
|
-
|
|
572
973
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
974
|
+
* Invokes the callback with the `fs.Stats` for the file descriptor.
|
|
975
|
+
*
|
|
976
|
+
* See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
|
|
977
|
+
* @since v0.1.95
|
|
575
978
|
*/
|
|
576
979
|
export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
577
|
-
export function fstat(
|
|
578
|
-
|
|
980
|
+
export function fstat(
|
|
981
|
+
fd: number,
|
|
982
|
+
options:
|
|
983
|
+
| (StatOptions & {
|
|
984
|
+
bigint?: false | undefined;
|
|
985
|
+
})
|
|
986
|
+
| undefined,
|
|
987
|
+
callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void
|
|
988
|
+
): void;
|
|
989
|
+
export function fstat(
|
|
990
|
+
fd: number,
|
|
991
|
+
options: StatOptions & {
|
|
992
|
+
bigint: true;
|
|
993
|
+
},
|
|
994
|
+
callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void
|
|
995
|
+
): void;
|
|
579
996
|
export function fstat(fd: number, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
|
|
580
|
-
|
|
581
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
582
997
|
export namespace fstat {
|
|
583
998
|
/**
|
|
584
999
|
* Asynchronous fstat(2) - Get file status.
|
|
585
1000
|
* @param fd A file descriptor.
|
|
586
1001
|
*/
|
|
587
|
-
function __promisify__(
|
|
588
|
-
|
|
1002
|
+
function __promisify__(
|
|
1003
|
+
fd: number,
|
|
1004
|
+
options?: StatOptions & {
|
|
1005
|
+
bigint?: false | undefined;
|
|
1006
|
+
}
|
|
1007
|
+
): Promise<Stats>;
|
|
1008
|
+
function __promisify__(
|
|
1009
|
+
fd: number,
|
|
1010
|
+
options: StatOptions & {
|
|
1011
|
+
bigint: true;
|
|
1012
|
+
}
|
|
1013
|
+
): Promise<BigIntStats>;
|
|
589
1014
|
function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
590
1015
|
}
|
|
591
|
-
|
|
592
1016
|
/**
|
|
593
1017
|
* Synchronous fstat(2) - Get file status.
|
|
594
1018
|
* @param fd A file descriptor.
|
|
595
1019
|
*/
|
|
596
|
-
export
|
|
1020
|
+
export function fstatSync(
|
|
1021
|
+
fd: number,
|
|
1022
|
+
options?: StatOptions & {
|
|
1023
|
+
bigint?: false | undefined;
|
|
1024
|
+
}
|
|
1025
|
+
): Stats;
|
|
1026
|
+
export function fstatSync(
|
|
1027
|
+
fd: number,
|
|
1028
|
+
options: StatOptions & {
|
|
1029
|
+
bigint: true;
|
|
1030
|
+
}
|
|
1031
|
+
): BigIntStats;
|
|
1032
|
+
export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
|
|
597
1033
|
|
|
598
1034
|
/**
|
|
599
|
-
*
|
|
600
|
-
*
|
|
1035
|
+
* Retrieves the `fs.Stats` for the symbolic link referred to by the path.
|
|
1036
|
+
* The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
|
|
1037
|
+
* link, then the link itself is stat-ed, not the file that it refers to.
|
|
1038
|
+
*
|
|
1039
|
+
* See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.
|
|
1040
|
+
* @since v0.1.30
|
|
601
1041
|
*/
|
|
602
1042
|
export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
603
|
-
export function lstat(
|
|
604
|
-
|
|
1043
|
+
export function lstat(
|
|
1044
|
+
path: PathLike,
|
|
1045
|
+
options:
|
|
1046
|
+
| (StatOptions & {
|
|
1047
|
+
bigint?: false | undefined;
|
|
1048
|
+
})
|
|
1049
|
+
| undefined,
|
|
1050
|
+
callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void
|
|
1051
|
+
): void;
|
|
1052
|
+
export function lstat(
|
|
1053
|
+
path: PathLike,
|
|
1054
|
+
options: StatOptions & {
|
|
1055
|
+
bigint: true;
|
|
1056
|
+
},
|
|
1057
|
+
callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void
|
|
1058
|
+
): void;
|
|
605
1059
|
export function lstat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
|
|
606
|
-
|
|
607
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
608
1060
|
export namespace lstat {
|
|
609
1061
|
/**
|
|
610
1062
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
611
1063
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
612
1064
|
*/
|
|
613
|
-
function __promisify__(
|
|
614
|
-
|
|
1065
|
+
function __promisify__(
|
|
1066
|
+
path: PathLike,
|
|
1067
|
+
options?: StatOptions & {
|
|
1068
|
+
bigint?: false | undefined;
|
|
1069
|
+
}
|
|
1070
|
+
): Promise<Stats>;
|
|
1071
|
+
function __promisify__(
|
|
1072
|
+
path: PathLike,
|
|
1073
|
+
options: StatOptions & {
|
|
1074
|
+
bigint: true;
|
|
1075
|
+
}
|
|
1076
|
+
): Promise<BigIntStats>;
|
|
615
1077
|
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
616
1078
|
}
|
|
617
|
-
|
|
618
1079
|
/**
|
|
619
1080
|
* Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
620
1081
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
621
1082
|
*/
|
|
622
1083
|
export const lstatSync: StatSyncFn;
|
|
623
1084
|
/**
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
1085
|
+
* Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than
|
|
1086
|
+
* a possible
|
|
1087
|
+
* exception are given to the completion callback.
|
|
1088
|
+
* @since v0.1.31
|
|
627
1089
|
*/
|
|
628
1090
|
export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
|
|
629
|
-
|
|
630
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
631
1091
|
export namespace link {
|
|
632
1092
|
/**
|
|
633
1093
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
|
|
@@ -636,31 +1096,49 @@ declare module 'fs' {
|
|
|
636
1096
|
*/
|
|
637
1097
|
function __promisify__(existingPath: PathLike, newPath: PathLike): Promise<void>;
|
|
638
1098
|
}
|
|
639
|
-
|
|
640
1099
|
/**
|
|
641
|
-
*
|
|
642
|
-
* @
|
|
643
|
-
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1100
|
+
* Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. Returns `undefined`.
|
|
1101
|
+
* @since v0.1.31
|
|
644
1102
|
*/
|
|
645
1103
|
export function linkSync(existingPath: PathLike, newPath: PathLike): void;
|
|
646
|
-
|
|
647
1104
|
/**
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
1105
|
+
* Creates the link called `path` pointing to `target`. No arguments other than a
|
|
1106
|
+
* possible exception are given to the completion callback.
|
|
1107
|
+
*
|
|
1108
|
+
* See the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details.
|
|
1109
|
+
*
|
|
1110
|
+
* The `type` argument is only available on Windows and ignored on other platforms.
|
|
1111
|
+
* It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
|
|
1112
|
+
* not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If
|
|
1113
|
+
* the `target` does not exist, `'file'` will be used. Windows junction points
|
|
1114
|
+
* require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path.
|
|
1115
|
+
*
|
|
1116
|
+
* Relative targets are relative to the link’s parent directory.
|
|
1117
|
+
*
|
|
1118
|
+
* ```js
|
|
1119
|
+
* import { symlink } from 'fs';
|
|
1120
|
+
*
|
|
1121
|
+
* symlink('./mew', './example/mewtwo', callback);
|
|
1122
|
+
* ```
|
|
1123
|
+
*
|
|
1124
|
+
* The above example creates a symbolic link `mewtwo` in the `example` which points
|
|
1125
|
+
* to `mew` in the same directory:
|
|
1126
|
+
*
|
|
1127
|
+
* ```bash
|
|
1128
|
+
* $ tree example/
|
|
1129
|
+
* example/
|
|
1130
|
+
* ├── mew
|
|
1131
|
+
* └── mewtwo -> ./mew
|
|
1132
|
+
* ```
|
|
1133
|
+
* @since v0.1.31
|
|
653
1134
|
*/
|
|
654
1135
|
export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
|
|
655
|
-
|
|
656
1136
|
/**
|
|
657
1137
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
|
658
1138
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
|
|
659
1139
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
|
|
660
1140
|
*/
|
|
661
1141
|
export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
|
|
662
|
-
|
|
663
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
664
1142
|
export namespace symlink {
|
|
665
1143
|
/**
|
|
666
1144
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
|
@@ -670,51 +1148,46 @@ declare module 'fs' {
|
|
|
670
1148
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
|
|
671
1149
|
*/
|
|
672
1150
|
function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
|
|
673
|
-
|
|
674
|
-
type Type = "dir" | "file" | "junction";
|
|
1151
|
+
type Type = 'dir' | 'file' | 'junction';
|
|
675
1152
|
}
|
|
676
|
-
|
|
677
1153
|
/**
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
1154
|
+
* Returns `undefined`.
|
|
1155
|
+
*
|
|
1156
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
1157
|
+
* this API: {@link symlink}.
|
|
1158
|
+
* @since v0.1.31
|
|
683
1159
|
*/
|
|
684
1160
|
export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
|
|
685
|
-
|
|
686
1161
|
/**
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
1162
|
+
* Reads the contents of the symbolic link referred to by `path`. The callback gets
|
|
1163
|
+
* two arguments `(err, linkString)`.
|
|
1164
|
+
*
|
|
1165
|
+
* See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
|
|
1166
|
+
*
|
|
1167
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1168
|
+
* object with an `encoding` property specifying the character encoding to use for
|
|
1169
|
+
* the link path passed to the callback. If the `encoding` is set to `'buffer'`,
|
|
1170
|
+
* the link path returned will be passed as a `Buffer` object.
|
|
1171
|
+
* @since v0.1.31
|
|
690
1172
|
*/
|
|
691
|
-
export function readlink(
|
|
692
|
-
path: PathLike,
|
|
693
|
-
options: EncodingOption,
|
|
694
|
-
callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
|
|
695
|
-
): void;
|
|
696
|
-
|
|
1173
|
+
export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
|
|
697
1174
|
/**
|
|
698
1175
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
699
1176
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
700
1177
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
701
1178
|
*/
|
|
702
1179
|
export function readlink(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
|
|
703
|
-
|
|
704
1180
|
/**
|
|
705
1181
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
706
1182
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
707
1183
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
708
1184
|
*/
|
|
709
1185
|
export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
|
|
710
|
-
|
|
711
1186
|
/**
|
|
712
1187
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
713
1188
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
714
1189
|
*/
|
|
715
1190
|
export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
|
|
716
|
-
|
|
717
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
718
1191
|
export namespace readlink {
|
|
719
1192
|
/**
|
|
720
1193
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
@@ -722,14 +1195,12 @@ declare module 'fs' {
|
|
|
722
1195
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
723
1196
|
*/
|
|
724
1197
|
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
|
|
725
|
-
|
|
726
1198
|
/**
|
|
727
1199
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
728
1200
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
729
1201
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
730
1202
|
*/
|
|
731
1203
|
function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
|
732
|
-
|
|
733
1204
|
/**
|
|
734
1205
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
735
1206
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -737,60 +1208,74 @@ declare module 'fs' {
|
|
|
737
1208
|
*/
|
|
738
1209
|
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
|
|
739
1210
|
}
|
|
740
|
-
|
|
741
1211
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
1212
|
+
* Returns the symbolic link's string value.
|
|
1213
|
+
*
|
|
1214
|
+
* See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
|
|
1215
|
+
*
|
|
1216
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1217
|
+
* object with an `encoding` property specifying the character encoding to use for
|
|
1218
|
+
* the link path returned. If the `encoding` is set to `'buffer'`,
|
|
1219
|
+
* the link path returned will be passed as a `Buffer` object.
|
|
1220
|
+
* @since v0.1.31
|
|
745
1221
|
*/
|
|
746
1222
|
export function readlinkSync(path: PathLike, options?: EncodingOption): string;
|
|
747
|
-
|
|
748
1223
|
/**
|
|
749
1224
|
* Synchronous readlink(2) - read value of a symbolic link.
|
|
750
1225
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
751
1226
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
752
1227
|
*/
|
|
753
1228
|
export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
|
|
754
|
-
|
|
755
1229
|
/**
|
|
756
1230
|
* Synchronous readlink(2) - read value of a symbolic link.
|
|
757
1231
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
758
1232
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
759
1233
|
*/
|
|
760
1234
|
export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
761
|
-
|
|
762
1235
|
/**
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
1236
|
+
* Asynchronously computes the canonical pathname by resolving `.`, `..` and
|
|
1237
|
+
* symbolic links.
|
|
1238
|
+
*
|
|
1239
|
+
* A canonical pathname is not necessarily unique. Hard links and bind mounts can
|
|
1240
|
+
* expose a file system entity through many pathnames.
|
|
1241
|
+
*
|
|
1242
|
+
* This function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions:
|
|
1243
|
+
*
|
|
1244
|
+
* 1. No case conversion is performed on case-insensitive file systems.
|
|
1245
|
+
* 2. The maximum number of symbolic links is platform-independent and generally
|
|
1246
|
+
* (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports.
|
|
1247
|
+
*
|
|
1248
|
+
* The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`to resolve relative paths.
|
|
1249
|
+
*
|
|
1250
|
+
* Only paths that can be converted to UTF8 strings are supported.
|
|
1251
|
+
*
|
|
1252
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1253
|
+
* object with an `encoding` property specifying the character encoding to use for
|
|
1254
|
+
* the path passed to the callback. If the `encoding` is set to `'buffer'`,
|
|
1255
|
+
* the path returned will be passed as a `Buffer` object.
|
|
1256
|
+
*
|
|
1257
|
+
* If `path` resolves to a socket or a pipe, the function will return a system
|
|
1258
|
+
* dependent name for that object.
|
|
1259
|
+
* @since v0.1.31
|
|
1260
|
+
*/
|
|
1261
|
+
export function realpath(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
|
773
1262
|
/**
|
|
774
1263
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
775
1264
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
776
1265
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
777
1266
|
*/
|
|
778
1267
|
export function realpath(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
|
|
779
|
-
|
|
780
1268
|
/**
|
|
781
1269
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
782
1270
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
783
1271
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
784
1272
|
*/
|
|
785
1273
|
export function realpath(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
|
|
786
|
-
|
|
787
1274
|
/**
|
|
788
1275
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
789
1276
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
790
1277
|
*/
|
|
791
1278
|
export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
|
792
|
-
|
|
793
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
794
1279
|
export namespace realpath {
|
|
795
1280
|
/**
|
|
796
1281
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
@@ -798,65 +1283,85 @@ declare module 'fs' {
|
|
|
798
1283
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
799
1284
|
*/
|
|
800
1285
|
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
|
|
801
|
-
|
|
802
1286
|
/**
|
|
803
1287
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
804
1288
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
805
1289
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
806
1290
|
*/
|
|
807
1291
|
function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
|
808
|
-
|
|
809
1292
|
/**
|
|
810
1293
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
811
1294
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
812
1295
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
813
1296
|
*/
|
|
814
1297
|
function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1298
|
+
/**
|
|
1299
|
+
* Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).
|
|
1300
|
+
*
|
|
1301
|
+
* The `callback` gets two arguments `(err, resolvedPath)`.
|
|
1302
|
+
*
|
|
1303
|
+
* Only paths that can be converted to UTF8 strings are supported.
|
|
1304
|
+
*
|
|
1305
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1306
|
+
* object with an `encoding` property specifying the character encoding to use for
|
|
1307
|
+
* the path passed to the callback. If the `encoding` is set to `'buffer'`,
|
|
1308
|
+
* the path returned will be passed as a `Buffer` object.
|
|
1309
|
+
*
|
|
1310
|
+
* On Linux, when Node.js is linked against musl libc, the procfs file system must
|
|
1311
|
+
* be mounted on `/proc` in order for this function to work. Glibc does not have
|
|
1312
|
+
* this restriction.
|
|
1313
|
+
* @since v9.2.0
|
|
1314
|
+
*/
|
|
1315
|
+
function native(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
|
821
1316
|
function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
|
|
822
1317
|
function native(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
|
|
823
1318
|
function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
|
824
1319
|
}
|
|
825
|
-
|
|
826
1320
|
/**
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
1321
|
+
* Returns the resolved pathname.
|
|
1322
|
+
*
|
|
1323
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
1324
|
+
* this API: {@link realpath}.
|
|
1325
|
+
* @since v0.1.31
|
|
830
1326
|
*/
|
|
831
1327
|
export function realpathSync(path: PathLike, options?: EncodingOption): string;
|
|
832
|
-
|
|
833
1328
|
/**
|
|
834
1329
|
* Synchronous realpath(3) - return the canonicalized absolute pathname.
|
|
835
1330
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
836
1331
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
837
1332
|
*/
|
|
838
1333
|
export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
|
|
839
|
-
|
|
840
1334
|
/**
|
|
841
1335
|
* Synchronous realpath(3) - return the canonicalized absolute pathname.
|
|
842
1336
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
843
1337
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
844
1338
|
*/
|
|
845
1339
|
export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
846
|
-
|
|
847
1340
|
export namespace realpathSync {
|
|
848
1341
|
function native(path: PathLike, options?: EncodingOption): string;
|
|
849
1342
|
function native(path: PathLike, options: BufferEncodingOption): Buffer;
|
|
850
1343
|
function native(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
851
1344
|
}
|
|
852
|
-
|
|
853
1345
|
/**
|
|
854
|
-
*
|
|
855
|
-
*
|
|
1346
|
+
* Asynchronously removes a file or symbolic link. No arguments other than a
|
|
1347
|
+
* possible exception are given to the completion callback.
|
|
1348
|
+
*
|
|
1349
|
+
* ```js
|
|
1350
|
+
* import { unlink } from 'fs';
|
|
1351
|
+
* // Assuming that 'path/file.txt' is a regular file.
|
|
1352
|
+
* unlink('path/file.txt', (err) => {
|
|
1353
|
+
* if (err) throw err;
|
|
1354
|
+
* console.log('path/file.txt was deleted');
|
|
1355
|
+
* });
|
|
1356
|
+
* ```
|
|
1357
|
+
*
|
|
1358
|
+
* `fs.unlink()` will not work on a directory, empty or otherwise. To remove a
|
|
1359
|
+
* directory, use {@link rmdir}.
|
|
1360
|
+
*
|
|
1361
|
+
* See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details.
|
|
1362
|
+
* @since v0.0.2
|
|
856
1363
|
*/
|
|
857
1364
|
export function unlink(path: PathLike, callback: NoParamCallback): void;
|
|
858
|
-
|
|
859
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
860
1365
|
export namespace unlink {
|
|
861
1366
|
/**
|
|
862
1367
|
* Asynchronous unlink(2) - delete a name and possibly the file it refers to.
|
|
@@ -864,13 +1369,11 @@ declare module 'fs' {
|
|
|
864
1369
|
*/
|
|
865
1370
|
function __promisify__(path: PathLike): Promise<void>;
|
|
866
1371
|
}
|
|
867
|
-
|
|
868
1372
|
/**
|
|
869
|
-
* Synchronous unlink(2)
|
|
870
|
-
* @
|
|
1373
|
+
* Synchronous [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html). Returns `undefined`.
|
|
1374
|
+
* @since v0.1.21
|
|
871
1375
|
*/
|
|
872
1376
|
export function unlinkSync(path: PathLike): void;
|
|
873
|
-
|
|
874
1377
|
export interface RmDirOptions {
|
|
875
1378
|
/**
|
|
876
1379
|
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
|
|
@@ -898,15 +1401,18 @@ declare module 'fs' {
|
|
|
898
1401
|
*/
|
|
899
1402
|
retryDelay?: number | undefined;
|
|
900
1403
|
}
|
|
901
|
-
|
|
902
1404
|
/**
|
|
903
|
-
* Asynchronous rmdir(2)
|
|
904
|
-
*
|
|
1405
|
+
* Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given
|
|
1406
|
+
* to the completion callback.
|
|
1407
|
+
*
|
|
1408
|
+
* Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on
|
|
1409
|
+
* Windows and an `ENOTDIR` error on POSIX.
|
|
1410
|
+
*
|
|
1411
|
+
* To get a behavior similar to the `rm -rf` Unix command, use {@link rm} with options `{ recursive: true, force: true }`.
|
|
1412
|
+
* @since v0.0.2
|
|
905
1413
|
*/
|
|
906
1414
|
export function rmdir(path: PathLike, callback: NoParamCallback): void;
|
|
907
1415
|
export function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
|
|
908
|
-
|
|
909
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
910
1416
|
export namespace rmdir {
|
|
911
1417
|
/**
|
|
912
1418
|
* Asynchronous rmdir(2) - delete a directory.
|
|
@@ -914,13 +1420,16 @@ declare module 'fs' {
|
|
|
914
1420
|
*/
|
|
915
1421
|
function __promisify__(path: PathLike, options?: RmDirOptions): Promise<void>;
|
|
916
1422
|
}
|
|
917
|
-
|
|
918
1423
|
/**
|
|
919
|
-
* Synchronous rmdir(2)
|
|
920
|
-
*
|
|
1424
|
+
* Synchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). Returns `undefined`.
|
|
1425
|
+
*
|
|
1426
|
+
* Using `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error
|
|
1427
|
+
* on Windows and an `ENOTDIR` error on POSIX.
|
|
1428
|
+
*
|
|
1429
|
+
* To get a behavior similar to the `rm -rf` Unix command, use {@link rmSync} with options `{ recursive: true, force: true }`.
|
|
1430
|
+
* @since v0.1.21
|
|
921
1431
|
*/
|
|
922
1432
|
export function rmdirSync(path: PathLike, options?: RmDirOptions): void;
|
|
923
|
-
|
|
924
1433
|
export interface RmOptions {
|
|
925
1434
|
/**
|
|
926
1435
|
* When `true`, exceptions will be ignored if `path` does not exist.
|
|
@@ -949,26 +1458,24 @@ declare module 'fs' {
|
|
|
949
1458
|
*/
|
|
950
1459
|
retryDelay?: number | undefined;
|
|
951
1460
|
}
|
|
952
|
-
|
|
953
1461
|
/**
|
|
954
|
-
* Asynchronously removes files and directories (modeled on the standard POSIX `rm`
|
|
1462
|
+
* Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
|
|
1463
|
+
* completion callback.
|
|
1464
|
+
* @since v14.14.0
|
|
955
1465
|
*/
|
|
956
1466
|
export function rm(path: PathLike, callback: NoParamCallback): void;
|
|
957
1467
|
export function rm(path: PathLike, options: RmOptions, callback: NoParamCallback): void;
|
|
958
|
-
|
|
959
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
960
1468
|
export namespace rm {
|
|
961
1469
|
/**
|
|
962
1470
|
* Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility).
|
|
963
1471
|
*/
|
|
964
1472
|
function __promisify__(path: PathLike, options?: RmOptions): Promise<void>;
|
|
965
1473
|
}
|
|
966
|
-
|
|
967
1474
|
/**
|
|
968
|
-
* Synchronously removes files and directories (modeled on the standard POSIX `rm`
|
|
1475
|
+
* Synchronously removes files and directories (modeled on the standard POSIX `rm`utility). Returns `undefined`.
|
|
1476
|
+
* @since v14.14.0
|
|
969
1477
|
*/
|
|
970
1478
|
export function rmSync(path: PathLike, options?: RmOptions): void;
|
|
971
|
-
|
|
972
1479
|
export interface MakeDirectoryOptions {
|
|
973
1480
|
/**
|
|
974
1481
|
* Indicates whether parent folders should be created.
|
|
@@ -982,23 +1489,65 @@ declare module 'fs' {
|
|
|
982
1489
|
*/
|
|
983
1490
|
mode?: Mode | undefined;
|
|
984
1491
|
}
|
|
985
|
-
|
|
986
1492
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1493
|
+
* Asynchronously creates a directory.
|
|
1494
|
+
*
|
|
1495
|
+
* The callback is given a possible exception and, if `recursive` is `true`, the
|
|
1496
|
+
* first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
|
|
1497
|
+
* created.
|
|
1498
|
+
*
|
|
1499
|
+
* The optional `options` argument can be an integer specifying `mode` (permission
|
|
1500
|
+
* and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that
|
|
1501
|
+
* exists results in an error only
|
|
1502
|
+
* when `recursive` is false.
|
|
1503
|
+
*
|
|
1504
|
+
* ```js
|
|
1505
|
+
* import { mkdir } from 'fs';
|
|
1506
|
+
*
|
|
1507
|
+
* // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist.
|
|
1508
|
+
* mkdir('/tmp/a/apple', { recursive: true }, (err) => {
|
|
1509
|
+
* if (err) throw err;
|
|
1510
|
+
* });
|
|
1511
|
+
* ```
|
|
1512
|
+
*
|
|
1513
|
+
* On Windows, using `fs.mkdir()` on the root directory even with recursion will
|
|
1514
|
+
* result in an error:
|
|
1515
|
+
*
|
|
1516
|
+
* ```js
|
|
1517
|
+
* import { mkdir } from 'fs';
|
|
1518
|
+
*
|
|
1519
|
+
* mkdir('/', { recursive: true }, (err) => {
|
|
1520
|
+
* // => [Error: EPERM: operation not permitted, mkdir 'C:\']
|
|
1521
|
+
* });
|
|
1522
|
+
* ```
|
|
1523
|
+
*
|
|
1524
|
+
* See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
|
|
1525
|
+
* @since v0.1.8
|
|
1526
|
+
*/
|
|
1527
|
+
export function mkdir(
|
|
1528
|
+
path: PathLike,
|
|
1529
|
+
options: MakeDirectoryOptions & {
|
|
1530
|
+
recursive: true;
|
|
1531
|
+
},
|
|
1532
|
+
callback: (err: NodeJS.ErrnoException | null, path?: string) => void
|
|
1533
|
+
): void;
|
|
994
1534
|
/**
|
|
995
1535
|
* Asynchronous mkdir(2) - create a directory.
|
|
996
1536
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
997
1537
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
998
1538
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
999
1539
|
*/
|
|
1000
|
-
export function mkdir(
|
|
1001
|
-
|
|
1540
|
+
export function mkdir(
|
|
1541
|
+
path: PathLike,
|
|
1542
|
+
options:
|
|
1543
|
+
| Mode
|
|
1544
|
+
| (MakeDirectoryOptions & {
|
|
1545
|
+
recursive?: false | undefined;
|
|
1546
|
+
})
|
|
1547
|
+
| null
|
|
1548
|
+
| undefined,
|
|
1549
|
+
callback: NoParamCallback
|
|
1550
|
+
): void;
|
|
1002
1551
|
/**
|
|
1003
1552
|
* Asynchronous mkdir(2) - create a directory.
|
|
1004
1553
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1006,14 +1555,11 @@ declare module 'fs' {
|
|
|
1006
1555
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1007
1556
|
*/
|
|
1008
1557
|
export function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path?: string) => void): void;
|
|
1009
|
-
|
|
1010
1558
|
/**
|
|
1011
1559
|
* Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
|
|
1012
1560
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1013
1561
|
*/
|
|
1014
1562
|
export function mkdir(path: PathLike, callback: NoParamCallback): void;
|
|
1015
|
-
|
|
1016
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1017
1563
|
export namespace mkdir {
|
|
1018
1564
|
/**
|
|
1019
1565
|
* Asynchronous mkdir(2) - create a directory.
|
|
@@ -1021,16 +1567,27 @@ declare module 'fs' {
|
|
|
1021
1567
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
1022
1568
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1023
1569
|
*/
|
|
1024
|
-
function __promisify__(
|
|
1025
|
-
|
|
1570
|
+
function __promisify__(
|
|
1571
|
+
path: PathLike,
|
|
1572
|
+
options: MakeDirectoryOptions & {
|
|
1573
|
+
recursive: true;
|
|
1574
|
+
}
|
|
1575
|
+
): Promise<string | undefined>;
|
|
1026
1576
|
/**
|
|
1027
1577
|
* Asynchronous mkdir(2) - create a directory.
|
|
1028
1578
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1029
1579
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
1030
1580
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1031
1581
|
*/
|
|
1032
|
-
function __promisify__(
|
|
1033
|
-
|
|
1582
|
+
function __promisify__(
|
|
1583
|
+
path: PathLike,
|
|
1584
|
+
options?:
|
|
1585
|
+
| Mode
|
|
1586
|
+
| (MakeDirectoryOptions & {
|
|
1587
|
+
recursive?: false | undefined;
|
|
1588
|
+
})
|
|
1589
|
+
| null
|
|
1590
|
+
): Promise<void>;
|
|
1034
1591
|
/**
|
|
1035
1592
|
* Asynchronous mkdir(2) - create a directory.
|
|
1036
1593
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1039,23 +1596,34 @@ declare module 'fs' {
|
|
|
1039
1596
|
*/
|
|
1040
1597
|
function __promisify__(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
|
|
1041
1598
|
}
|
|
1042
|
-
|
|
1043
1599
|
/**
|
|
1044
|
-
*
|
|
1045
|
-
*
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1600
|
+
* Synchronously creates a directory. Returns `undefined`, or if `recursive` is`true`, the first directory path created.
|
|
1601
|
+
* This is the synchronous version of {@link mkdir}.
|
|
1602
|
+
*
|
|
1603
|
+
* See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
|
|
1604
|
+
* @since v0.1.21
|
|
1048
1605
|
*/
|
|
1049
|
-
export function mkdirSync(
|
|
1050
|
-
|
|
1606
|
+
export function mkdirSync(
|
|
1607
|
+
path: PathLike,
|
|
1608
|
+
options: MakeDirectoryOptions & {
|
|
1609
|
+
recursive: true;
|
|
1610
|
+
}
|
|
1611
|
+
): string | undefined;
|
|
1051
1612
|
/**
|
|
1052
1613
|
* Synchronous mkdir(2) - create a directory.
|
|
1053
1614
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1054
1615
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
|
1055
1616
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1056
1617
|
*/
|
|
1057
|
-
export function mkdirSync(
|
|
1058
|
-
|
|
1618
|
+
export function mkdirSync(
|
|
1619
|
+
path: PathLike,
|
|
1620
|
+
options?:
|
|
1621
|
+
| Mode
|
|
1622
|
+
| (MakeDirectoryOptions & {
|
|
1623
|
+
recursive?: false | undefined;
|
|
1624
|
+
})
|
|
1625
|
+
| null
|
|
1626
|
+
): void;
|
|
1059
1627
|
/**
|
|
1060
1628
|
* Synchronous mkdir(2) - create a directory.
|
|
1061
1629
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1063,35 +1631,89 @@ declare module 'fs' {
|
|
|
1063
1631
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
|
1064
1632
|
*/
|
|
1065
1633
|
export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
|
|
1066
|
-
|
|
1067
1634
|
/**
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1635
|
+
* Creates a unique temporary directory.
|
|
1636
|
+
*
|
|
1637
|
+
* Generates six random characters to be appended behind a required`prefix` to create a unique temporary directory. Due to platform
|
|
1638
|
+
* inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,
|
|
1639
|
+
* notably the BSDs, can return more than six random characters, and replace
|
|
1640
|
+
* trailing `X` characters in `prefix` with random characters.
|
|
1641
|
+
*
|
|
1642
|
+
* The created directory path is passed as a string to the callback's second
|
|
1643
|
+
* parameter.
|
|
1644
|
+
*
|
|
1645
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1646
|
+
* object with an `encoding` property specifying the character encoding to use.
|
|
1647
|
+
*
|
|
1648
|
+
* ```js
|
|
1649
|
+
* import { mkdtemp } from 'fs';
|
|
1650
|
+
*
|
|
1651
|
+
* mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, directory) => {
|
|
1652
|
+
* if (err) throw err;
|
|
1653
|
+
* console.log(directory);
|
|
1654
|
+
* // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2
|
|
1655
|
+
* });
|
|
1656
|
+
* ```
|
|
1657
|
+
*
|
|
1658
|
+
* The `fs.mkdtemp()` method will append the six randomly selected characters
|
|
1659
|
+
* directly to the `prefix` string. For instance, given a directory `/tmp`, if the
|
|
1660
|
+
* intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
|
|
1661
|
+
* (`require('path').sep`).
|
|
1662
|
+
*
|
|
1663
|
+
* ```js
|
|
1664
|
+
* import { tmpdir } from 'os';
|
|
1665
|
+
* import { mkdtemp } from 'fs';
|
|
1666
|
+
*
|
|
1667
|
+
* // The parent directory for the new temporary directory
|
|
1668
|
+
* const tmpDir = tmpdir();
|
|
1669
|
+
*
|
|
1670
|
+
* // This method is *INCORRECT*:
|
|
1671
|
+
* mkdtemp(tmpDir, (err, directory) => {
|
|
1672
|
+
* if (err) throw err;
|
|
1673
|
+
* console.log(directory);
|
|
1674
|
+
* // Will print something similar to `/tmpabc123`.
|
|
1675
|
+
* // A new temporary directory is created at the file system root
|
|
1676
|
+
* // rather than *within* the /tmp directory.
|
|
1677
|
+
* });
|
|
1678
|
+
*
|
|
1679
|
+
* // This method is *CORRECT*:
|
|
1680
|
+
* import { sep } from 'path';
|
|
1681
|
+
* mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
|
|
1682
|
+
* if (err) throw err;
|
|
1683
|
+
* console.log(directory);
|
|
1684
|
+
* // Will print something similar to `/tmp/abc123`.
|
|
1685
|
+
* // A new temporary directory is created within
|
|
1686
|
+
* // the /tmp directory.
|
|
1687
|
+
* });
|
|
1688
|
+
* ```
|
|
1689
|
+
* @since v5.10.0
|
|
1071
1690
|
*/
|
|
1072
1691
|
export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
|
1073
|
-
|
|
1074
1692
|
/**
|
|
1075
1693
|
* Asynchronously creates a unique temporary directory.
|
|
1076
1694
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1077
1695
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1078
1696
|
*/
|
|
1079
|
-
export function mkdtemp(
|
|
1080
|
-
|
|
1697
|
+
export function mkdtemp(
|
|
1698
|
+
prefix: string,
|
|
1699
|
+
options:
|
|
1700
|
+
| 'buffer'
|
|
1701
|
+
| {
|
|
1702
|
+
encoding: 'buffer';
|
|
1703
|
+
},
|
|
1704
|
+
callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void
|
|
1705
|
+
): void;
|
|
1081
1706
|
/**
|
|
1082
1707
|
* Asynchronously creates a unique temporary directory.
|
|
1083
1708
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1084
1709
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1085
1710
|
*/
|
|
1086
1711
|
export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
|
|
1087
|
-
|
|
1088
1712
|
/**
|
|
1089
1713
|
* Asynchronously creates a unique temporary directory.
|
|
1090
1714
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1091
1715
|
*/
|
|
1092
1716
|
export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
|
1093
|
-
|
|
1094
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1095
1717
|
export namespace mkdtemp {
|
|
1096
1718
|
/**
|
|
1097
1719
|
* Asynchronously creates a unique temporary directory.
|
|
@@ -1099,14 +1721,12 @@ declare module 'fs' {
|
|
|
1099
1721
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1100
1722
|
*/
|
|
1101
1723
|
function __promisify__(prefix: string, options?: EncodingOption): Promise<string>;
|
|
1102
|
-
|
|
1103
1724
|
/**
|
|
1104
1725
|
* Asynchronously creates a unique temporary directory.
|
|
1105
1726
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1106
1727
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1107
1728
|
*/
|
|
1108
1729
|
function __promisify__(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
|
|
1109
|
-
|
|
1110
1730
|
/**
|
|
1111
1731
|
* Asynchronously creates a unique temporary directory.
|
|
1112
1732
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
@@ -1114,39 +1734,54 @@ declare module 'fs' {
|
|
|
1114
1734
|
*/
|
|
1115
1735
|
function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
|
|
1116
1736
|
}
|
|
1117
|
-
|
|
1118
1737
|
/**
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1738
|
+
* Returns the created directory path.
|
|
1739
|
+
*
|
|
1740
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
1741
|
+
* this API: {@link mkdtemp}.
|
|
1742
|
+
*
|
|
1743
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1744
|
+
* object with an `encoding` property specifying the character encoding to use.
|
|
1745
|
+
* @since v5.10.0
|
|
1122
1746
|
*/
|
|
1123
1747
|
export function mkdtempSync(prefix: string, options?: EncodingOption): string;
|
|
1124
|
-
|
|
1125
1748
|
/**
|
|
1126
1749
|
* Synchronously creates a unique temporary directory.
|
|
1127
1750
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1128
1751
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1129
1752
|
*/
|
|
1130
1753
|
export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
|
|
1131
|
-
|
|
1132
1754
|
/**
|
|
1133
1755
|
* Synchronously creates a unique temporary directory.
|
|
1134
1756
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
1135
1757
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1136
1758
|
*/
|
|
1137
1759
|
export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
|
|
1138
|
-
|
|
1139
1760
|
/**
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1142
|
-
*
|
|
1761
|
+
* Reads the contents of a directory. The callback gets two arguments `(err, files)`where `files` is an array of the names of the files in the directory excluding`'.'` and `'..'`.
|
|
1762
|
+
*
|
|
1763
|
+
* See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
|
|
1764
|
+
*
|
|
1765
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1766
|
+
* object with an `encoding` property specifying the character encoding to use for
|
|
1767
|
+
* the filenames passed to the callback. If the `encoding` is set to `'buffer'`,
|
|
1768
|
+
* the filenames returned will be passed as `Buffer` objects.
|
|
1769
|
+
*
|
|
1770
|
+
* If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects.
|
|
1771
|
+
* @since v0.1.8
|
|
1143
1772
|
*/
|
|
1144
1773
|
export function readdir(
|
|
1145
1774
|
path: PathLike,
|
|
1146
|
-
options:
|
|
1147
|
-
|
|
1775
|
+
options:
|
|
1776
|
+
| {
|
|
1777
|
+
encoding: BufferEncoding | null;
|
|
1778
|
+
withFileTypes?: false | undefined;
|
|
1779
|
+
}
|
|
1780
|
+
| BufferEncoding
|
|
1781
|
+
| undefined
|
|
1782
|
+
| null,
|
|
1783
|
+
callback: (err: NodeJS.ErrnoException | null, files: string[]) => void
|
|
1148
1784
|
): void;
|
|
1149
|
-
|
|
1150
1785
|
/**
|
|
1151
1786
|
* Asynchronous readdir(3) - read a directory.
|
|
1152
1787
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1154,10 +1789,14 @@ declare module 'fs' {
|
|
|
1154
1789
|
*/
|
|
1155
1790
|
export function readdir(
|
|
1156
1791
|
path: PathLike,
|
|
1157
|
-
options:
|
|
1792
|
+
options:
|
|
1793
|
+
| {
|
|
1794
|
+
encoding: 'buffer';
|
|
1795
|
+
withFileTypes?: false | undefined;
|
|
1796
|
+
}
|
|
1797
|
+
| 'buffer',
|
|
1158
1798
|
callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void
|
|
1159
1799
|
): void;
|
|
1160
|
-
|
|
1161
1800
|
/**
|
|
1162
1801
|
* Asynchronous readdir(3) - read a directory.
|
|
1163
1802
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1165,89 +1804,161 @@ declare module 'fs' {
|
|
|
1165
1804
|
*/
|
|
1166
1805
|
export function readdir(
|
|
1167
1806
|
path: PathLike,
|
|
1168
|
-
options:
|
|
1169
|
-
|
|
1807
|
+
options:
|
|
1808
|
+
| (ObjectEncodingOptions & {
|
|
1809
|
+
withFileTypes?: false | undefined;
|
|
1810
|
+
})
|
|
1811
|
+
| BufferEncoding
|
|
1812
|
+
| undefined
|
|
1813
|
+
| null,
|
|
1814
|
+
callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void
|
|
1170
1815
|
): void;
|
|
1171
|
-
|
|
1172
1816
|
/**
|
|
1173
1817
|
* Asynchronous readdir(3) - read a directory.
|
|
1174
1818
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1175
1819
|
*/
|
|
1176
1820
|
export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
|
|
1177
|
-
|
|
1178
1821
|
/**
|
|
1179
1822
|
* Asynchronous readdir(3) - read a directory.
|
|
1180
1823
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1181
1824
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
|
1182
1825
|
*/
|
|
1183
|
-
export function readdir(
|
|
1184
|
-
|
|
1185
|
-
|
|
1826
|
+
export function readdir(
|
|
1827
|
+
path: PathLike,
|
|
1828
|
+
options: ObjectEncodingOptions & {
|
|
1829
|
+
withFileTypes: true;
|
|
1830
|
+
},
|
|
1831
|
+
callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void
|
|
1832
|
+
): void;
|
|
1186
1833
|
export namespace readdir {
|
|
1187
1834
|
/**
|
|
1188
1835
|
* Asynchronous readdir(3) - read a directory.
|
|
1189
1836
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1190
1837
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1191
1838
|
*/
|
|
1192
|
-
function __promisify__(
|
|
1193
|
-
|
|
1839
|
+
function __promisify__(
|
|
1840
|
+
path: PathLike,
|
|
1841
|
+
options?:
|
|
1842
|
+
| {
|
|
1843
|
+
encoding: BufferEncoding | null;
|
|
1844
|
+
withFileTypes?: false | undefined;
|
|
1845
|
+
}
|
|
1846
|
+
| BufferEncoding
|
|
1847
|
+
| null
|
|
1848
|
+
): Promise<string[]>;
|
|
1194
1849
|
/**
|
|
1195
1850
|
* Asynchronous readdir(3) - read a directory.
|
|
1196
1851
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1197
1852
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1198
1853
|
*/
|
|
1199
|
-
function __promisify__(
|
|
1200
|
-
|
|
1854
|
+
function __promisify__(
|
|
1855
|
+
path: PathLike,
|
|
1856
|
+
options:
|
|
1857
|
+
| 'buffer'
|
|
1858
|
+
| {
|
|
1859
|
+
encoding: 'buffer';
|
|
1860
|
+
withFileTypes?: false | undefined;
|
|
1861
|
+
}
|
|
1862
|
+
): Promise<Buffer[]>;
|
|
1201
1863
|
/**
|
|
1202
1864
|
* Asynchronous readdir(3) - read a directory.
|
|
1203
1865
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1204
1866
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1205
1867
|
*/
|
|
1206
|
-
function __promisify__(
|
|
1207
|
-
|
|
1868
|
+
function __promisify__(
|
|
1869
|
+
path: PathLike,
|
|
1870
|
+
options?:
|
|
1871
|
+
| (ObjectEncodingOptions & {
|
|
1872
|
+
withFileTypes?: false | undefined;
|
|
1873
|
+
})
|
|
1874
|
+
| BufferEncoding
|
|
1875
|
+
| null
|
|
1876
|
+
): Promise<string[] | Buffer[]>;
|
|
1208
1877
|
/**
|
|
1209
1878
|
* Asynchronous readdir(3) - read a directory.
|
|
1210
1879
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1211
1880
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent
|
|
1212
1881
|
*/
|
|
1213
|
-
function __promisify__(
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1882
|
+
function __promisify__(
|
|
1883
|
+
path: PathLike,
|
|
1884
|
+
options: ObjectEncodingOptions & {
|
|
1885
|
+
withFileTypes: true;
|
|
1886
|
+
}
|
|
1887
|
+
): Promise<Dirent[]>;
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Reads the contents of the directory.
|
|
1891
|
+
*
|
|
1892
|
+
* See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
|
|
1893
|
+
*
|
|
1894
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1895
|
+
* object with an `encoding` property specifying the character encoding to use for
|
|
1896
|
+
* the filenames returned. If the `encoding` is set to `'buffer'`,
|
|
1897
|
+
* the filenames returned will be passed as `Buffer` objects.
|
|
1898
|
+
*
|
|
1899
|
+
* If `options.withFileTypes` is set to `true`, the result will contain `fs.Dirent` objects.
|
|
1900
|
+
* @since v0.1.21
|
|
1901
|
+
*/
|
|
1902
|
+
export function readdirSync(
|
|
1903
|
+
path: PathLike,
|
|
1904
|
+
options?:
|
|
1905
|
+
| {
|
|
1906
|
+
encoding: BufferEncoding | null;
|
|
1907
|
+
withFileTypes?: false | undefined;
|
|
1908
|
+
}
|
|
1909
|
+
| BufferEncoding
|
|
1910
|
+
| null
|
|
1911
|
+
): string[];
|
|
1223
1912
|
/**
|
|
1224
1913
|
* Synchronous readdir(3) - read a directory.
|
|
1225
1914
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1226
1915
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1227
1916
|
*/
|
|
1228
|
-
export function readdirSync(
|
|
1229
|
-
|
|
1917
|
+
export function readdirSync(
|
|
1918
|
+
path: PathLike,
|
|
1919
|
+
options:
|
|
1920
|
+
| {
|
|
1921
|
+
encoding: 'buffer';
|
|
1922
|
+
withFileTypes?: false | undefined;
|
|
1923
|
+
}
|
|
1924
|
+
| 'buffer'
|
|
1925
|
+
): Buffer[];
|
|
1230
1926
|
/**
|
|
1231
1927
|
* Synchronous readdir(3) - read a directory.
|
|
1232
1928
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1233
1929
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
1234
1930
|
*/
|
|
1235
|
-
export function readdirSync(
|
|
1236
|
-
|
|
1931
|
+
export function readdirSync(
|
|
1932
|
+
path: PathLike,
|
|
1933
|
+
options?:
|
|
1934
|
+
| (ObjectEncodingOptions & {
|
|
1935
|
+
withFileTypes?: false | undefined;
|
|
1936
|
+
})
|
|
1937
|
+
| BufferEncoding
|
|
1938
|
+
| null
|
|
1939
|
+
): string[] | Buffer[];
|
|
1237
1940
|
/**
|
|
1238
1941
|
* Synchronous readdir(3) - read a directory.
|
|
1239
1942
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1240
1943
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
|
1241
1944
|
*/
|
|
1242
|
-
export function readdirSync(
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1945
|
+
export function readdirSync(
|
|
1946
|
+
path: PathLike,
|
|
1947
|
+
options: ObjectEncodingOptions & {
|
|
1948
|
+
withFileTypes: true;
|
|
1949
|
+
}
|
|
1950
|
+
): Dirent[];
|
|
1951
|
+
/**
|
|
1952
|
+
* Closes the file descriptor. No arguments other than a possible exception are
|
|
1953
|
+
* given to the completion callback.
|
|
1954
|
+
*
|
|
1955
|
+
* Calling `fs.close()` on any file descriptor (`fd`) that is currently in use
|
|
1956
|
+
* through any other `fs` operation may lead to undefined behavior.
|
|
1957
|
+
*
|
|
1958
|
+
* See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
|
|
1959
|
+
* @since v0.0.2
|
|
1247
1960
|
*/
|
|
1248
1961
|
export function close(fd: number, callback?: NoParamCallback): void;
|
|
1249
|
-
|
|
1250
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1251
1962
|
export namespace close {
|
|
1252
1963
|
/**
|
|
1253
1964
|
* Asynchronous close(2) - close a file descriptor.
|
|
@@ -1255,27 +1966,39 @@ declare module 'fs' {
|
|
|
1255
1966
|
*/
|
|
1256
1967
|
function __promisify__(fd: number): Promise<void>;
|
|
1257
1968
|
}
|
|
1258
|
-
|
|
1259
1969
|
/**
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1970
|
+
* Closes the file descriptor. Returns `undefined`.
|
|
1971
|
+
*
|
|
1972
|
+
* Calling `fs.closeSync()` on any file descriptor (`fd`) that is currently in use
|
|
1973
|
+
* through any other `fs` operation may lead to undefined behavior.
|
|
1974
|
+
*
|
|
1975
|
+
* See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
|
|
1976
|
+
* @since v0.1.21
|
|
1262
1977
|
*/
|
|
1263
1978
|
export function closeSync(fd: number): void;
|
|
1264
|
-
|
|
1265
1979
|
/**
|
|
1266
|
-
* Asynchronous open(2)
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1980
|
+
* Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details.
|
|
1981
|
+
*
|
|
1982
|
+
* `mode` sets the file mode (permission and sticky bits), but only if the file was
|
|
1983
|
+
* created. On Windows, only the write permission can be manipulated; see {@link chmod}.
|
|
1984
|
+
*
|
|
1985
|
+
* The callback gets two arguments `(err, fd)`.
|
|
1986
|
+
*
|
|
1987
|
+
* Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
|
|
1988
|
+
* by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
|
1989
|
+
* a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
|
1990
|
+
*
|
|
1991
|
+
* Functions based on `fs.open()` exhibit this behavior as well:`fs.writeFile()`, `fs.readFile()`, etc.
|
|
1992
|
+
* @since v0.0.2
|
|
1993
|
+
* @param [flags='r'] See `support of file system `flags``.
|
|
1994
|
+
* @param [mode=0o666]
|
|
1269
1995
|
*/
|
|
1270
1996
|
export function open(path: PathLike, flags: OpenMode, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
|
1271
|
-
|
|
1272
1997
|
/**
|
|
1273
1998
|
* Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
|
|
1274
1999
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1275
2000
|
*/
|
|
1276
2001
|
export function open(path: PathLike, flags: OpenMode, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
|
1277
|
-
|
|
1278
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1279
2002
|
export namespace open {
|
|
1280
2003
|
/**
|
|
1281
2004
|
* Asynchronous open(2) - open and possibly create a file.
|
|
@@ -1284,23 +2007,26 @@ declare module 'fs' {
|
|
|
1284
2007
|
*/
|
|
1285
2008
|
function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise<number>;
|
|
1286
2009
|
}
|
|
1287
|
-
|
|
1288
2010
|
/**
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
2011
|
+
* Returns an integer representing the file descriptor.
|
|
2012
|
+
*
|
|
2013
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
2014
|
+
* this API: {@link open}.
|
|
2015
|
+
* @since v0.1.21
|
|
2016
|
+
* @param [flags='r']
|
|
2017
|
+
* @param [mode=0o666]
|
|
1292
2018
|
*/
|
|
1293
2019
|
export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number;
|
|
1294
|
-
|
|
1295
2020
|
/**
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
2021
|
+
* Change the file system timestamps of the object referenced by `path`.
|
|
2022
|
+
*
|
|
2023
|
+
* The `atime` and `mtime` arguments follow these rules:
|
|
2024
|
+
*
|
|
2025
|
+
* * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`.
|
|
2026
|
+
* * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown.
|
|
2027
|
+
* @since v0.4.2
|
|
1300
2028
|
*/
|
|
1301
2029
|
export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
|
1302
|
-
|
|
1303
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1304
2030
|
export namespace utimes {
|
|
1305
2031
|
/**
|
|
1306
2032
|
* Asynchronously change file timestamps of the file referenced by the supplied path.
|
|
@@ -1310,24 +2036,20 @@ declare module 'fs' {
|
|
|
1310
2036
|
*/
|
|
1311
2037
|
function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
|
1312
2038
|
}
|
|
1313
|
-
|
|
1314
2039
|
/**
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
2040
|
+
* Returns `undefined`.
|
|
2041
|
+
*
|
|
2042
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
2043
|
+
* this API: {@link utimes}.
|
|
2044
|
+
* @since v0.4.2
|
|
1319
2045
|
*/
|
|
1320
2046
|
export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
|
|
1321
|
-
|
|
1322
2047
|
/**
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
* @
|
|
1326
|
-
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
2048
|
+
* Change the file system timestamps of the object referenced by the supplied file
|
|
2049
|
+
* descriptor. See {@link utimes}.
|
|
2050
|
+
* @since v0.4.2
|
|
1327
2051
|
*/
|
|
1328
2052
|
export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
|
1329
|
-
|
|
1330
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1331
2053
|
export namespace futimes {
|
|
1332
2054
|
/**
|
|
1333
2055
|
* Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
|
|
@@ -1337,22 +2059,19 @@ declare module 'fs' {
|
|
|
1337
2059
|
*/
|
|
1338
2060
|
function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
|
1339
2061
|
}
|
|
1340
|
-
|
|
1341
2062
|
/**
|
|
1342
|
-
*
|
|
1343
|
-
* @
|
|
1344
|
-
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
1345
|
-
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
|
2063
|
+
* Synchronous version of {@link futimes}. Returns `undefined`.
|
|
2064
|
+
* @since v0.4.2
|
|
1346
2065
|
*/
|
|
1347
2066
|
export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void;
|
|
1348
|
-
|
|
1349
2067
|
/**
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
2068
|
+
* Request that all data for the open file descriptor is flushed to the storage
|
|
2069
|
+
* device. The specific implementation is operating system and device specific.
|
|
2070
|
+
* Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. No arguments other
|
|
2071
|
+
* than a possible exception are given to the completion callback.
|
|
2072
|
+
* @since v0.1.96
|
|
1352
2073
|
*/
|
|
1353
2074
|
export function fsync(fd: number, callback: NoParamCallback): void;
|
|
1354
|
-
|
|
1355
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1356
2075
|
export namespace fsync {
|
|
1357
2076
|
/**
|
|
1358
2077
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
|
@@ -1360,19 +2079,37 @@ declare module 'fs' {
|
|
|
1360
2079
|
*/
|
|
1361
2080
|
function __promisify__(fd: number): Promise<void>;
|
|
1362
2081
|
}
|
|
1363
|
-
|
|
1364
2082
|
/**
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
2083
|
+
* Request that all data for the open file descriptor is flushed to the storage
|
|
2084
|
+
* device. The specific implementation is operating system and device specific.
|
|
2085
|
+
* Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. Returns `undefined`.
|
|
2086
|
+
* @since v0.1.96
|
|
1367
2087
|
*/
|
|
1368
2088
|
export function fsyncSync(fd: number): void;
|
|
1369
|
-
|
|
1370
2089
|
/**
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
2090
|
+
* Write `buffer` to the file specified by `fd`. If `buffer` is a normal object, it
|
|
2091
|
+
* must have an own `toString` function property.
|
|
2092
|
+
*
|
|
2093
|
+
* `offset` determines the part of the buffer to be written, and `length` is
|
|
2094
|
+
* an integer specifying the number of bytes to write.
|
|
2095
|
+
*
|
|
2096
|
+
* `position` refers to the offset from the beginning of the file where this data
|
|
2097
|
+
* should be written. If `typeof position !== 'number'`, the data will be written
|
|
2098
|
+
* at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).
|
|
2099
|
+
*
|
|
2100
|
+
* The callback will be given three arguments `(err, bytesWritten, buffer)` where`bytesWritten` specifies how many _bytes_ were written from `buffer`.
|
|
2101
|
+
*
|
|
2102
|
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
|
2103
|
+
* a promise for an `Object` with `bytesWritten` and `buffer` properties.
|
|
2104
|
+
*
|
|
2105
|
+
* It is unsafe to use `fs.write()` multiple times on the same file without waiting
|
|
2106
|
+
* for the callback. For this scenario, {@link createWriteStream} is
|
|
2107
|
+
* recommended.
|
|
2108
|
+
*
|
|
2109
|
+
* On Linux, positional writes don't work when the file is opened in append mode.
|
|
2110
|
+
* The kernel ignores the position argument and always appends the data to
|
|
2111
|
+
* the end of the file.
|
|
2112
|
+
* @since v0.0.2
|
|
1376
2113
|
*/
|
|
1377
2114
|
export function write<TBuffer extends NodeJS.ArrayBufferView>(
|
|
1378
2115
|
fd: number,
|
|
@@ -1380,9 +2117,8 @@ declare module 'fs' {
|
|
|
1380
2117
|
offset: number | undefined | null,
|
|
1381
2118
|
length: number | undefined | null,
|
|
1382
2119
|
position: number | undefined | null,
|
|
1383
|
-
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
|
|
2120
|
+
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
|
|
1384
2121
|
): void;
|
|
1385
|
-
|
|
1386
2122
|
/**
|
|
1387
2123
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
|
1388
2124
|
* @param fd A file descriptor.
|
|
@@ -1394,9 +2130,8 @@ declare module 'fs' {
|
|
|
1394
2130
|
buffer: TBuffer,
|
|
1395
2131
|
offset: number | undefined | null,
|
|
1396
2132
|
length: number | undefined | null,
|
|
1397
|
-
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
|
|
2133
|
+
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
|
|
1398
2134
|
): void;
|
|
1399
|
-
|
|
1400
2135
|
/**
|
|
1401
2136
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
|
1402
2137
|
* @param fd A file descriptor.
|
|
@@ -1408,13 +2143,11 @@ declare module 'fs' {
|
|
|
1408
2143
|
offset: number | undefined | null,
|
|
1409
2144
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
|
|
1410
2145
|
): void;
|
|
1411
|
-
|
|
1412
2146
|
/**
|
|
1413
2147
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
|
1414
2148
|
* @param fd A file descriptor.
|
|
1415
2149
|
*/
|
|
1416
2150
|
export function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
|
|
1417
|
-
|
|
1418
2151
|
/**
|
|
1419
2152
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
|
1420
2153
|
* @param fd A file descriptor.
|
|
@@ -1427,9 +2160,8 @@ declare module 'fs' {
|
|
|
1427
2160
|
string: string,
|
|
1428
2161
|
position: number | undefined | null,
|
|
1429
2162
|
encoding: BufferEncoding | undefined | null,
|
|
1430
|
-
callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void
|
|
2163
|
+
callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void
|
|
1431
2164
|
): void;
|
|
1432
|
-
|
|
1433
2165
|
/**
|
|
1434
2166
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
|
1435
2167
|
* @param fd A file descriptor.
|
|
@@ -1437,15 +2169,12 @@ declare module 'fs' {
|
|
|
1437
2169
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
|
1438
2170
|
*/
|
|
1439
2171
|
export function write(fd: number, string: string, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
|
|
1440
|
-
|
|
1441
2172
|
/**
|
|
1442
2173
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
|
1443
2174
|
* @param fd A file descriptor.
|
|
1444
2175
|
* @param string A string to write.
|
|
1445
2176
|
*/
|
|
1446
2177
|
export function write(fd: number, string: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
|
|
1447
|
-
|
|
1448
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1449
2178
|
export namespace write {
|
|
1450
2179
|
/**
|
|
1451
2180
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
|
@@ -1459,9 +2188,11 @@ declare module 'fs' {
|
|
|
1459
2188
|
buffer?: TBuffer,
|
|
1460
2189
|
offset?: number,
|
|
1461
2190
|
length?: number,
|
|
1462
|
-
position?: number | null
|
|
1463
|
-
): Promise<{
|
|
1464
|
-
|
|
2191
|
+
position?: number | null
|
|
2192
|
+
): Promise<{
|
|
2193
|
+
bytesWritten: number;
|
|
2194
|
+
buffer: TBuffer;
|
|
2195
|
+
}>;
|
|
1465
2196
|
/**
|
|
1466
2197
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
|
1467
2198
|
* @param fd A file descriptor.
|
|
@@ -1469,18 +2200,25 @@ declare module 'fs' {
|
|
|
1469
2200
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
|
1470
2201
|
* @param encoding The expected string encoding.
|
|
1471
2202
|
*/
|
|
1472
|
-
function __promisify__(
|
|
2203
|
+
function __promisify__(
|
|
2204
|
+
fd: number,
|
|
2205
|
+
string: string,
|
|
2206
|
+
position?: number | null,
|
|
2207
|
+
encoding?: BufferEncoding | null
|
|
2208
|
+
): Promise<{
|
|
2209
|
+
bytesWritten: number;
|
|
2210
|
+
buffer: string;
|
|
2211
|
+
}>;
|
|
1473
2212
|
}
|
|
1474
|
-
|
|
1475
2213
|
/**
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
* @
|
|
2214
|
+
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2215
|
+
*
|
|
2216
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
2217
|
+
* this API: {@link write}.
|
|
2218
|
+
* @since v0.1.21
|
|
2219
|
+
* @return The number of bytes written.
|
|
1481
2220
|
*/
|
|
1482
2221
|
export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
|
|
1483
|
-
|
|
1484
2222
|
/**
|
|
1485
2223
|
* Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
|
|
1486
2224
|
* @param fd A file descriptor.
|
|
@@ -1489,16 +2227,23 @@ declare module 'fs' {
|
|
|
1489
2227
|
* @param encoding The expected string encoding.
|
|
1490
2228
|
*/
|
|
1491
2229
|
export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
|
|
1492
|
-
|
|
1493
2230
|
export type ReadPosition = number | bigint;
|
|
1494
|
-
|
|
1495
2231
|
/**
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
2232
|
+
* Read data from the file specified by `fd`.
|
|
2233
|
+
*
|
|
2234
|
+
* The callback is given the three arguments, `(err, bytesRead, buffer)`.
|
|
2235
|
+
*
|
|
2236
|
+
* If the file is not modified concurrently, the end-of-file is reached when the
|
|
2237
|
+
* number of bytes read is zero.
|
|
2238
|
+
*
|
|
2239
|
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
|
2240
|
+
* a promise for an `Object` with `bytesRead` and `buffer` properties.
|
|
2241
|
+
* @since v0.0.2
|
|
1498
2242
|
* @param buffer The buffer that the data will be written to.
|
|
1499
|
-
* @param offset The
|
|
2243
|
+
* @param offset The position in `buffer` to write the data to.
|
|
1500
2244
|
* @param length The number of bytes to read.
|
|
1501
|
-
* @param position
|
|
2245
|
+
* @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If
|
|
2246
|
+
* `position` is an integer, the file position will be unchanged.
|
|
1502
2247
|
*/
|
|
1503
2248
|
export function read<TBuffer extends NodeJS.ArrayBufferView>(
|
|
1504
2249
|
fd: number,
|
|
@@ -1506,10 +2251,8 @@ declare module 'fs' {
|
|
|
1506
2251
|
offset: number,
|
|
1507
2252
|
length: number,
|
|
1508
2253
|
position: ReadPosition | null,
|
|
1509
|
-
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
|
2254
|
+
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
|
1510
2255
|
): void;
|
|
1511
|
-
|
|
1512
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1513
2256
|
export namespace read {
|
|
1514
2257
|
/**
|
|
1515
2258
|
* @param fd A file descriptor.
|
|
@@ -1524,9 +2267,11 @@ declare module 'fs' {
|
|
|
1524
2267
|
offset: number,
|
|
1525
2268
|
length: number,
|
|
1526
2269
|
position: number | null
|
|
1527
|
-
): Promise<{
|
|
2270
|
+
): Promise<{
|
|
2271
|
+
bytesRead: number;
|
|
2272
|
+
buffer: TBuffer;
|
|
2273
|
+
}>;
|
|
1528
2274
|
}
|
|
1529
|
-
|
|
1530
2275
|
export interface ReadSyncOptions {
|
|
1531
2276
|
/**
|
|
1532
2277
|
* @default 0
|
|
@@ -1541,36 +2286,96 @@ declare module 'fs' {
|
|
|
1541
2286
|
*/
|
|
1542
2287
|
position?: ReadPosition | null | undefined;
|
|
1543
2288
|
}
|
|
1544
|
-
|
|
1545
2289
|
/**
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
* @
|
|
1551
|
-
* @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
|
|
2290
|
+
* Returns the number of `bytesRead`.
|
|
2291
|
+
*
|
|
2292
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
2293
|
+
* this API: {@link read}.
|
|
2294
|
+
* @since v0.1.21
|
|
1552
2295
|
*/
|
|
1553
2296
|
export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null): number;
|
|
1554
|
-
|
|
1555
2297
|
/**
|
|
1556
2298
|
* Similar to the above `fs.readSync` function, this version takes an optional `options` object.
|
|
1557
2299
|
* If no `options` object is specified, it will default with the above values.
|
|
1558
2300
|
*/
|
|
1559
2301
|
export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
|
|
1560
|
-
|
|
1561
2302
|
/**
|
|
1562
2303
|
* Asynchronously reads the entire contents of a file.
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
2304
|
+
*
|
|
2305
|
+
* ```js
|
|
2306
|
+
* import { readFile } from 'fs';
|
|
2307
|
+
*
|
|
2308
|
+
* readFile('/etc/passwd', (err, data) => {
|
|
2309
|
+
* if (err) throw err;
|
|
2310
|
+
* console.log(data);
|
|
2311
|
+
* });
|
|
2312
|
+
* ```
|
|
2313
|
+
*
|
|
2314
|
+
* The callback is passed two arguments `(err, data)`, where `data` is the
|
|
2315
|
+
* contents of the file.
|
|
2316
|
+
*
|
|
2317
|
+
* If no encoding is specified, then the raw buffer is returned.
|
|
2318
|
+
*
|
|
2319
|
+
* If `options` is a string, then it specifies the encoding:
|
|
2320
|
+
*
|
|
2321
|
+
* ```js
|
|
2322
|
+
* import { readFile } from 'fs';
|
|
2323
|
+
*
|
|
2324
|
+
* readFile('/etc/passwd', 'utf8', callback);
|
|
2325
|
+
* ```
|
|
2326
|
+
*
|
|
2327
|
+
* When the path is a directory, the behavior of `fs.readFile()` and {@link readFileSync} is platform-specific. On macOS, Linux, and Windows, an
|
|
2328
|
+
* error will be returned. On FreeBSD, a representation of the directory's contents
|
|
2329
|
+
* will be returned.
|
|
2330
|
+
*
|
|
2331
|
+
* ```js
|
|
2332
|
+
* import { readFile } from 'fs';
|
|
2333
|
+
*
|
|
2334
|
+
* // macOS, Linux, and Windows
|
|
2335
|
+
* readFile('<directory>', (err, data) => {
|
|
2336
|
+
* // => [Error: EISDIR: illegal operation on a directory, read <directory>]
|
|
2337
|
+
* });
|
|
2338
|
+
*
|
|
2339
|
+
* // FreeBSD
|
|
2340
|
+
* readFile('<directory>', (err, data) => {
|
|
2341
|
+
* // => null, <data>
|
|
2342
|
+
* });
|
|
2343
|
+
* ```
|
|
2344
|
+
*
|
|
2345
|
+
* It is possible to abort an ongoing request using an `AbortSignal`. If a
|
|
2346
|
+
* request is aborted the callback is called with an `AbortError`:
|
|
2347
|
+
*
|
|
2348
|
+
* ```js
|
|
2349
|
+
* import { readFile } from 'fs';
|
|
2350
|
+
*
|
|
2351
|
+
* const controller = new AbortController();
|
|
2352
|
+
* const signal = controller.signal;
|
|
2353
|
+
* readFile(fileInfo[0].name, { signal }, (err, buf) => {
|
|
2354
|
+
* // ...
|
|
2355
|
+
* });
|
|
2356
|
+
* // When you want to abort the request
|
|
2357
|
+
* controller.abort();
|
|
2358
|
+
* ```
|
|
2359
|
+
*
|
|
2360
|
+
* The `fs.readFile()` function buffers the entire file. To minimize memory costs,
|
|
2361
|
+
* when possible prefer streaming via `fs.createReadStream()`.
|
|
2362
|
+
*
|
|
2363
|
+
* Aborting an ongoing request does not abort individual operating
|
|
2364
|
+
* system requests but rather the internal buffering `fs.readFile` performs.
|
|
2365
|
+
* @since v0.1.29
|
|
2366
|
+
* @param path filename or file descriptor
|
|
1567
2367
|
*/
|
|
1568
2368
|
export function readFile(
|
|
1569
2369
|
path: PathOrFileDescriptor,
|
|
1570
|
-
options:
|
|
1571
|
-
|
|
2370
|
+
options:
|
|
2371
|
+
| ({
|
|
2372
|
+
encoding?: null | undefined;
|
|
2373
|
+
flag?: string | undefined;
|
|
2374
|
+
} & Abortable)
|
|
2375
|
+
| undefined
|
|
2376
|
+
| null,
|
|
2377
|
+
callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void
|
|
1572
2378
|
): void;
|
|
1573
|
-
|
|
1574
2379
|
/**
|
|
1575
2380
|
* Asynchronously reads the entire contents of a file.
|
|
1576
2381
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1580,10 +2385,14 @@ declare module 'fs' {
|
|
|
1580
2385
|
*/
|
|
1581
2386
|
export function readFile(
|
|
1582
2387
|
path: PathOrFileDescriptor,
|
|
1583
|
-
options:
|
|
1584
|
-
|
|
2388
|
+
options:
|
|
2389
|
+
| ({
|
|
2390
|
+
encoding: BufferEncoding;
|
|
2391
|
+
flag?: string | undefined;
|
|
2392
|
+
} & Abortable)
|
|
2393
|
+
| BufferEncoding,
|
|
2394
|
+
callback: (err: NodeJS.ErrnoException | null, data: string) => void
|
|
1585
2395
|
): void;
|
|
1586
|
-
|
|
1587
2396
|
/**
|
|
1588
2397
|
* Asynchronously reads the entire contents of a file.
|
|
1589
2398
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1593,18 +2402,21 @@ declare module 'fs' {
|
|
|
1593
2402
|
*/
|
|
1594
2403
|
export function readFile(
|
|
1595
2404
|
path: PathOrFileDescriptor,
|
|
1596
|
-
options:
|
|
1597
|
-
|
|
2405
|
+
options:
|
|
2406
|
+
| (ObjectEncodingOptions & {
|
|
2407
|
+
flag?: string | undefined;
|
|
2408
|
+
} & Abortable)
|
|
2409
|
+
| BufferEncoding
|
|
2410
|
+
| undefined
|
|
2411
|
+
| null,
|
|
2412
|
+
callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void
|
|
1598
2413
|
): void;
|
|
1599
|
-
|
|
1600
2414
|
/**
|
|
1601
2415
|
* Asynchronously reads the entire contents of a file.
|
|
1602
2416
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
1603
2417
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
1604
2418
|
*/
|
|
1605
2419
|
export function readFile(path: PathOrFileDescriptor, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
|
|
1606
|
-
|
|
1607
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1608
2420
|
export namespace readFile {
|
|
1609
2421
|
/**
|
|
1610
2422
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -1613,8 +2425,13 @@ declare module 'fs' {
|
|
|
1613
2425
|
* @param options An object that may contain an optional flag.
|
|
1614
2426
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1615
2427
|
*/
|
|
1616
|
-
function __promisify__(
|
|
1617
|
-
|
|
2428
|
+
function __promisify__(
|
|
2429
|
+
path: PathOrFileDescriptor,
|
|
2430
|
+
options?: {
|
|
2431
|
+
encoding?: null | undefined;
|
|
2432
|
+
flag?: string | undefined;
|
|
2433
|
+
} | null
|
|
2434
|
+
): Promise<Buffer>;
|
|
1618
2435
|
/**
|
|
1619
2436
|
* Asynchronously reads the entire contents of a file.
|
|
1620
2437
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1623,8 +2440,15 @@ declare module 'fs' {
|
|
|
1623
2440
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1624
2441
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1625
2442
|
*/
|
|
1626
|
-
function __promisify__(
|
|
1627
|
-
|
|
2443
|
+
function __promisify__(
|
|
2444
|
+
path: PathOrFileDescriptor,
|
|
2445
|
+
options:
|
|
2446
|
+
| {
|
|
2447
|
+
encoding: BufferEncoding;
|
|
2448
|
+
flag?: string | undefined;
|
|
2449
|
+
}
|
|
2450
|
+
| BufferEncoding
|
|
2451
|
+
): Promise<string>;
|
|
1628
2452
|
/**
|
|
1629
2453
|
* Asynchronously reads the entire contents of a file.
|
|
1630
2454
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1633,17 +2457,47 @@ declare module 'fs' {
|
|
|
1633
2457
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1634
2458
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1635
2459
|
*/
|
|
1636
|
-
function __promisify__(
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
2460
|
+
function __promisify__(
|
|
2461
|
+
path: PathOrFileDescriptor,
|
|
2462
|
+
options?:
|
|
2463
|
+
| (ObjectEncodingOptions & {
|
|
2464
|
+
flag?: string | undefined;
|
|
2465
|
+
})
|
|
2466
|
+
| BufferEncoding
|
|
2467
|
+
| null
|
|
2468
|
+
): Promise<string | Buffer>;
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* Returns the contents of the `path`.
|
|
2472
|
+
*
|
|
2473
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
2474
|
+
* this API: {@link readFile}.
|
|
2475
|
+
*
|
|
2476
|
+
* If the `encoding` option is specified then this function returns a
|
|
2477
|
+
* string. Otherwise it returns a buffer.
|
|
2478
|
+
*
|
|
2479
|
+
* Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific.
|
|
2480
|
+
*
|
|
2481
|
+
* ```js
|
|
2482
|
+
* import { readFileSync } from 'fs';
|
|
2483
|
+
*
|
|
2484
|
+
* // macOS, Linux, and Windows
|
|
2485
|
+
* readFileSync('<directory>');
|
|
2486
|
+
* // => [Error: EISDIR: illegal operation on a directory, read <directory>]
|
|
2487
|
+
*
|
|
2488
|
+
* // FreeBSD
|
|
2489
|
+
* readFileSync('<directory>'); // => <data>
|
|
2490
|
+
* ```
|
|
2491
|
+
* @since v0.1.8
|
|
2492
|
+
* @param path filename or file descriptor
|
|
2493
|
+
*/
|
|
2494
|
+
export function readFileSync(
|
|
2495
|
+
path: PathOrFileDescriptor,
|
|
2496
|
+
options?: {
|
|
2497
|
+
encoding?: null | undefined;
|
|
2498
|
+
flag?: string | undefined;
|
|
2499
|
+
} | null
|
|
2500
|
+
): Buffer;
|
|
1647
2501
|
/**
|
|
1648
2502
|
* Synchronously reads the entire contents of a file.
|
|
1649
2503
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1651,8 +2505,15 @@ declare module 'fs' {
|
|
|
1651
2505
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1652
2506
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1653
2507
|
*/
|
|
1654
|
-
export function readFileSync(
|
|
1655
|
-
|
|
2508
|
+
export function readFileSync(
|
|
2509
|
+
path: PathOrFileDescriptor,
|
|
2510
|
+
options:
|
|
2511
|
+
| {
|
|
2512
|
+
encoding: BufferEncoding;
|
|
2513
|
+
flag?: string | undefined;
|
|
2514
|
+
}
|
|
2515
|
+
| BufferEncoding
|
|
2516
|
+
): string;
|
|
1656
2517
|
/**
|
|
1657
2518
|
* Synchronously reads the entire contents of a file.
|
|
1658
2519
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1660,23 +2521,87 @@ declare module 'fs' {
|
|
|
1660
2521
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1661
2522
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1662
2523
|
*/
|
|
1663
|
-
export function readFileSync(
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
2524
|
+
export function readFileSync(
|
|
2525
|
+
path: PathOrFileDescriptor,
|
|
2526
|
+
options?:
|
|
2527
|
+
| (ObjectEncodingOptions & {
|
|
2528
|
+
flag?: string | undefined;
|
|
2529
|
+
})
|
|
2530
|
+
| BufferEncoding
|
|
2531
|
+
| null
|
|
2532
|
+
): string | Buffer;
|
|
2533
|
+
export type WriteFileOptions =
|
|
2534
|
+
| (ObjectEncodingOptions &
|
|
2535
|
+
Abortable & {
|
|
2536
|
+
mode?: Mode | undefined;
|
|
2537
|
+
flag?: string | undefined;
|
|
2538
|
+
})
|
|
2539
|
+
| BufferEncoding
|
|
2540
|
+
| null;
|
|
2541
|
+
/**
|
|
2542
|
+
* When `file` is a filename, asynchronously writes data to the file, replacing the
|
|
2543
|
+
* file if it already exists. `data` can be a string or a buffer.
|
|
2544
|
+
*
|
|
2545
|
+
* When `file` is a file descriptor, the behavior is similar to calling`fs.write()` directly (which is recommended). See the notes below on using
|
|
2546
|
+
* a file descriptor.
|
|
2547
|
+
*
|
|
2548
|
+
* The `encoding` option is ignored if `data` is a buffer.
|
|
2549
|
+
*
|
|
2550
|
+
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2551
|
+
*
|
|
2552
|
+
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2553
|
+
*
|
|
2554
|
+
* ```js
|
|
2555
|
+
* import { writeFile } from 'fs';
|
|
2556
|
+
* import { Buffer } from 'buffer';
|
|
2557
|
+
*
|
|
2558
|
+
* const data = new Uint8Array(Buffer.from('Hello Node.js'));
|
|
2559
|
+
* writeFile('message.txt', data, (err) => {
|
|
2560
|
+
* if (err) throw err;
|
|
2561
|
+
* console.log('The file has been saved!');
|
|
2562
|
+
* });
|
|
2563
|
+
* ```
|
|
2564
|
+
*
|
|
2565
|
+
* If `options` is a string, then it specifies the encoding:
|
|
2566
|
+
*
|
|
2567
|
+
* ```js
|
|
2568
|
+
* import { writeFile } from 'fs';
|
|
2569
|
+
*
|
|
2570
|
+
* writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
|
|
2571
|
+
* ```
|
|
2572
|
+
*
|
|
2573
|
+
* It is unsafe to use `fs.writeFile()` multiple times on the same file without
|
|
2574
|
+
* waiting for the callback. For this scenario, {@link createWriteStream} is
|
|
2575
|
+
* recommended.
|
|
2576
|
+
*
|
|
2577
|
+
* Similarly to `fs.readFile` \- `fs.writeFile` is a convenience method that
|
|
2578
|
+
* performs multiple `write` calls internally to write the buffer passed to it.
|
|
2579
|
+
* For performance sensitive code consider using {@link createWriteStream}.
|
|
2580
|
+
*
|
|
2581
|
+
* It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`.
|
|
2582
|
+
* Cancelation is "best effort", and some amount of data is likely still
|
|
2583
|
+
* to be written.
|
|
2584
|
+
*
|
|
2585
|
+
* ```js
|
|
2586
|
+
* import { writeFile } from 'fs';
|
|
2587
|
+
* import { Buffer } from 'buffer';
|
|
2588
|
+
*
|
|
2589
|
+
* const controller = new AbortController();
|
|
2590
|
+
* const { signal } = controller;
|
|
2591
|
+
* const data = new Uint8Array(Buffer.from('Hello Node.js'));
|
|
2592
|
+
* writeFile('message.txt', data, { signal }, (err) => {
|
|
2593
|
+
* // When a request is aborted - the callback is called with an AbortError
|
|
2594
|
+
* });
|
|
2595
|
+
* // When the request should be aborted
|
|
2596
|
+
* controller.abort();
|
|
2597
|
+
* ```
|
|
2598
|
+
*
|
|
2599
|
+
* Aborting an ongoing request does not abort individual operating
|
|
2600
|
+
* system requests but rather the internal buffering `fs.writeFile` performs.
|
|
2601
|
+
* @since v0.1.29
|
|
2602
|
+
* @param file filename or file descriptor
|
|
2603
|
+
*/
|
|
2604
|
+
export function writeFile(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
1680
2605
|
/**
|
|
1681
2606
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
1682
2607
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1684,8 +2609,6 @@ declare module 'fs' {
|
|
|
1684
2609
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
|
1685
2610
|
*/
|
|
1686
2611
|
export function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
|
|
1687
|
-
|
|
1688
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1689
2612
|
export namespace writeFile {
|
|
1690
2613
|
/**
|
|
1691
2614
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
@@ -1701,33 +2624,73 @@ declare module 'fs' {
|
|
|
1701
2624
|
*/
|
|
1702
2625
|
function __promisify__(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
|
|
1703
2626
|
}
|
|
1704
|
-
|
|
1705
2627
|
/**
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1708
|
-
* If
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
*
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
/**
|
|
1719
|
-
* Asynchronously append data to a file, creating the file if it does not
|
|
1720
|
-
*
|
|
1721
|
-
*
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1725
|
-
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
2628
|
+
* Returns `undefined`.
|
|
2629
|
+
*
|
|
2630
|
+
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2631
|
+
*
|
|
2632
|
+
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2633
|
+
*
|
|
2634
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
2635
|
+
* this API: {@link writeFile}.
|
|
2636
|
+
* @since v0.1.29
|
|
2637
|
+
* @param file filename or file descriptor
|
|
2638
|
+
*/
|
|
2639
|
+
export function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
|
|
2640
|
+
/**
|
|
2641
|
+
* Asynchronously append data to a file, creating the file if it does not yet
|
|
2642
|
+
* exist. `data` can be a string or a `Buffer`.
|
|
2643
|
+
*
|
|
2644
|
+
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2645
|
+
*
|
|
2646
|
+
* ```js
|
|
2647
|
+
* import { appendFile } from 'fs';
|
|
2648
|
+
*
|
|
2649
|
+
* appendFile('message.txt', 'data to append', (err) => {
|
|
2650
|
+
* if (err) throw err;
|
|
2651
|
+
* console.log('The "data to append" was appended to file!');
|
|
2652
|
+
* });
|
|
2653
|
+
* ```
|
|
2654
|
+
*
|
|
2655
|
+
* If `options` is a string, then it specifies the encoding:
|
|
2656
|
+
*
|
|
2657
|
+
* ```js
|
|
2658
|
+
* import { appendFile } from 'fs';
|
|
2659
|
+
*
|
|
2660
|
+
* appendFile('message.txt', 'data to append', 'utf8', callback);
|
|
2661
|
+
* ```
|
|
2662
|
+
*
|
|
2663
|
+
* The `path` may be specified as a numeric file descriptor that has been opened
|
|
2664
|
+
* for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
|
|
2665
|
+
* not be closed automatically.
|
|
2666
|
+
*
|
|
2667
|
+
* ```js
|
|
2668
|
+
* import { open, close, appendFile } from 'fs';
|
|
2669
|
+
*
|
|
2670
|
+
* function closeFd(fd) {
|
|
2671
|
+
* close(fd, (err) => {
|
|
2672
|
+
* if (err) throw err;
|
|
2673
|
+
* });
|
|
2674
|
+
* }
|
|
2675
|
+
*
|
|
2676
|
+
* open('message.txt', 'a', (err, fd) => {
|
|
2677
|
+
* if (err) throw err;
|
|
2678
|
+
*
|
|
2679
|
+
* try {
|
|
2680
|
+
* appendFile(fd, 'data to append', 'utf8', (err) => {
|
|
2681
|
+
* closeFd(fd);
|
|
2682
|
+
* if (err) throw err;
|
|
2683
|
+
* });
|
|
2684
|
+
* } catch (err) {
|
|
2685
|
+
* closeFd(fd);
|
|
2686
|
+
* throw err;
|
|
2687
|
+
* }
|
|
2688
|
+
* });
|
|
2689
|
+
* ```
|
|
2690
|
+
* @since v0.6.7
|
|
2691
|
+
* @param path filename or file descriptor
|
|
2692
|
+
*/
|
|
2693
|
+
export function appendFile(path: PathOrFileDescriptor, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
1731
2694
|
/**
|
|
1732
2695
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
|
1733
2696
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1735,8 +2698,6 @@ declare module 'fs' {
|
|
|
1735
2698
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
|
1736
2699
|
*/
|
|
1737
2700
|
export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
|
|
1738
|
-
|
|
1739
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
1740
2701
|
export namespace appendFile {
|
|
1741
2702
|
/**
|
|
1742
2703
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
|
@@ -1752,55 +2713,177 @@ declare module 'fs' {
|
|
|
1752
2713
|
*/
|
|
1753
2714
|
function __promisify__(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
|
|
1754
2715
|
}
|
|
1755
|
-
|
|
1756
2716
|
/**
|
|
1757
|
-
* Synchronously append data to a file, creating the file if it does not
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
1761
|
-
*
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1765
|
-
*
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
*
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
2717
|
+
* Synchronously append data to a file, creating the file if it does not yet
|
|
2718
|
+
* exist. `data` can be a string or a `Buffer`.
|
|
2719
|
+
*
|
|
2720
|
+
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2721
|
+
*
|
|
2722
|
+
* ```js
|
|
2723
|
+
* import { appendFileSync } from 'fs';
|
|
2724
|
+
*
|
|
2725
|
+
* try {
|
|
2726
|
+
* appendFileSync('message.txt', 'data to append');
|
|
2727
|
+
* console.log('The "data to append" was appended to file!');
|
|
2728
|
+
* } catch (err) {
|
|
2729
|
+
* // Handle the error
|
|
2730
|
+
* }
|
|
2731
|
+
* ```
|
|
2732
|
+
*
|
|
2733
|
+
* If `options` is a string, then it specifies the encoding:
|
|
2734
|
+
*
|
|
2735
|
+
* ```js
|
|
2736
|
+
* import { appendFileSync } from 'fs';
|
|
2737
|
+
*
|
|
2738
|
+
* appendFileSync('message.txt', 'data to append', 'utf8');
|
|
2739
|
+
* ```
|
|
2740
|
+
*
|
|
2741
|
+
* The `path` may be specified as a numeric file descriptor that has been opened
|
|
2742
|
+
* for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
|
|
2743
|
+
* not be closed automatically.
|
|
2744
|
+
*
|
|
2745
|
+
* ```js
|
|
2746
|
+
* import { openSync, closeSync, appendFileSync } from 'fs';
|
|
2747
|
+
*
|
|
2748
|
+
* let fd;
|
|
2749
|
+
*
|
|
2750
|
+
* try {
|
|
2751
|
+
* fd = openSync('message.txt', 'a');
|
|
2752
|
+
* appendFileSync(fd, 'data to append', 'utf8');
|
|
2753
|
+
* } catch (err) {
|
|
2754
|
+
* // Handle the error
|
|
2755
|
+
* } finally {
|
|
2756
|
+
* if (fd !== undefined)
|
|
2757
|
+
* closeSync(fd);
|
|
2758
|
+
* }
|
|
2759
|
+
* ```
|
|
2760
|
+
* @since v0.6.7
|
|
2761
|
+
* @param path filename or file descriptor
|
|
2762
|
+
*/
|
|
2763
|
+
export function appendFileSync(path: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): void;
|
|
2764
|
+
/**
|
|
2765
|
+
* Watch for changes on `filename`. The callback `listener` will be called each
|
|
2766
|
+
* time the file is accessed.
|
|
2767
|
+
*
|
|
2768
|
+
* The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates
|
|
2769
|
+
* whether the process should continue to run as long as files are being watched.
|
|
2770
|
+
* The `options` object may specify an `interval` property indicating how often the
|
|
2771
|
+
* target should be polled in milliseconds.
|
|
2772
|
+
*
|
|
2773
|
+
* The `listener` gets two arguments the current stat object and the previous
|
|
2774
|
+
* stat object:
|
|
2775
|
+
*
|
|
2776
|
+
* ```js
|
|
2777
|
+
* import { watchFile } from 'fs';
|
|
2778
|
+
*
|
|
2779
|
+
* watchFile('message.text', (curr, prev) => {
|
|
2780
|
+
* console.log(`the current mtime is: ${curr.mtime}`);
|
|
2781
|
+
* console.log(`the previous mtime was: ${prev.mtime}`);
|
|
2782
|
+
* });
|
|
2783
|
+
* ```
|
|
2784
|
+
*
|
|
2785
|
+
* These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
|
|
2786
|
+
* the numeric values in these objects are specified as `BigInt`s.
|
|
2787
|
+
*
|
|
2788
|
+
* To be notified when the file was modified, not just accessed, it is necessary
|
|
2789
|
+
* to compare `curr.mtimeMs` and `prev.mtimeMs`.
|
|
2790
|
+
*
|
|
2791
|
+
* When an `fs.watchFile` operation results in an `ENOENT` error, it
|
|
2792
|
+
* will invoke the listener once, with all the fields zeroed (or, for dates, the
|
|
2793
|
+
* Unix Epoch). If the file is created later on, the listener will be called
|
|
2794
|
+
* again, with the latest stat objects. This is a change in functionality since
|
|
2795
|
+
* v0.10.
|
|
2796
|
+
*
|
|
2797
|
+
* Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible.
|
|
2798
|
+
*
|
|
2799
|
+
* When a file being watched by `fs.watchFile()` disappears and reappears,
|
|
2800
|
+
* then the contents of `previous` in the second callback event (the file's
|
|
2801
|
+
* reappearance) will be the same as the contents of `previous` in the first
|
|
2802
|
+
* callback event (its disappearance).
|
|
2803
|
+
*
|
|
2804
|
+
* This happens when:
|
|
2805
|
+
*
|
|
2806
|
+
* * the file is deleted, followed by a restore
|
|
2807
|
+
* * the file is renamed and then renamed a second time back to its original name
|
|
2808
|
+
* @since v0.1.31
|
|
2809
|
+
*/
|
|
2810
|
+
export interface WatchFileOptions {
|
|
2811
|
+
bigint?: boolean | undefined;
|
|
2812
|
+
persistent?: boolean | undefined;
|
|
2813
|
+
interval?: number | undefined;
|
|
2814
|
+
}
|
|
2815
|
+
export function watchFile(
|
|
2816
|
+
filename: PathLike,
|
|
2817
|
+
options:
|
|
2818
|
+
| (WatchFileOptions & {
|
|
2819
|
+
bigint?: false | undefined;
|
|
2820
|
+
})
|
|
2821
|
+
| undefined,
|
|
2822
|
+
listener: (curr: Stats, prev: Stats) => void
|
|
2823
|
+
): StatWatcher;
|
|
2824
|
+
export function watchFile(
|
|
2825
|
+
filename: PathLike,
|
|
2826
|
+
options:
|
|
2827
|
+
| (WatchFileOptions & {
|
|
2828
|
+
bigint: true;
|
|
2829
|
+
})
|
|
2830
|
+
| undefined,
|
|
2831
|
+
listener: (curr: BigIntStats, prev: BigIntStats) => void
|
|
2832
|
+
): StatWatcher;
|
|
1774
2833
|
/**
|
|
1775
2834
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
|
|
1776
2835
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
1777
2836
|
*/
|
|
1778
|
-
export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void):
|
|
1779
|
-
|
|
2837
|
+
export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): StatWatcher;
|
|
1780
2838
|
/**
|
|
1781
|
-
* Stop watching for changes on `filename`.
|
|
1782
|
-
*
|
|
2839
|
+
* Stop watching for changes on `filename`. If `listener` is specified, only that
|
|
2840
|
+
* particular listener is removed. Otherwise, _all_ listeners are removed,
|
|
2841
|
+
* effectively stopping watching of `filename`.
|
|
2842
|
+
*
|
|
2843
|
+
* Calling `fs.unwatchFile()` with a filename that is not being watched is a
|
|
2844
|
+
* no-op, not an error.
|
|
2845
|
+
*
|
|
2846
|
+
* Using {@link watch} is more efficient than `fs.watchFile()` and`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`and `fs.unwatchFile()` when possible.
|
|
2847
|
+
* @since v0.1.31
|
|
2848
|
+
* @param listener Optional, a listener previously attached using `fs.watchFile()`
|
|
1783
2849
|
*/
|
|
1784
2850
|
export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
|
1785
|
-
|
|
1786
2851
|
export interface WatchOptions extends Abortable {
|
|
1787
|
-
encoding?: BufferEncoding |
|
|
2852
|
+
encoding?: BufferEncoding | 'buffer' | undefined;
|
|
1788
2853
|
persistent?: boolean | undefined;
|
|
1789
2854
|
recursive?: boolean | undefined;
|
|
1790
2855
|
}
|
|
1791
|
-
|
|
1792
|
-
export type WatchListener<T> = (event:
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
*
|
|
1796
|
-
*
|
|
1797
|
-
*
|
|
1798
|
-
*
|
|
1799
|
-
*
|
|
1800
|
-
*
|
|
2856
|
+
export type WatchEventType = 'rename' | 'change';
|
|
2857
|
+
export type WatchListener<T> = (event: WatchEventType, filename: T) => void;
|
|
2858
|
+
/**
|
|
2859
|
+
* Watch for changes on `filename`, where `filename` is either a file or a
|
|
2860
|
+
* directory.
|
|
2861
|
+
*
|
|
2862
|
+
* The second argument is optional. If `options` is provided as a string, it
|
|
2863
|
+
* specifies the `encoding`. Otherwise `options` should be passed as an object.
|
|
2864
|
+
*
|
|
2865
|
+
* The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file
|
|
2866
|
+
* which triggered the event.
|
|
2867
|
+
*
|
|
2868
|
+
* On most platforms, `'rename'` is emitted whenever a filename appears or
|
|
2869
|
+
* disappears in the directory.
|
|
2870
|
+
*
|
|
2871
|
+
* The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`.
|
|
2872
|
+
*
|
|
2873
|
+
* If a `signal` is passed, aborting the corresponding AbortController will close
|
|
2874
|
+
* the returned `fs.FSWatcher`.
|
|
2875
|
+
* @since v0.5.10
|
|
2876
|
+
* @param listener
|
|
1801
2877
|
*/
|
|
1802
|
-
export function watch(
|
|
1803
|
-
|
|
2878
|
+
export function watch(
|
|
2879
|
+
filename: PathLike,
|
|
2880
|
+
options:
|
|
2881
|
+
| (WatchOptions & {
|
|
2882
|
+
encoding: 'buffer';
|
|
2883
|
+
})
|
|
2884
|
+
| 'buffer',
|
|
2885
|
+
listener?: WatchListener<Buffer>
|
|
2886
|
+
): FSWatcher;
|
|
1804
2887
|
/**
|
|
1805
2888
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1806
2889
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1809,12 +2892,7 @@ declare module 'fs' {
|
|
|
1809
2892
|
* If `persistent` is not supplied, the default of `true` is used.
|
|
1810
2893
|
* If `recursive` is not supplied, the default of `false` is used.
|
|
1811
2894
|
*/
|
|
1812
|
-
export function watch(
|
|
1813
|
-
filename: PathLike,
|
|
1814
|
-
options?: WatchOptions | BufferEncoding | null,
|
|
1815
|
-
listener?: WatchListener<string>,
|
|
1816
|
-
): FSWatcher;
|
|
1817
|
-
|
|
2895
|
+
export function watch(filename: PathLike, options?: WatchOptions | BufferEncoding | null, listener?: WatchListener<string>): FSWatcher;
|
|
1818
2896
|
/**
|
|
1819
2897
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1820
2898
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1824,21 +2902,142 @@ declare module 'fs' {
|
|
|
1824
2902
|
* If `recursive` is not supplied, the default of `false` is used.
|
|
1825
2903
|
*/
|
|
1826
2904
|
export function watch(filename: PathLike, options: WatchOptions | string, listener?: WatchListener<string | Buffer>): FSWatcher;
|
|
1827
|
-
|
|
1828
2905
|
/**
|
|
1829
2906
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1830
2907
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
1831
2908
|
*/
|
|
1832
2909
|
export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
|
|
1833
|
-
|
|
1834
2910
|
/**
|
|
1835
|
-
*
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
2911
|
+
* Test whether or not the given path exists by checking with the file system.
|
|
2912
|
+
* Then call the `callback` argument with either true or false:
|
|
2913
|
+
*
|
|
2914
|
+
* ```js
|
|
2915
|
+
* import { exists } from 'fs';
|
|
2916
|
+
*
|
|
2917
|
+
* exists('/etc/passwd', (e) => {
|
|
2918
|
+
* console.log(e ? 'it exists' : 'no passwd!');
|
|
2919
|
+
* });
|
|
2920
|
+
* ```
|
|
2921
|
+
*
|
|
2922
|
+
* **The parameters for this callback are not consistent with other Node.js**
|
|
2923
|
+
* **callbacks.** Normally, the first parameter to a Node.js callback is an `err`parameter, optionally followed by other parameters. The `fs.exists()` callback
|
|
2924
|
+
* has only one boolean parameter. This is one reason `fs.access()` is recommended
|
|
2925
|
+
* instead of `fs.exists()`.
|
|
2926
|
+
*
|
|
2927
|
+
* Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing
|
|
2928
|
+
* so introduces a race condition, since other processes may change the file's
|
|
2929
|
+
* state between the two calls. Instead, user code should open/read/write the
|
|
2930
|
+
* file directly and handle the error raised if the file does not exist.
|
|
2931
|
+
*
|
|
2932
|
+
* **write (NOT RECOMMENDED)**
|
|
2933
|
+
*
|
|
2934
|
+
* ```js
|
|
2935
|
+
* import { exists, open, close } from 'fs';
|
|
2936
|
+
*
|
|
2937
|
+
* exists('myfile', (e) => {
|
|
2938
|
+
* if (e) {
|
|
2939
|
+
* console.error('myfile already exists');
|
|
2940
|
+
* } else {
|
|
2941
|
+
* open('myfile', 'wx', (err, fd) => {
|
|
2942
|
+
* if (err) throw err;
|
|
2943
|
+
*
|
|
2944
|
+
* try {
|
|
2945
|
+
* writeMyData(fd);
|
|
2946
|
+
* } finally {
|
|
2947
|
+
* close(fd, (err) => {
|
|
2948
|
+
* if (err) throw err;
|
|
2949
|
+
* });
|
|
2950
|
+
* }
|
|
2951
|
+
* });
|
|
2952
|
+
* }
|
|
2953
|
+
* });
|
|
2954
|
+
* ```
|
|
2955
|
+
*
|
|
2956
|
+
* **write (RECOMMENDED)**
|
|
2957
|
+
*
|
|
2958
|
+
* ```js
|
|
2959
|
+
* import { open, close } from 'fs';
|
|
2960
|
+
* open('myfile', 'wx', (err, fd) => {
|
|
2961
|
+
* if (err) {
|
|
2962
|
+
* if (err.code === 'EEXIST') {
|
|
2963
|
+
* console.error('myfile already exists');
|
|
2964
|
+
* return;
|
|
2965
|
+
* }
|
|
2966
|
+
*
|
|
2967
|
+
* throw err;
|
|
2968
|
+
* }
|
|
2969
|
+
*
|
|
2970
|
+
* try {
|
|
2971
|
+
* writeMyData(fd);
|
|
2972
|
+
* } finally {
|
|
2973
|
+
* close(fd, (err) => {
|
|
2974
|
+
* if (err) throw err;
|
|
2975
|
+
* });
|
|
2976
|
+
* }
|
|
2977
|
+
* });
|
|
2978
|
+
* ```
|
|
2979
|
+
*
|
|
2980
|
+
* **read (NOT RECOMMENDED)**
|
|
2981
|
+
*
|
|
2982
|
+
* ```js
|
|
2983
|
+
* import { open, close, exists } from 'fs';
|
|
2984
|
+
*
|
|
2985
|
+
* exists('myfile', (e) => {
|
|
2986
|
+
* if (e) {
|
|
2987
|
+
* open('myfile', 'r', (err, fd) => {
|
|
2988
|
+
* if (err) throw err;
|
|
2989
|
+
*
|
|
2990
|
+
* try {
|
|
2991
|
+
* readMyData(fd);
|
|
2992
|
+
* } finally {
|
|
2993
|
+
* close(fd, (err) => {
|
|
2994
|
+
* if (err) throw err;
|
|
2995
|
+
* });
|
|
2996
|
+
* }
|
|
2997
|
+
* });
|
|
2998
|
+
* } else {
|
|
2999
|
+
* console.error('myfile does not exist');
|
|
3000
|
+
* }
|
|
3001
|
+
* });
|
|
3002
|
+
* ```
|
|
3003
|
+
*
|
|
3004
|
+
* **read (RECOMMENDED)**
|
|
3005
|
+
*
|
|
3006
|
+
* ```js
|
|
3007
|
+
* import { open, close } from 'fs';
|
|
3008
|
+
*
|
|
3009
|
+
* open('myfile', 'r', (err, fd) => {
|
|
3010
|
+
* if (err) {
|
|
3011
|
+
* if (err.code === 'ENOENT') {
|
|
3012
|
+
* console.error('myfile does not exist');
|
|
3013
|
+
* return;
|
|
3014
|
+
* }
|
|
3015
|
+
*
|
|
3016
|
+
* throw err;
|
|
3017
|
+
* }
|
|
3018
|
+
*
|
|
3019
|
+
* try {
|
|
3020
|
+
* readMyData(fd);
|
|
3021
|
+
* } finally {
|
|
3022
|
+
* close(fd, (err) => {
|
|
3023
|
+
* if (err) throw err;
|
|
3024
|
+
* });
|
|
3025
|
+
* }
|
|
3026
|
+
* });
|
|
3027
|
+
* ```
|
|
3028
|
+
*
|
|
3029
|
+
* The "not recommended" examples above check for existence and then use the
|
|
3030
|
+
* file; the "recommended" examples are better because they use the file directly
|
|
3031
|
+
* and handle the error, if any.
|
|
3032
|
+
*
|
|
3033
|
+
* In general, check for the existence of a file only if the file won’t be
|
|
3034
|
+
* used directly, for example when its existence is a signal from another
|
|
3035
|
+
* process.
|
|
3036
|
+
* @since v0.0.2
|
|
3037
|
+
* @deprecated Since v1.0.0 - Use {@link stat} or {@link access} instead.
|
|
1838
3038
|
*/
|
|
1839
3039
|
export function exists(path: PathLike, callback: (exists: boolean) => void): void;
|
|
1840
|
-
|
|
1841
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
3040
|
+
/** @deprecated */
|
|
1842
3041
|
export namespace exists {
|
|
1843
3042
|
/**
|
|
1844
3043
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1846,78 +3045,70 @@ declare module 'fs' {
|
|
|
1846
3045
|
*/
|
|
1847
3046
|
function __promisify__(path: PathLike): Promise<boolean>;
|
|
1848
3047
|
}
|
|
1849
|
-
|
|
1850
3048
|
/**
|
|
1851
|
-
*
|
|
1852
|
-
*
|
|
3049
|
+
* Returns `true` if the path exists, `false` otherwise.
|
|
3050
|
+
*
|
|
3051
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
3052
|
+
* this API: {@link exists}.
|
|
3053
|
+
*
|
|
3054
|
+
* `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`parameter to `fs.exists()` accepts parameters that are inconsistent with other
|
|
3055
|
+
* Node.js callbacks. `fs.existsSync()` does not use a callback.
|
|
3056
|
+
*
|
|
3057
|
+
* ```js
|
|
3058
|
+
* import { existsSync } from 'fs';
|
|
3059
|
+
*
|
|
3060
|
+
* if (existsSync('/etc/passwd'))
|
|
3061
|
+
* console.log('The path exists.');
|
|
3062
|
+
* ```
|
|
3063
|
+
* @since v0.1.21
|
|
1853
3064
|
*/
|
|
1854
3065
|
export function existsSync(path: PathLike): boolean;
|
|
1855
|
-
|
|
1856
3066
|
export namespace constants {
|
|
1857
3067
|
// File Access Constants
|
|
1858
|
-
|
|
1859
3068
|
/** Constant for fs.access(). File is visible to the calling process. */
|
|
1860
3069
|
const F_OK: number;
|
|
1861
|
-
|
|
1862
3070
|
/** Constant for fs.access(). File can be read by the calling process. */
|
|
1863
3071
|
const R_OK: number;
|
|
1864
|
-
|
|
1865
3072
|
/** Constant for fs.access(). File can be written by the calling process. */
|
|
1866
3073
|
const W_OK: number;
|
|
1867
|
-
|
|
1868
3074
|
/** Constant for fs.access(). File can be executed by the calling process. */
|
|
1869
3075
|
const X_OK: number;
|
|
1870
|
-
|
|
1871
3076
|
// File Copy Constants
|
|
1872
|
-
|
|
1873
3077
|
/** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
|
|
1874
3078
|
const COPYFILE_EXCL: number;
|
|
1875
|
-
|
|
1876
3079
|
/**
|
|
1877
3080
|
* Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink.
|
|
1878
3081
|
* If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
|
|
1879
3082
|
*/
|
|
1880
3083
|
const COPYFILE_FICLONE: number;
|
|
1881
|
-
|
|
1882
3084
|
/**
|
|
1883
3085
|
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
|
|
1884
3086
|
* If the underlying platform does not support copy-on-write, then the operation will fail with an error.
|
|
1885
3087
|
*/
|
|
1886
3088
|
const COPYFILE_FICLONE_FORCE: number;
|
|
1887
|
-
|
|
1888
3089
|
// File Open Constants
|
|
1889
|
-
|
|
1890
3090
|
/** Constant for fs.open(). Flag indicating to open a file for read-only access. */
|
|
1891
3091
|
const O_RDONLY: number;
|
|
1892
|
-
|
|
1893
3092
|
/** Constant for fs.open(). Flag indicating to open a file for write-only access. */
|
|
1894
3093
|
const O_WRONLY: number;
|
|
1895
|
-
|
|
1896
3094
|
/** Constant for fs.open(). Flag indicating to open a file for read-write access. */
|
|
1897
3095
|
const O_RDWR: number;
|
|
1898
|
-
|
|
1899
3096
|
/** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
|
|
1900
3097
|
const O_CREAT: number;
|
|
1901
|
-
|
|
1902
3098
|
/** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
|
|
1903
3099
|
const O_EXCL: number;
|
|
1904
|
-
|
|
1905
3100
|
/**
|
|
1906
3101
|
* Constant for fs.open(). Flag indicating that if path identifies a terminal device,
|
|
1907
3102
|
* opening the path shall not cause that terminal to become the controlling terminal for the process
|
|
1908
3103
|
* (if the process does not already have one).
|
|
1909
3104
|
*/
|
|
1910
3105
|
const O_NOCTTY: number;
|
|
1911
|
-
|
|
1912
3106
|
/** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
|
|
1913
3107
|
const O_TRUNC: number;
|
|
1914
|
-
|
|
1915
3108
|
/** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
|
|
1916
3109
|
const O_APPEND: number;
|
|
1917
|
-
|
|
1918
3110
|
/** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
|
|
1919
3111
|
const O_DIRECTORY: number;
|
|
1920
|
-
|
|
1921
3112
|
/**
|
|
1922
3113
|
* constant for fs.open().
|
|
1923
3114
|
* Flag indicating reading accesses to the file system will no longer result in
|
|
@@ -1925,89 +3116,60 @@ declare module 'fs' {
|
|
|
1925
3116
|
* This flag is available on Linux operating systems only.
|
|
1926
3117
|
*/
|
|
1927
3118
|
const O_NOATIME: number;
|
|
1928
|
-
|
|
1929
3119
|
/** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
|
|
1930
3120
|
const O_NOFOLLOW: number;
|
|
1931
|
-
|
|
1932
3121
|
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
|
|
1933
3122
|
const O_SYNC: number;
|
|
1934
|
-
|
|
1935
3123
|
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
|
|
1936
3124
|
const O_DSYNC: number;
|
|
1937
|
-
|
|
1938
3125
|
/** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
|
|
1939
3126
|
const O_SYMLINK: number;
|
|
1940
|
-
|
|
1941
3127
|
/** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
|
|
1942
3128
|
const O_DIRECT: number;
|
|
1943
|
-
|
|
1944
3129
|
/** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
|
|
1945
3130
|
const O_NONBLOCK: number;
|
|
1946
|
-
|
|
1947
3131
|
// File Type Constants
|
|
1948
|
-
|
|
1949
3132
|
/** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
|
|
1950
3133
|
const S_IFMT: number;
|
|
1951
|
-
|
|
1952
3134
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
|
|
1953
3135
|
const S_IFREG: number;
|
|
1954
|
-
|
|
1955
3136
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
|
|
1956
3137
|
const S_IFDIR: number;
|
|
1957
|
-
|
|
1958
3138
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
|
|
1959
3139
|
const S_IFCHR: number;
|
|
1960
|
-
|
|
1961
3140
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
|
|
1962
3141
|
const S_IFBLK: number;
|
|
1963
|
-
|
|
1964
3142
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
|
|
1965
3143
|
const S_IFIFO: number;
|
|
1966
|
-
|
|
1967
3144
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
|
|
1968
3145
|
const S_IFLNK: number;
|
|
1969
|
-
|
|
1970
3146
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
|
|
1971
3147
|
const S_IFSOCK: number;
|
|
1972
|
-
|
|
1973
3148
|
// File Mode Constants
|
|
1974
|
-
|
|
1975
3149
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
|
|
1976
3150
|
const S_IRWXU: number;
|
|
1977
|
-
|
|
1978
3151
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
|
|
1979
3152
|
const S_IRUSR: number;
|
|
1980
|
-
|
|
1981
3153
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
|
|
1982
3154
|
const S_IWUSR: number;
|
|
1983
|
-
|
|
1984
3155
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
|
|
1985
3156
|
const S_IXUSR: number;
|
|
1986
|
-
|
|
1987
3157
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
|
|
1988
3158
|
const S_IRWXG: number;
|
|
1989
|
-
|
|
1990
3159
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
|
|
1991
3160
|
const S_IRGRP: number;
|
|
1992
|
-
|
|
1993
3161
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
|
|
1994
3162
|
const S_IWGRP: number;
|
|
1995
|
-
|
|
1996
3163
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
|
|
1997
3164
|
const S_IXGRP: number;
|
|
1998
|
-
|
|
1999
3165
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
|
|
2000
3166
|
const S_IRWXO: number;
|
|
2001
|
-
|
|
2002
3167
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
|
|
2003
3168
|
const S_IROTH: number;
|
|
2004
|
-
|
|
2005
3169
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
|
|
2006
3170
|
const S_IWOTH: number;
|
|
2007
|
-
|
|
2008
3171
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
|
|
2009
3172
|
const S_IXOTH: number;
|
|
2010
|
-
|
|
2011
3173
|
/**
|
|
2012
3174
|
* When set, a memory file mapping is used to access the file. This flag
|
|
2013
3175
|
* is available on Windows operating systems only. On other operating systems,
|
|
@@ -2015,20 +3177,177 @@ declare module 'fs' {
|
|
|
2015
3177
|
*/
|
|
2016
3178
|
const UV_FS_O_FILEMAP: number;
|
|
2017
3179
|
}
|
|
2018
|
-
|
|
2019
3180
|
/**
|
|
2020
|
-
*
|
|
2021
|
-
*
|
|
3181
|
+
* Tests a user's permissions for the file or directory specified by `path`.
|
|
3182
|
+
* The `mode` argument is an optional integer that specifies the accessibility
|
|
3183
|
+
* checks to be performed. Check `File access constants` for possible values
|
|
3184
|
+
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
|
3185
|
+
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
|
3186
|
+
*
|
|
3187
|
+
* The final argument, `callback`, is a callback function that is invoked with
|
|
3188
|
+
* a possible error argument. If any of the accessibility checks fail, the error
|
|
3189
|
+
* argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable.
|
|
3190
|
+
*
|
|
3191
|
+
* ```js
|
|
3192
|
+
* import { access, constants } from 'fs';
|
|
3193
|
+
*
|
|
3194
|
+
* const file = 'package.json';
|
|
3195
|
+
*
|
|
3196
|
+
* // Check if the file exists in the current directory.
|
|
3197
|
+
* access(file, constants.F_OK, (err) => {
|
|
3198
|
+
* console.log(`${file} ${err ? 'does not exist' : 'exists'}`);
|
|
3199
|
+
* });
|
|
3200
|
+
*
|
|
3201
|
+
* // Check if the file is readable.
|
|
3202
|
+
* access(file, constants.R_OK, (err) => {
|
|
3203
|
+
* console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);
|
|
3204
|
+
* });
|
|
3205
|
+
*
|
|
3206
|
+
* // Check if the file is writable.
|
|
3207
|
+
* access(file, constants.W_OK, (err) => {
|
|
3208
|
+
* console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
|
|
3209
|
+
* });
|
|
3210
|
+
*
|
|
3211
|
+
* // Check if the file exists in the current directory, and if it is writable.
|
|
3212
|
+
* access(file, constants.F_OK | constants.W_OK, (err) => {
|
|
3213
|
+
* if (err) {
|
|
3214
|
+
* console.error(
|
|
3215
|
+
* `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
|
|
3216
|
+
* } else {
|
|
3217
|
+
* console.log(`${file} exists, and it is writable`);
|
|
3218
|
+
* }
|
|
3219
|
+
* });
|
|
3220
|
+
* ```
|
|
3221
|
+
*
|
|
3222
|
+
* Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()`. Doing
|
|
3223
|
+
* so introduces a race condition, since other processes may change the file's
|
|
3224
|
+
* state between the two calls. Instead, user code should open/read/write the
|
|
3225
|
+
* file directly and handle the error raised if the file is not accessible.
|
|
3226
|
+
*
|
|
3227
|
+
* **write (NOT RECOMMENDED)**
|
|
3228
|
+
*
|
|
3229
|
+
* ```js
|
|
3230
|
+
* import { access, open, close } from 'fs';
|
|
3231
|
+
*
|
|
3232
|
+
* access('myfile', (err) => {
|
|
3233
|
+
* if (!err) {
|
|
3234
|
+
* console.error('myfile already exists');
|
|
3235
|
+
* return;
|
|
3236
|
+
* }
|
|
3237
|
+
*
|
|
3238
|
+
* open('myfile', 'wx', (err, fd) => {
|
|
3239
|
+
* if (err) throw err;
|
|
3240
|
+
*
|
|
3241
|
+
* try {
|
|
3242
|
+
* writeMyData(fd);
|
|
3243
|
+
* } finally {
|
|
3244
|
+
* close(fd, (err) => {
|
|
3245
|
+
* if (err) throw err;
|
|
3246
|
+
* });
|
|
3247
|
+
* }
|
|
3248
|
+
* });
|
|
3249
|
+
* });
|
|
3250
|
+
* ```
|
|
3251
|
+
*
|
|
3252
|
+
* **write (RECOMMENDED)**
|
|
3253
|
+
*
|
|
3254
|
+
* ```js
|
|
3255
|
+
* import { open, close } from 'fs';
|
|
3256
|
+
*
|
|
3257
|
+
* open('myfile', 'wx', (err, fd) => {
|
|
3258
|
+
* if (err) {
|
|
3259
|
+
* if (err.code === 'EEXIST') {
|
|
3260
|
+
* console.error('myfile already exists');
|
|
3261
|
+
* return;
|
|
3262
|
+
* }
|
|
3263
|
+
*
|
|
3264
|
+
* throw err;
|
|
3265
|
+
* }
|
|
3266
|
+
*
|
|
3267
|
+
* try {
|
|
3268
|
+
* writeMyData(fd);
|
|
3269
|
+
* } finally {
|
|
3270
|
+
* close(fd, (err) => {
|
|
3271
|
+
* if (err) throw err;
|
|
3272
|
+
* });
|
|
3273
|
+
* }
|
|
3274
|
+
* });
|
|
3275
|
+
* ```
|
|
3276
|
+
*
|
|
3277
|
+
* **read (NOT RECOMMENDED)**
|
|
3278
|
+
*
|
|
3279
|
+
* ```js
|
|
3280
|
+
* import { access, open, close } from 'fs';
|
|
3281
|
+
* access('myfile', (err) => {
|
|
3282
|
+
* if (err) {
|
|
3283
|
+
* if (err.code === 'ENOENT') {
|
|
3284
|
+
* console.error('myfile does not exist');
|
|
3285
|
+
* return;
|
|
3286
|
+
* }
|
|
3287
|
+
*
|
|
3288
|
+
* throw err;
|
|
3289
|
+
* }
|
|
3290
|
+
*
|
|
3291
|
+
* open('myfile', 'r', (err, fd) => {
|
|
3292
|
+
* if (err) throw err;
|
|
3293
|
+
*
|
|
3294
|
+
* try {
|
|
3295
|
+
* readMyData(fd);
|
|
3296
|
+
* } finally {
|
|
3297
|
+
* close(fd, (err) => {
|
|
3298
|
+
* if (err) throw err;
|
|
3299
|
+
* });
|
|
3300
|
+
* }
|
|
3301
|
+
* });
|
|
3302
|
+
* });
|
|
3303
|
+
* ```
|
|
3304
|
+
*
|
|
3305
|
+
* **read (RECOMMENDED)**
|
|
3306
|
+
*
|
|
3307
|
+
* ```js
|
|
3308
|
+
* import { open, close } from 'fs';
|
|
3309
|
+
*
|
|
3310
|
+
* open('myfile', 'r', (err, fd) => {
|
|
3311
|
+
* if (err) {
|
|
3312
|
+
* if (err.code === 'ENOENT') {
|
|
3313
|
+
* console.error('myfile does not exist');
|
|
3314
|
+
* return;
|
|
3315
|
+
* }
|
|
3316
|
+
*
|
|
3317
|
+
* throw err;
|
|
3318
|
+
* }
|
|
3319
|
+
*
|
|
3320
|
+
* try {
|
|
3321
|
+
* readMyData(fd);
|
|
3322
|
+
* } finally {
|
|
3323
|
+
* close(fd, (err) => {
|
|
3324
|
+
* if (err) throw err;
|
|
3325
|
+
* });
|
|
3326
|
+
* }
|
|
3327
|
+
* });
|
|
3328
|
+
* ```
|
|
3329
|
+
*
|
|
3330
|
+
* The "not recommended" examples above check for accessibility and then use the
|
|
3331
|
+
* file; the "recommended" examples are better because they use the file directly
|
|
3332
|
+
* and handle the error, if any.
|
|
3333
|
+
*
|
|
3334
|
+
* In general, check for the accessibility of a file only if the file will not be
|
|
3335
|
+
* used directly, for example when its accessibility is a signal from another
|
|
3336
|
+
* process.
|
|
3337
|
+
*
|
|
3338
|
+
* On Windows, access-control policies (ACLs) on a directory may limit access to
|
|
3339
|
+
* a file or directory. The `fs.access()` function, however, does not check the
|
|
3340
|
+
* ACL and therefore may report that a path is accessible even if the ACL restricts
|
|
3341
|
+
* the user from reading or writing to it.
|
|
3342
|
+
* @since v0.11.15
|
|
3343
|
+
* @param [mode=fs.constants.F_OK]
|
|
2022
3344
|
*/
|
|
2023
3345
|
export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
|
|
2024
|
-
|
|
2025
3346
|
/**
|
|
2026
3347
|
* Asynchronously tests a user's permissions for the file specified by path.
|
|
2027
3348
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
2028
3349
|
*/
|
|
2029
3350
|
export function access(path: PathLike, callback: NoParamCallback): void;
|
|
2030
|
-
|
|
2031
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
2032
3351
|
export namespace access {
|
|
2033
3352
|
/**
|
|
2034
3353
|
* Asynchronously tests a user's permissions for the file specified by path.
|
|
@@ -2037,13 +3356,31 @@ declare module 'fs' {
|
|
|
2037
3356
|
*/
|
|
2038
3357
|
function __promisify__(path: PathLike, mode?: number): Promise<void>;
|
|
2039
3358
|
}
|
|
2040
|
-
|
|
2041
3359
|
/**
|
|
2042
|
-
* Synchronously tests a user's permissions for the file
|
|
2043
|
-
*
|
|
3360
|
+
* Synchronously tests a user's permissions for the file or directory specified
|
|
3361
|
+
* by `path`. The `mode` argument is an optional integer that specifies the
|
|
3362
|
+
* accessibility checks to be performed. Check `File access constants` for
|
|
3363
|
+
* possible values of `mode`. It is possible to create a mask consisting of
|
|
3364
|
+
* the bitwise OR of two or more values
|
|
3365
|
+
* (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
|
3366
|
+
*
|
|
3367
|
+
* If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
|
|
3368
|
+
* the method will return `undefined`.
|
|
3369
|
+
*
|
|
3370
|
+
* ```js
|
|
3371
|
+
* import { accessSync, constants } from 'fs';
|
|
3372
|
+
*
|
|
3373
|
+
* try {
|
|
3374
|
+
* accessSync('etc/passwd', constants.R_OK | constants.W_OK);
|
|
3375
|
+
* console.log('can read/write');
|
|
3376
|
+
* } catch (err) {
|
|
3377
|
+
* console.error('no access!');
|
|
3378
|
+
* }
|
|
3379
|
+
* ```
|
|
3380
|
+
* @since v0.11.15
|
|
3381
|
+
* @param [mode=fs.constants.F_OK]
|
|
2044
3382
|
*/
|
|
2045
3383
|
export function accessSync(path: PathLike, mode?: number): void;
|
|
2046
|
-
|
|
2047
3384
|
interface StreamOptions {
|
|
2048
3385
|
flags?: string | undefined;
|
|
2049
3386
|
encoding?: BufferEncoding | undefined;
|
|
@@ -2057,30 +3394,110 @@ declare module 'fs' {
|
|
|
2057
3394
|
start?: number | undefined;
|
|
2058
3395
|
highWaterMark?: number | undefined;
|
|
2059
3396
|
}
|
|
2060
|
-
|
|
2061
3397
|
interface ReadStreamOptions extends StreamOptions {
|
|
2062
3398
|
end?: number | undefined;
|
|
2063
3399
|
}
|
|
2064
|
-
|
|
2065
3400
|
/**
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
*
|
|
2073
|
-
*
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
*
|
|
2079
|
-
*
|
|
3401
|
+
* Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
|
|
3402
|
+
* returned by this method has a default `highWaterMark` of 64 kb.
|
|
3403
|
+
*
|
|
3404
|
+
* `options` can include `start` and `end` values to read a range of bytes from
|
|
3405
|
+
* the file instead of the entire file. Both `start` and `end` are inclusive and
|
|
3406
|
+
* start counting at 0, allowed values are in the
|
|
3407
|
+
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `fd` is specified and `start` is
|
|
3408
|
+
* omitted or `undefined`, `fs.createReadStream()` reads sequentially from the
|
|
3409
|
+
* current file position. The `encoding` can be any one of those accepted by `Buffer`.
|
|
3410
|
+
*
|
|
3411
|
+
* If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
|
|
3412
|
+
* the specified file descriptor. This means that no `'open'` event will be
|
|
3413
|
+
* emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `net.Socket`.
|
|
3414
|
+
*
|
|
3415
|
+
* If `fd` points to a character device that only supports blocking reads
|
|
3416
|
+
* (such as keyboard or sound card), read operations do not finish until data is
|
|
3417
|
+
* available. This can prevent the process from exiting and the stream from
|
|
3418
|
+
* closing naturally.
|
|
3419
|
+
*
|
|
3420
|
+
* By default, the stream will emit a `'close'` event after it has been
|
|
3421
|
+
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
|
3422
|
+
*
|
|
3423
|
+
* By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option,
|
|
3424
|
+
* an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is
|
|
3425
|
+
* also required.
|
|
3426
|
+
*
|
|
3427
|
+
* ```js
|
|
3428
|
+
* import { createReadStream } from 'fs';
|
|
3429
|
+
*
|
|
3430
|
+
* // Create a stream from some character device.
|
|
3431
|
+
* const stream = createReadStream('/dev/input/event0');
|
|
3432
|
+
* setTimeout(() => {
|
|
3433
|
+
* stream.close(); // This may not close the stream.
|
|
3434
|
+
* // Artificially marking end-of-stream, as if the underlying resource had
|
|
3435
|
+
* // indicated end-of-file by itself, allows the stream to close.
|
|
3436
|
+
* // This does not cancel pending read operations, and if there is such an
|
|
3437
|
+
* // operation, the process may still not be able to exit successfully
|
|
3438
|
+
* // until it finishes.
|
|
3439
|
+
* stream.push(null);
|
|
3440
|
+
* stream.read(0);
|
|
3441
|
+
* }, 100);
|
|
3442
|
+
* ```
|
|
3443
|
+
*
|
|
3444
|
+
* If `autoClose` is false, then the file descriptor won't be closed, even if
|
|
3445
|
+
* there's an error. It is the application's responsibility to close it and make
|
|
3446
|
+
* sure there's no file descriptor leak. If `autoClose` is set to true (default
|
|
3447
|
+
* behavior), on `'error'` or `'end'` the file descriptor will be closed
|
|
3448
|
+
* automatically.
|
|
3449
|
+
*
|
|
3450
|
+
* `mode` sets the file mode (permission and sticky bits), but only if the
|
|
3451
|
+
* file was created.
|
|
3452
|
+
*
|
|
3453
|
+
* An example to read the last 10 bytes of a file which is 100 bytes long:
|
|
3454
|
+
*
|
|
3455
|
+
* ```js
|
|
3456
|
+
* import { createReadStream } from 'fs';
|
|
3457
|
+
*
|
|
3458
|
+
* createReadStream('sample.txt', { start: 90, end: 99 });
|
|
3459
|
+
* ```
|
|
3460
|
+
*
|
|
3461
|
+
* If `options` is a string, then it specifies the encoding.
|
|
3462
|
+
* @since v0.1.31
|
|
3463
|
+
*/
|
|
3464
|
+
export function createReadStream(path: PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
|
|
3465
|
+
/**
|
|
3466
|
+
* `options` may also include a `start` option to allow writing data at some
|
|
3467
|
+
* position past the beginning of the file, allowed values are in the
|
|
3468
|
+
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than replacing
|
|
3469
|
+
* it may require the `flags` option to be set to `r+` rather than the default `w`.
|
|
3470
|
+
* The `encoding` can be any one of those accepted by `Buffer`.
|
|
3471
|
+
*
|
|
3472
|
+
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
|
3473
|
+
* then the file descriptor won't be closed, even if there's an error.
|
|
3474
|
+
* It is the application's responsibility to close it and make sure there's no
|
|
3475
|
+
* file descriptor leak.
|
|
3476
|
+
*
|
|
3477
|
+
* By default, the stream will emit a `'close'` event after it has been
|
|
3478
|
+
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
|
3479
|
+
*
|
|
3480
|
+
* By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev` and `close`. Overriding `write()`without `writev()` can reduce
|
|
3481
|
+
* performance as some optimizations (`_writev()`)
|
|
3482
|
+
* will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override
|
|
3483
|
+
* for `open` is also required. If `autoClose` is `true`, an override for `close`is also required.
|
|
3484
|
+
*
|
|
3485
|
+
* Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be
|
|
3486
|
+
* emitted. `fd` should be blocking; non-blocking `fd`s
|
|
3487
|
+
* should be passed to `net.Socket`.
|
|
3488
|
+
*
|
|
3489
|
+
* If `options` is a string, then it specifies the encoding.
|
|
3490
|
+
* @since v0.1.31
|
|
3491
|
+
*/
|
|
3492
|
+
export function createWriteStream(path: PathLike, options?: BufferEncoding | StreamOptions): WriteStream;
|
|
3493
|
+
/**
|
|
3494
|
+
* Forces all currently queued I/O operations associated with the file to the
|
|
3495
|
+
* operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other
|
|
3496
|
+
* than a possible
|
|
3497
|
+
* exception are given to the completion callback.
|
|
3498
|
+
* @since v0.1.96
|
|
2080
3499
|
*/
|
|
2081
3500
|
export function fdatasync(fd: number, callback: NoParamCallback): void;
|
|
2082
|
-
|
|
2083
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
2084
3501
|
export namespace fdatasync {
|
|
2085
3502
|
/**
|
|
2086
3503
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
|
@@ -2088,123 +3505,166 @@ declare module 'fs' {
|
|
|
2088
3505
|
*/
|
|
2089
3506
|
function __promisify__(fd: number): Promise<void>;
|
|
2090
3507
|
}
|
|
2091
|
-
|
|
2092
3508
|
/**
|
|
2093
|
-
*
|
|
2094
|
-
*
|
|
3509
|
+
* Forces all currently queued I/O operations associated with the file to the
|
|
3510
|
+
* operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. Returns `undefined`.
|
|
3511
|
+
* @since v0.1.96
|
|
2095
3512
|
*/
|
|
2096
3513
|
export function fdatasyncSync(fd: number): void;
|
|
2097
|
-
|
|
2098
3514
|
/**
|
|
2099
|
-
* Asynchronously copies src to dest
|
|
2100
|
-
* No arguments other than a possible exception are given to the
|
|
2101
|
-
* Node.js makes no guarantees about the atomicity of the copy
|
|
2102
|
-
* If an error occurs after the destination file has been opened for
|
|
2103
|
-
* to remove the destination.
|
|
2104
|
-
*
|
|
2105
|
-
*
|
|
3515
|
+
* Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
|
|
3516
|
+
* already exists. No arguments other than a possible exception are given to the
|
|
3517
|
+
* callback function. Node.js makes no guarantees about the atomicity of the copy
|
|
3518
|
+
* operation. If an error occurs after the destination file has been opened for
|
|
3519
|
+
* writing, Node.js will attempt to remove the destination.
|
|
3520
|
+
*
|
|
3521
|
+
* `mode` is an optional integer that specifies the behavior
|
|
3522
|
+
* of the copy operation. It is possible to create a mask consisting of the bitwise
|
|
3523
|
+
* OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
|
|
3524
|
+
*
|
|
3525
|
+
* * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
|
|
3526
|
+
* exists.
|
|
3527
|
+
* * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
|
|
3528
|
+
* copy-on-write reflink. If the platform does not support copy-on-write, then a
|
|
3529
|
+
* fallback copy mechanism is used.
|
|
3530
|
+
* * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
|
|
3531
|
+
* create a copy-on-write reflink. If the platform does not support
|
|
3532
|
+
* copy-on-write, then the operation will fail.
|
|
3533
|
+
*
|
|
3534
|
+
* ```js
|
|
3535
|
+
* import { copyFile, constants } from 'fs';
|
|
3536
|
+
*
|
|
3537
|
+
* function callback(err) {
|
|
3538
|
+
* if (err) throw err;
|
|
3539
|
+
* console.log('source.txt was copied to destination.txt');
|
|
3540
|
+
* }
|
|
3541
|
+
*
|
|
3542
|
+
* // destination.txt will be created or overwritten by default.
|
|
3543
|
+
* copyFile('source.txt', 'destination.txt', callback);
|
|
3544
|
+
*
|
|
3545
|
+
* // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
|
|
3546
|
+
* copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback);
|
|
3547
|
+
* ```
|
|
3548
|
+
* @since v8.5.0
|
|
3549
|
+
* @param src source filename to copy
|
|
3550
|
+
* @param dest destination filename of the copy operation
|
|
3551
|
+
* @param [mode=0] modifiers for copy operation.
|
|
2106
3552
|
*/
|
|
2107
3553
|
export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
|
|
2108
|
-
|
|
2109
|
-
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
|
|
2110
|
-
* No arguments other than a possible exception are given to the callback function.
|
|
2111
|
-
* Node.js makes no guarantees about the atomicity of the copy operation.
|
|
2112
|
-
* If an error occurs after the destination file has been opened for writing, Node.js will attempt
|
|
2113
|
-
* to remove the destination.
|
|
2114
|
-
* @param src A path to the source file.
|
|
2115
|
-
* @param dest A path to the destination file.
|
|
2116
|
-
* @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
|
|
2117
|
-
*/
|
|
2118
|
-
export function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
|
|
2119
|
-
|
|
2120
|
-
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
|
3554
|
+
export function copyFile(src: PathLike, dest: PathLike, mode: number, callback: NoParamCallback): void;
|
|
2121
3555
|
export namespace copyFile {
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
*
|
|
2139
|
-
*
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2142
|
-
*
|
|
2143
|
-
*
|
|
2144
|
-
*
|
|
2145
|
-
*
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
*
|
|
2151
|
-
*
|
|
2152
|
-
*
|
|
3556
|
+
function __promisify__(src: PathLike, dst: PathLike, mode?: number): Promise<void>;
|
|
3557
|
+
}
|
|
3558
|
+
/**
|
|
3559
|
+
* Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it
|
|
3560
|
+
* already exists. Returns `undefined`. Node.js makes no guarantees about the
|
|
3561
|
+
* atomicity of the copy operation. If an error occurs after the destination file
|
|
3562
|
+
* has been opened for writing, Node.js will attempt to remove the destination.
|
|
3563
|
+
*
|
|
3564
|
+
* `mode` is an optional integer that specifies the behavior
|
|
3565
|
+
* of the copy operation. It is possible to create a mask consisting of the bitwise
|
|
3566
|
+
* OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
|
|
3567
|
+
*
|
|
3568
|
+
* * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
|
|
3569
|
+
* exists.
|
|
3570
|
+
* * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
|
|
3571
|
+
* copy-on-write reflink. If the platform does not support copy-on-write, then a
|
|
3572
|
+
* fallback copy mechanism is used.
|
|
3573
|
+
* * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
|
|
3574
|
+
* create a copy-on-write reflink. If the platform does not support
|
|
3575
|
+
* copy-on-write, then the operation will fail.
|
|
3576
|
+
*
|
|
3577
|
+
* ```js
|
|
3578
|
+
* import { copyFileSync, constants } from 'fs';
|
|
3579
|
+
*
|
|
3580
|
+
* // destination.txt will be created or overwritten by default.
|
|
3581
|
+
* copyFileSync('source.txt', 'destination.txt');
|
|
3582
|
+
* console.log('source.txt was copied to destination.txt');
|
|
3583
|
+
*
|
|
3584
|
+
* // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
|
|
3585
|
+
* copyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
|
|
3586
|
+
* ```
|
|
3587
|
+
* @since v8.5.0
|
|
3588
|
+
* @param src source filename to copy
|
|
3589
|
+
* @param dest destination filename of the copy operation
|
|
3590
|
+
* @param [mode=0] modifiers for copy operation.
|
|
3591
|
+
*/
|
|
3592
|
+
export function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void;
|
|
3593
|
+
/**
|
|
3594
|
+
* Write an array of `ArrayBufferView`s to the file specified by `fd` using`writev()`.
|
|
3595
|
+
*
|
|
3596
|
+
* `position` is the offset from the beginning of the file where this data
|
|
3597
|
+
* should be written. If `typeof position !== 'number'`, the data will be written
|
|
3598
|
+
* at the current position.
|
|
3599
|
+
*
|
|
3600
|
+
* The callback will be given three arguments: `err`, `bytesWritten`, and`buffers`. `bytesWritten` is how many bytes were written from `buffers`.
|
|
3601
|
+
*
|
|
3602
|
+
* If this method is `util.promisify()` ed, it returns a promise for an`Object` with `bytesWritten` and `buffers` properties.
|
|
3603
|
+
*
|
|
3604
|
+
* It is unsafe to use `fs.writev()` multiple times on the same file without
|
|
3605
|
+
* waiting for the callback. For this scenario, use {@link createWriteStream}.
|
|
3606
|
+
*
|
|
2153
3607
|
* On Linux, positional writes don't work when the file is opened in append mode.
|
|
2154
|
-
* The kernel ignores the position argument and always appends the data to
|
|
3608
|
+
* The kernel ignores the position argument and always appends the data to
|
|
3609
|
+
* the end of the file.
|
|
3610
|
+
* @since v12.9.0
|
|
2155
3611
|
*/
|
|
2156
|
-
export function writev(
|
|
2157
|
-
fd: number,
|
|
2158
|
-
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
|
2159
|
-
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
|
|
2160
|
-
): void;
|
|
3612
|
+
export function writev(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
|
|
2161
3613
|
export function writev(
|
|
2162
3614
|
fd: number,
|
|
2163
3615
|
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
|
2164
3616
|
position: number,
|
|
2165
3617
|
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
|
|
2166
3618
|
): void;
|
|
2167
|
-
|
|
2168
3619
|
export interface WriteVResult {
|
|
2169
3620
|
bytesWritten: number;
|
|
2170
3621
|
buffers: NodeJS.ArrayBufferView[];
|
|
2171
3622
|
}
|
|
2172
|
-
|
|
2173
3623
|
export namespace writev {
|
|
2174
3624
|
function __promisify__(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
|
|
2175
3625
|
}
|
|
2176
|
-
|
|
2177
3626
|
/**
|
|
2178
|
-
*
|
|
3627
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
3628
|
+
* this API: {@link writev}.
|
|
3629
|
+
* @since v12.9.0
|
|
3630
|
+
* @return The number of bytes written.
|
|
2179
3631
|
*/
|
|
2180
3632
|
export function writevSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
3633
|
+
/**
|
|
3634
|
+
* Read from a file specified by `fd` and write to an array of `ArrayBufferView`s
|
|
3635
|
+
* using `readv()`.
|
|
3636
|
+
*
|
|
3637
|
+
* `position` is the offset from the beginning of the file from where data
|
|
3638
|
+
* should be read. If `typeof position !== 'number'`, the data will be read
|
|
3639
|
+
* from the current position.
|
|
3640
|
+
*
|
|
3641
|
+
* The callback will be given three arguments: `err`, `bytesRead`, and`buffers`. `bytesRead` is how many bytes were read from the file.
|
|
3642
|
+
*
|
|
3643
|
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
|
3644
|
+
* a promise for an `Object` with `bytesRead` and `buffers` properties.
|
|
3645
|
+
* @since v13.13.0, v12.17.0
|
|
3646
|
+
*/
|
|
3647
|
+
export function readv(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
|
|
2187
3648
|
export function readv(
|
|
2188
3649
|
fd: number,
|
|
2189
3650
|
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
|
2190
3651
|
position: number,
|
|
2191
3652
|
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
|
|
2192
3653
|
): void;
|
|
2193
|
-
|
|
2194
3654
|
export interface ReadVResult {
|
|
2195
3655
|
bytesRead: number;
|
|
2196
3656
|
buffers: NodeJS.ArrayBufferView[];
|
|
2197
3657
|
}
|
|
2198
|
-
|
|
2199
3658
|
export namespace readv {
|
|
2200
3659
|
function __promisify__(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
|
|
2201
3660
|
}
|
|
2202
|
-
|
|
2203
3661
|
/**
|
|
2204
|
-
*
|
|
3662
|
+
* For detailed information, see the documentation of the asynchronous version of
|
|
3663
|
+
* this API: {@link readv}.
|
|
3664
|
+
* @since v13.13.0, v12.17.0
|
|
3665
|
+
* @return The number of bytes read.
|
|
2205
3666
|
*/
|
|
2206
3667
|
export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
|
|
2207
|
-
|
|
2208
3668
|
export interface OpenDirOptions {
|
|
2209
3669
|
encoding?: BufferEncoding | undefined;
|
|
2210
3670
|
/**
|
|
@@ -2215,36 +3675,110 @@ declare module 'fs' {
|
|
|
2215
3675
|
*/
|
|
2216
3676
|
bufferSize?: number | undefined;
|
|
2217
3677
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
3678
|
+
/**
|
|
3679
|
+
* Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
|
|
3680
|
+
*
|
|
3681
|
+
* Creates an `fs.Dir`, which contains all further functions for reading from
|
|
3682
|
+
* and cleaning up the directory.
|
|
3683
|
+
*
|
|
3684
|
+
* The `encoding` option sets the encoding for the `path` while opening the
|
|
3685
|
+
* directory and subsequent read operations.
|
|
3686
|
+
* @since v12.12.0
|
|
3687
|
+
*/
|
|
3688
|
+
export function opendirSync(path: PathLike, options?: OpenDirOptions): Dir;
|
|
3689
|
+
/**
|
|
3690
|
+
* Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for
|
|
3691
|
+
* more details.
|
|
3692
|
+
*
|
|
3693
|
+
* Creates an `fs.Dir`, which contains all further functions for reading from
|
|
3694
|
+
* and cleaning up the directory.
|
|
3695
|
+
*
|
|
3696
|
+
* The `encoding` option sets the encoding for the `path` while opening the
|
|
3697
|
+
* directory and subsequent read operations.
|
|
3698
|
+
* @since v12.12.0
|
|
3699
|
+
*/
|
|
3700
|
+
export function opendir(path: PathLike, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
|
|
3701
|
+
export function opendir(path: PathLike, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
|
|
2224
3702
|
export namespace opendir {
|
|
2225
|
-
function __promisify__(path:
|
|
3703
|
+
function __promisify__(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
|
|
2226
3704
|
}
|
|
2227
|
-
|
|
2228
3705
|
export interface BigIntStats extends StatsBase<bigint> {
|
|
2229
|
-
}
|
|
2230
|
-
|
|
2231
|
-
export class BigIntStats {
|
|
2232
3706
|
atimeNs: bigint;
|
|
2233
3707
|
mtimeNs: bigint;
|
|
2234
3708
|
ctimeNs: bigint;
|
|
2235
3709
|
birthtimeNs: bigint;
|
|
2236
3710
|
}
|
|
2237
|
-
|
|
2238
3711
|
export interface BigIntOptions {
|
|
2239
3712
|
bigint: true;
|
|
2240
3713
|
}
|
|
2241
|
-
|
|
2242
3714
|
export interface StatOptions {
|
|
2243
3715
|
bigint?: boolean | undefined;
|
|
3716
|
+
}
|
|
3717
|
+
export interface StatSyncOptions extends StatOptions {
|
|
2244
3718
|
throwIfNoEntry?: boolean | undefined;
|
|
2245
3719
|
}
|
|
3720
|
+
export interface CopyOptions {
|
|
3721
|
+
/**
|
|
3722
|
+
* Dereference symlinks
|
|
3723
|
+
* @default false
|
|
3724
|
+
*/
|
|
3725
|
+
dereference?: boolean;
|
|
3726
|
+
/**
|
|
3727
|
+
* When `force` is `false`, and the destination
|
|
3728
|
+
* exists, throw an error.
|
|
3729
|
+
* @default false
|
|
3730
|
+
*/
|
|
3731
|
+
errorOnExist?: boolean;
|
|
3732
|
+
/**
|
|
3733
|
+
* Function to filter copied files/directories. Return
|
|
3734
|
+
* `true` to copy the item, `false` to ignore it.
|
|
3735
|
+
*/
|
|
3736
|
+
filter?(source: string, destination: string): boolean;
|
|
3737
|
+
/**
|
|
3738
|
+
* Overwrite existing file or directory. _The copy
|
|
3739
|
+
* operation will ignore errors if you set this to false and the destination
|
|
3740
|
+
* exists. Use the `errorOnExist` option to change this behavior.
|
|
3741
|
+
* @default true
|
|
3742
|
+
*/
|
|
3743
|
+
force?: boolean;
|
|
3744
|
+
/**
|
|
3745
|
+
* When `true` timestamps from `src` will
|
|
3746
|
+
* be preserved.
|
|
3747
|
+
* @default false
|
|
3748
|
+
*/
|
|
3749
|
+
preserveTimestamps?: boolean;
|
|
3750
|
+
/**
|
|
3751
|
+
* Copy directories recursively.
|
|
3752
|
+
* @default false
|
|
3753
|
+
*/
|
|
3754
|
+
recursive?: boolean;
|
|
3755
|
+
}
|
|
3756
|
+
/**
|
|
3757
|
+
* Asynchronously copies the entire directory structure from `src` to `dest`,
|
|
3758
|
+
* including subdirectories and files.
|
|
3759
|
+
*
|
|
3760
|
+
* When copying a directory to another directory, globs are not supported and
|
|
3761
|
+
* behavior is similar to `cp dir1/ dir2/`.
|
|
3762
|
+
* @since v16.7.0
|
|
3763
|
+
* @experimental
|
|
3764
|
+
* @param src source path to copy.
|
|
3765
|
+
* @param dest destination path to copy to.
|
|
3766
|
+
*/
|
|
3767
|
+
export function cp(source: string, destination: string, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
3768
|
+
export function cp(source: string, destination: string, opts: CopyOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
3769
|
+
/**
|
|
3770
|
+
* Synchronously copies the entire directory structure from `src` to `dest`,
|
|
3771
|
+
* including subdirectories and files.
|
|
3772
|
+
*
|
|
3773
|
+
* When copying a directory to another directory, globs are not supported and
|
|
3774
|
+
* behavior is similar to `cp dir1/ dir2/`.
|
|
3775
|
+
* @since v16.7.0
|
|
3776
|
+
* @experimental
|
|
3777
|
+
* @param src source path to copy.
|
|
3778
|
+
* @param dest destination path to copy to.
|
|
3779
|
+
*/
|
|
3780
|
+
export function cpSync(source: string, destination: string, opts?: CopyOptions): void;
|
|
2246
3781
|
}
|
|
2247
|
-
|
|
2248
3782
|
declare module 'node:fs' {
|
|
2249
3783
|
export * from 'fs';
|
|
2250
3784
|
}
|