cloudstructs 0.1.37 → 0.1.41
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/.jsii +3 -3
- 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 +3 -4
- 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 +1070 -240
- package/node_modules/@slack/logger/node_modules/@types/node/cluster.d.ts +331 -104
- package/node_modules/@slack/logger/node_modules/@types/node/console.d.ts +310 -37
- package/node_modules/@slack/logger/node_modules/@types/node/constants.d.ts +3 -3
- package/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +2406 -742
- package/node_modules/@slack/logger/node_modules/@types/node/dgram.d.ts +458 -58
- package/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
- package/node_modules/@slack/logger/node_modules/@types/node/dns/promises.d.ts +292 -36
- package/node_modules/@slack/logger/node_modules/@types/node/dns.d.ts +414 -97
- package/node_modules/@slack/logger/node_modules/@types/node/domain.d.ts +153 -9
- package/node_modules/@slack/logger/node_modules/@types/node/events.d.ts +560 -35
- package/node_modules/@slack/logger/node_modules/@types/node/fs/promises.d.ts +735 -279
- package/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +2351 -870
- 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 +1020 -98
- package/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +1586 -466
- package/node_modules/@slack/logger/node_modules/@types/node/https.d.ts +366 -15
- package/node_modules/@slack/logger/node_modules/@types/node/index.d.ts +87 -13
- package/node_modules/@slack/logger/node_modules/@types/node/inspector.d.ts +577 -562
- package/node_modules/@slack/logger/node_modules/@types/node/module.d.ts +53 -12
- package/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +558 -143
- 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 +18 -15
- 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 +290 -92
- package/node_modules/@slack/logger/node_modules/@types/node/process.d.ts +1170 -156
- 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 -80
- package/node_modules/@slack/logger/node_modules/@types/node/repl.d.ts +138 -113
- 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 +6 -0
- package/node_modules/@slack/logger/node_modules/@types/node/stream.d.ts +979 -226
- 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 +53 -10
- package/node_modules/@slack/logger/node_modules/@types/node/timers.d.ts +32 -39
- package/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +449 -227
- 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 +160 -24
- package/node_modules/@slack/logger/node_modules/@types/node/url.d.ts +703 -32
- package/node_modules/@slack/logger/node_modules/@types/node/util.d.ts +1375 -76
- package/node_modules/@slack/logger/node_modules/@types/node/v8.d.ts +255 -79
- 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 +501 -138
- package/node_modules/@slack/logger/node_modules/@types/node/zlib.d.ts +216 -64
- 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 +3 -4
- 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 +1070 -240
- package/node_modules/@slack/web-api/node_modules/@types/node/cluster.d.ts +331 -104
- package/node_modules/@slack/web-api/node_modules/@types/node/console.d.ts +310 -37
- package/node_modules/@slack/web-api/node_modules/@types/node/constants.d.ts +3 -3
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +2406 -742
- package/node_modules/@slack/web-api/node_modules/@types/node/dgram.d.ts +458 -58
- package/node_modules/@slack/web-api/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +292 -36
- package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +414 -97
- package/node_modules/@slack/web-api/node_modules/@types/node/domain.d.ts +153 -9
- package/node_modules/@slack/web-api/node_modules/@types/node/events.d.ts +560 -35
- package/node_modules/@slack/web-api/node_modules/@types/node/fs/promises.d.ts +735 -279
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +2351 -870
- 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 +1020 -98
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +1586 -466
- package/node_modules/@slack/web-api/node_modules/@types/node/https.d.ts +366 -15
- package/node_modules/@slack/web-api/node_modules/@types/node/index.d.ts +87 -13
- package/node_modules/@slack/web-api/node_modules/@types/node/inspector.d.ts +577 -562
- package/node_modules/@slack/web-api/node_modules/@types/node/module.d.ts +53 -12
- package/node_modules/@slack/web-api/node_modules/@types/node/net.d.ts +558 -143
- 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 +18 -15
- 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 +290 -92
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +1170 -156
- 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 -80
- package/node_modules/@slack/web-api/node_modules/@types/node/repl.d.ts +138 -113
- 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 +6 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/stream.d.ts +979 -226
- 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 +53 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/timers.d.ts +32 -39
- package/node_modules/@slack/web-api/node_modules/@types/node/tls.d.ts +449 -227
- 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 +160 -24
- package/node_modules/@slack/web-api/node_modules/@types/node/url.d.ts +703 -32
- package/node_modules/@slack/web-api/node_modules/@types/node/util.d.ts +1375 -76
- package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +255 -79
- 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 +501 -138
- package/node_modules/@slack/web-api/node_modules/@types/node/zlib.d.ts +216 -64
- 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 +3 -4
- 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 +1070 -240
- package/node_modules/@types/cacheable-request/node_modules/@types/node/cluster.d.ts +331 -104
- package/node_modules/@types/cacheable-request/node_modules/@types/node/console.d.ts +310 -37
- package/node_modules/@types/cacheable-request/node_modules/@types/node/constants.d.ts +3 -3
- package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +2406 -742
- package/node_modules/@types/cacheable-request/node_modules/@types/node/dgram.d.ts +458 -58
- package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/dns/promises.d.ts +292 -36
- package/node_modules/@types/cacheable-request/node_modules/@types/node/dns.d.ts +414 -97
- package/node_modules/@types/cacheable-request/node_modules/@types/node/domain.d.ts +153 -9
- package/node_modules/@types/cacheable-request/node_modules/@types/node/events.d.ts +560 -35
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs/promises.d.ts +735 -279
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +2351 -870
- 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 +1020 -98
- package/node_modules/@types/cacheable-request/node_modules/@types/node/http2.d.ts +1586 -466
- package/node_modules/@types/cacheable-request/node_modules/@types/node/https.d.ts +366 -15
- package/node_modules/@types/cacheable-request/node_modules/@types/node/index.d.ts +87 -13
- package/node_modules/@types/cacheable-request/node_modules/@types/node/inspector.d.ts +577 -562
- package/node_modules/@types/cacheable-request/node_modules/@types/node/module.d.ts +53 -12
- package/node_modules/@types/cacheable-request/node_modules/@types/node/net.d.ts +558 -143
- 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 +18 -15
- 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 +290 -92
- package/node_modules/@types/cacheable-request/node_modules/@types/node/process.d.ts +1170 -156
- 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 -80
- package/node_modules/@types/cacheable-request/node_modules/@types/node/repl.d.ts +138 -113
- 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 +6 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream.d.ts +979 -226
- 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 +53 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/timers.d.ts +32 -39
- package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +449 -227
- 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 +160 -24
- package/node_modules/@types/cacheable-request/node_modules/@types/node/url.d.ts +703 -32
- package/node_modules/@types/cacheable-request/node_modules/@types/node/util.d.ts +1375 -76
- package/node_modules/@types/cacheable-request/node_modules/@types/node/v8.d.ts +255 -79
- 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 +501 -138
- package/node_modules/@types/cacheable-request/node_modules/@types/node/zlib.d.ts +216 -64
- 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 +3 -4
- 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 +1070 -240
- package/node_modules/@types/is-stream/node_modules/@types/node/cluster.d.ts +331 -104
- package/node_modules/@types/is-stream/node_modules/@types/node/console.d.ts +310 -37
- package/node_modules/@types/is-stream/node_modules/@types/node/constants.d.ts +3 -3
- package/node_modules/@types/is-stream/node_modules/@types/node/crypto.d.ts +2406 -742
- package/node_modules/@types/is-stream/node_modules/@types/node/dgram.d.ts +458 -58
- package/node_modules/@types/is-stream/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/dns/promises.d.ts +292 -36
- package/node_modules/@types/is-stream/node_modules/@types/node/dns.d.ts +414 -97
- package/node_modules/@types/is-stream/node_modules/@types/node/domain.d.ts +153 -9
- package/node_modules/@types/is-stream/node_modules/@types/node/events.d.ts +560 -35
- package/node_modules/@types/is-stream/node_modules/@types/node/fs/promises.d.ts +735 -279
- package/node_modules/@types/is-stream/node_modules/@types/node/fs.d.ts +2351 -870
- 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 +1020 -98
- package/node_modules/@types/is-stream/node_modules/@types/node/http2.d.ts +1586 -466
- package/node_modules/@types/is-stream/node_modules/@types/node/https.d.ts +366 -15
- package/node_modules/@types/is-stream/node_modules/@types/node/index.d.ts +87 -13
- package/node_modules/@types/is-stream/node_modules/@types/node/inspector.d.ts +577 -562
- package/node_modules/@types/is-stream/node_modules/@types/node/module.d.ts +53 -12
- package/node_modules/@types/is-stream/node_modules/@types/node/net.d.ts +558 -143
- 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 +18 -15
- 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 +290 -92
- package/node_modules/@types/is-stream/node_modules/@types/node/process.d.ts +1170 -156
- 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 -80
- package/node_modules/@types/is-stream/node_modules/@types/node/repl.d.ts +138 -113
- 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 +6 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/stream.d.ts +979 -226
- 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 +53 -10
- package/node_modules/@types/is-stream/node_modules/@types/node/timers.d.ts +32 -39
- package/node_modules/@types/is-stream/node_modules/@types/node/tls.d.ts +449 -227
- 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 +160 -24
- package/node_modules/@types/is-stream/node_modules/@types/node/url.d.ts +703 -32
- package/node_modules/@types/is-stream/node_modules/@types/node/util.d.ts +1375 -76
- package/node_modules/@types/is-stream/node_modules/@types/node/v8.d.ts +255 -79
- 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 +501 -138
- package/node_modules/@types/is-stream/node_modules/@types/node/zlib.d.ts +216 -64
- 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 +3 -4
- 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 +1070 -240
- package/node_modules/@types/keyv/node_modules/@types/node/cluster.d.ts +331 -104
- package/node_modules/@types/keyv/node_modules/@types/node/console.d.ts +310 -37
- package/node_modules/@types/keyv/node_modules/@types/node/constants.d.ts +3 -3
- package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +2406 -742
- package/node_modules/@types/keyv/node_modules/@types/node/dgram.d.ts +458 -58
- package/node_modules/@types/keyv/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
- package/node_modules/@types/keyv/node_modules/@types/node/dns/promises.d.ts +292 -36
- package/node_modules/@types/keyv/node_modules/@types/node/dns.d.ts +414 -97
- package/node_modules/@types/keyv/node_modules/@types/node/domain.d.ts +153 -9
- package/node_modules/@types/keyv/node_modules/@types/node/events.d.ts +560 -35
- package/node_modules/@types/keyv/node_modules/@types/node/fs/promises.d.ts +735 -279
- package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +2351 -870
- 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 +1020 -98
- package/node_modules/@types/keyv/node_modules/@types/node/http2.d.ts +1586 -466
- package/node_modules/@types/keyv/node_modules/@types/node/https.d.ts +366 -15
- package/node_modules/@types/keyv/node_modules/@types/node/index.d.ts +87 -13
- package/node_modules/@types/keyv/node_modules/@types/node/inspector.d.ts +577 -562
- package/node_modules/@types/keyv/node_modules/@types/node/module.d.ts +53 -12
- package/node_modules/@types/keyv/node_modules/@types/node/net.d.ts +558 -143
- 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 +18 -15
- 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 +290 -92
- package/node_modules/@types/keyv/node_modules/@types/node/process.d.ts +1170 -156
- 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 -80
- package/node_modules/@types/keyv/node_modules/@types/node/repl.d.ts +138 -113
- 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 +6 -0
- package/node_modules/@types/keyv/node_modules/@types/node/stream.d.ts +979 -226
- 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 +53 -10
- package/node_modules/@types/keyv/node_modules/@types/node/timers.d.ts +32 -39
- package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +449 -227
- 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 +160 -24
- package/node_modules/@types/keyv/node_modules/@types/node/url.d.ts +703 -32
- package/node_modules/@types/keyv/node_modules/@types/node/util.d.ts +1375 -76
- package/node_modules/@types/keyv/node_modules/@types/node/v8.d.ts +255 -79
- 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 +501 -138
- package/node_modules/@types/keyv/node_modules/@types/node/zlib.d.ts +216 -64
- 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 +3 -4
- 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 +1070 -240
- package/node_modules/@types/responselike/node_modules/@types/node/cluster.d.ts +331 -104
- package/node_modules/@types/responselike/node_modules/@types/node/console.d.ts +310 -37
- package/node_modules/@types/responselike/node_modules/@types/node/constants.d.ts +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +2406 -742
- package/node_modules/@types/responselike/node_modules/@types/node/dgram.d.ts +458 -58
- package/node_modules/@types/responselike/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
- package/node_modules/@types/responselike/node_modules/@types/node/dns/promises.d.ts +292 -36
- package/node_modules/@types/responselike/node_modules/@types/node/dns.d.ts +414 -97
- package/node_modules/@types/responselike/node_modules/@types/node/domain.d.ts +153 -9
- package/node_modules/@types/responselike/node_modules/@types/node/events.d.ts +560 -35
- package/node_modules/@types/responselike/node_modules/@types/node/fs/promises.d.ts +735 -279
- package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +2351 -870
- 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 +1020 -98
- package/node_modules/@types/responselike/node_modules/@types/node/http2.d.ts +1586 -466
- package/node_modules/@types/responselike/node_modules/@types/node/https.d.ts +366 -15
- package/node_modules/@types/responselike/node_modules/@types/node/index.d.ts +87 -13
- package/node_modules/@types/responselike/node_modules/@types/node/inspector.d.ts +577 -562
- package/node_modules/@types/responselike/node_modules/@types/node/module.d.ts +53 -12
- package/node_modules/@types/responselike/node_modules/@types/node/net.d.ts +558 -143
- 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 +18 -15
- 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 +290 -92
- package/node_modules/@types/responselike/node_modules/@types/node/process.d.ts +1170 -156
- 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 -80
- package/node_modules/@types/responselike/node_modules/@types/node/repl.d.ts +138 -113
- 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 +6 -0
- package/node_modules/@types/responselike/node_modules/@types/node/stream.d.ts +979 -226
- 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 +53 -10
- package/node_modules/@types/responselike/node_modules/@types/node/timers.d.ts +32 -39
- package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +449 -227
- 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 +160 -24
- package/node_modules/@types/responselike/node_modules/@types/node/url.d.ts +703 -32
- package/node_modules/@types/responselike/node_modules/@types/node/util.d.ts +1375 -76
- package/node_modules/@types/responselike/node_modules/@types/node/v8.d.ts +255 -79
- 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 +501 -138
- package/node_modules/@types/responselike/node_modules/@types/node/zlib.d.ts +216 -64
- 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 +14 -7
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/mime-db/HISTORY.md +6 -0
- package/node_modules/mime-db/db.json +39 -1
- package/node_modules/mime-db/package.json +4 -4
- package/node_modules/mime-types/HISTORY.md +7 -0
- package/node_modules/mime-types/package.json +4 -4
- 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 +15 -15
- package/node_modules/@slack/logger/node_modules/@types/node/base.d.ts +0 -19
- package/node_modules/@slack/logger/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
- package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- 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/diagnostic_channel.d.ts +0 -38
- package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- 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/diagnostic_channel.d.ts +0 -38
- package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- 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/diagnostic_channel.d.ts +0 -38
- package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- 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/diagnostic_channel.d.ts +0 -38
- package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- 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/diagnostic_channel.d.ts +0 -38
- package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- 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,6 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
|
|
3
|
+
* Node.js APIs support `Buffer`s.
|
|
4
|
+
*
|
|
5
|
+
* The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and
|
|
6
|
+
* extends it with methods that cover additional use cases. Node.js APIs accept
|
|
7
|
+
* plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well.
|
|
8
|
+
*
|
|
9
|
+
* While the `Buffer` class is available within the global scope, it is still
|
|
10
|
+
* recommended to explicitly reference it via an import or require statement.
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* import { Buffer } from 'buffer';
|
|
14
|
+
*
|
|
15
|
+
* // Creates a zero-filled Buffer of length 10.
|
|
16
|
+
* const buf1 = Buffer.alloc(10);
|
|
17
|
+
*
|
|
18
|
+
* // Creates a Buffer of length 10,
|
|
19
|
+
* // filled with bytes which all have the value `1`.
|
|
20
|
+
* const buf2 = Buffer.alloc(10, 1);
|
|
21
|
+
*
|
|
22
|
+
* // Creates an uninitialized buffer of length 10.
|
|
23
|
+
* // This is faster than calling Buffer.alloc() but the returned
|
|
24
|
+
* // Buffer instance might contain old data that needs to be
|
|
25
|
+
* // overwritten using fill(), write(), or other functions that fill the Buffer's
|
|
26
|
+
* // contents.
|
|
27
|
+
* const buf3 = Buffer.allocUnsafe(10);
|
|
28
|
+
*
|
|
29
|
+
* // Creates a Buffer containing the bytes [1, 2, 3].
|
|
30
|
+
* const buf4 = Buffer.from([1, 2, 3]);
|
|
31
|
+
*
|
|
32
|
+
* // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries
|
|
33
|
+
* // are all truncated using `(value & 255)` to fit into the range 0–255.
|
|
34
|
+
* const buf5 = Buffer.from([257, 257.5, -255, '1']);
|
|
35
|
+
*
|
|
36
|
+
* // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
|
|
37
|
+
* // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
|
|
38
|
+
* // [116, 195, 169, 115, 116] (in decimal notation)
|
|
39
|
+
* const buf6 = Buffer.from('tést');
|
|
40
|
+
*
|
|
41
|
+
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
|
42
|
+
* const buf7 = Buffer.from('tést', 'latin1');
|
|
43
|
+
* ```
|
|
44
|
+
* @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/buffer.js)
|
|
45
|
+
*/
|
|
1
46
|
declare module 'buffer' {
|
|
2
|
-
import { BinaryLike } from 'crypto';
|
|
3
|
-
|
|
47
|
+
import { BinaryLike } from 'node:crypto';
|
|
4
48
|
export const INSPECT_MAX_BYTES: number;
|
|
5
49
|
export const kMaxLength: number;
|
|
6
50
|
export const kStringMaxLength: number;
|
|
@@ -8,19 +52,49 @@ declare module 'buffer' {
|
|
|
8
52
|
MAX_LENGTH: number;
|
|
9
53
|
MAX_STRING_LENGTH: number;
|
|
10
54
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
55
|
+
export type TranscodeEncoding = 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'latin1' | 'binary';
|
|
56
|
+
/**
|
|
57
|
+
* Re-encodes the given `Buffer` or `Uint8Array` instance from one character
|
|
58
|
+
* encoding to another. Returns a new `Buffer` instance.
|
|
59
|
+
*
|
|
60
|
+
* Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if
|
|
61
|
+
* conversion from `fromEnc` to `toEnc` is not permitted.
|
|
62
|
+
*
|
|
63
|
+
* Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`,`'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.
|
|
64
|
+
*
|
|
65
|
+
* The transcoding process will use substitution characters if a given byte
|
|
66
|
+
* sequence cannot be adequately represented in the target encoding. For instance:
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* import { Buffer, transcode } from 'buffer';
|
|
70
|
+
*
|
|
71
|
+
* const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');
|
|
72
|
+
* console.log(newBuf.toString('ascii'));
|
|
73
|
+
* // Prints: '?'
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced
|
|
77
|
+
* with `?` in the transcoded `Buffer`.
|
|
78
|
+
* @since v7.1.0
|
|
79
|
+
* @param source A `Buffer` or `Uint8Array` instance.
|
|
80
|
+
* @param fromEnc The current encoding.
|
|
81
|
+
* @param toEnc To target encoding.
|
|
82
|
+
*/
|
|
14
83
|
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
|
|
15
|
-
|
|
16
84
|
export const SlowBuffer: {
|
|
17
85
|
/** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
|
|
18
|
-
new(size: number): Buffer;
|
|
86
|
+
new (size: number): Buffer;
|
|
19
87
|
prototype: Buffer;
|
|
20
88
|
};
|
|
21
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
|
|
91
|
+
* a prior call to `URL.createObjectURL()`.
|
|
92
|
+
* @since v16.7.0
|
|
93
|
+
* @experimental
|
|
94
|
+
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
|
95
|
+
*/
|
|
96
|
+
export function resolveObjectURL(id: string): Blob | undefined;
|
|
22
97
|
export { Buffer };
|
|
23
|
-
|
|
24
98
|
/**
|
|
25
99
|
* @experimental
|
|
26
100
|
*/
|
|
@@ -29,7 +103,6 @@ declare module 'buffer' {
|
|
|
29
103
|
* @default 'utf8'
|
|
30
104
|
*/
|
|
31
105
|
encoding?: BufferEncoding | undefined;
|
|
32
|
-
|
|
33
106
|
/**
|
|
34
107
|
* The Blob content-type. The intent is for `type` to convey
|
|
35
108
|
* the MIME media type of the data, however no validation of the type format
|
|
@@ -37,21 +110,23 @@ declare module 'buffer' {
|
|
|
37
110
|
*/
|
|
38
111
|
type?: string | undefined;
|
|
39
112
|
}
|
|
40
|
-
|
|
41
113
|
/**
|
|
114
|
+
* A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across
|
|
115
|
+
* multiple worker threads.
|
|
116
|
+
* @since v15.7.0
|
|
42
117
|
* @experimental
|
|
43
118
|
*/
|
|
44
119
|
export class Blob {
|
|
45
120
|
/**
|
|
46
|
-
*
|
|
121
|
+
* The total size of the `Blob` in bytes.
|
|
122
|
+
* @since v15.7.0
|
|
47
123
|
*/
|
|
48
124
|
readonly size: number;
|
|
49
|
-
|
|
50
125
|
/**
|
|
51
126
|
* The content-type of the `Blob`.
|
|
127
|
+
* @since v15.7.0
|
|
52
128
|
*/
|
|
53
129
|
readonly type: string;
|
|
54
|
-
|
|
55
130
|
/**
|
|
56
131
|
* Creates a new `Blob` object containing a concatenation of the given sources.
|
|
57
132
|
*
|
|
@@ -60,32 +135,44 @@ declare module 'buffer' {
|
|
|
60
135
|
*
|
|
61
136
|
* String sources are also copied into the `Blob`.
|
|
62
137
|
*/
|
|
63
|
-
constructor(sources: Array<
|
|
64
|
-
|
|
138
|
+
constructor(sources: Array<BinaryLike | Blob>, options?: BlobOptions);
|
|
139
|
+
/**
|
|
140
|
+
* Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of
|
|
141
|
+
* the `Blob` data.
|
|
142
|
+
* @since v15.7.0
|
|
143
|
+
*/
|
|
65
144
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
66
|
-
|
|
67
145
|
/**
|
|
146
|
+
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
|
|
147
|
+
* data. The original `Blob` is not altered.
|
|
148
|
+
* @since v15.7.0
|
|
68
149
|
* @param start The starting index.
|
|
69
150
|
* @param end The ending index.
|
|
70
151
|
* @param type The content-type for the new `Blob`
|
|
71
152
|
*/
|
|
72
153
|
slice(start?: number, end?: number, type?: string): Blob;
|
|
73
|
-
|
|
74
154
|
/**
|
|
75
|
-
* Returns a promise that
|
|
155
|
+
* Returns a promise that fulfills with the contents of the `Blob` decoded as a
|
|
156
|
+
* UTF-8 string.
|
|
157
|
+
* @since v15.7.0
|
|
76
158
|
*/
|
|
77
159
|
text(): Promise<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Returns a new `ReadableStream` that allows the content of the `Blob` to be read.
|
|
162
|
+
* @since v16.7.0
|
|
163
|
+
*/
|
|
164
|
+
stream(): unknown; // pending web streams types
|
|
78
165
|
}
|
|
79
|
-
|
|
80
166
|
export import atob = globalThis.atob;
|
|
81
167
|
export import btoa = globalThis.btoa;
|
|
82
|
-
|
|
83
168
|
global {
|
|
84
169
|
// Buffer class
|
|
85
|
-
type BufferEncoding =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
170
|
+
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
|
171
|
+
type WithImplicitCoercion<T> =
|
|
172
|
+
| T
|
|
173
|
+
| {
|
|
174
|
+
valueOf(): T;
|
|
175
|
+
};
|
|
89
176
|
/**
|
|
90
177
|
* Raw data is stored in instances of the Buffer class.
|
|
91
178
|
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
|
|
@@ -99,21 +186,21 @@ declare module 'buffer' {
|
|
|
99
186
|
* @param encoding encoding to use, optional. Default is 'utf8'
|
|
100
187
|
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
|
101
188
|
*/
|
|
102
|
-
new(str: string, encoding?: BufferEncoding): Buffer;
|
|
189
|
+
new (str: string, encoding?: BufferEncoding): Buffer;
|
|
103
190
|
/**
|
|
104
191
|
* Allocates a new buffer of {size} octets.
|
|
105
192
|
*
|
|
106
193
|
* @param size count of octets to allocate.
|
|
107
194
|
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
|
108
195
|
*/
|
|
109
|
-
new(size: number): Buffer;
|
|
196
|
+
new (size: number): Buffer;
|
|
110
197
|
/**
|
|
111
198
|
* Allocates a new buffer containing the given {array} of octets.
|
|
112
199
|
*
|
|
113
200
|
* @param array The octets to store.
|
|
114
201
|
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
|
115
202
|
*/
|
|
116
|
-
new(array: Uint8Array): Buffer;
|
|
203
|
+
new (array: Uint8Array): Buffer;
|
|
117
204
|
/**
|
|
118
205
|
* Produces a Buffer backed by the same allocated memory as
|
|
119
206
|
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
|
@@ -122,28 +209,37 @@ declare module 'buffer' {
|
|
|
122
209
|
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
|
123
210
|
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
|
124
211
|
*/
|
|
125
|
-
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
|
212
|
+
new (arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
|
126
213
|
/**
|
|
127
214
|
* Allocates a new buffer containing the given {array} of octets.
|
|
128
215
|
*
|
|
129
216
|
* @param array The octets to store.
|
|
130
217
|
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
|
131
218
|
*/
|
|
132
|
-
new(array: ReadonlyArray<any>): Buffer;
|
|
219
|
+
new (array: ReadonlyArray<any>): Buffer;
|
|
133
220
|
/**
|
|
134
221
|
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
|
135
222
|
*
|
|
136
223
|
* @param buffer The buffer to copy.
|
|
137
224
|
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
|
138
225
|
*/
|
|
139
|
-
new(buffer: Buffer): Buffer;
|
|
226
|
+
new (buffer: Buffer): Buffer;
|
|
140
227
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
228
|
+
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
|
229
|
+
* Array entries outside that range will be truncated to fit into it.
|
|
230
|
+
*
|
|
231
|
+
* ```js
|
|
232
|
+
* import { Buffer } from 'buffer';
|
|
233
|
+
*
|
|
234
|
+
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
|
235
|
+
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
|
239
|
+
* appropriate for `Buffer.from()` variants.
|
|
145
240
|
*
|
|
146
|
-
*
|
|
241
|
+
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
|
|
242
|
+
* @since v5.10.0
|
|
147
243
|
*/
|
|
148
244
|
from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
|
|
149
245
|
/**
|
|
@@ -157,204 +253,1890 @@ declare module 'buffer' {
|
|
|
157
253
|
* If provided, the {encoding} parameter identifies the character encoding.
|
|
158
254
|
* If not provided, {encoding} defaults to 'utf8'.
|
|
159
255
|
*/
|
|
160
|
-
from(
|
|
256
|
+
from(
|
|
257
|
+
str:
|
|
258
|
+
| WithImplicitCoercion<string>
|
|
259
|
+
| {
|
|
260
|
+
[Symbol.toPrimitive](hint: 'string'): string;
|
|
261
|
+
},
|
|
262
|
+
encoding?: BufferEncoding
|
|
263
|
+
): Buffer;
|
|
161
264
|
/**
|
|
162
265
|
* Creates a new Buffer using the passed {data}
|
|
163
266
|
* @param values to create a new Buffer
|
|
164
267
|
*/
|
|
165
268
|
of(...items: number[]): Buffer;
|
|
166
269
|
/**
|
|
167
|
-
* Returns true if
|
|
270
|
+
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
|
|
271
|
+
*
|
|
272
|
+
* ```js
|
|
273
|
+
* import { Buffer } from 'buffer';
|
|
168
274
|
*
|
|
169
|
-
*
|
|
275
|
+
* Buffer.isBuffer(Buffer.alloc(10)); // true
|
|
276
|
+
* Buffer.isBuffer(Buffer.from('foo')); // true
|
|
277
|
+
* Buffer.isBuffer('a string'); // false
|
|
278
|
+
* Buffer.isBuffer([]); // false
|
|
279
|
+
* Buffer.isBuffer(new Uint8Array(1024)); // false
|
|
280
|
+
* ```
|
|
281
|
+
* @since v0.1.101
|
|
170
282
|
*/
|
|
171
283
|
isBuffer(obj: any): obj is Buffer;
|
|
172
284
|
/**
|
|
173
|
-
* Returns true if
|
|
174
|
-
*
|
|
285
|
+
* Returns `true` if `encoding` is the name of a supported character encoding,
|
|
286
|
+
* or `false` otherwise.
|
|
287
|
+
*
|
|
288
|
+
* ```js
|
|
289
|
+
* import { Buffer } from 'buffer';
|
|
290
|
+
*
|
|
291
|
+
* console.log(Buffer.isEncoding('utf8'));
|
|
292
|
+
* // Prints: true
|
|
175
293
|
*
|
|
176
|
-
*
|
|
294
|
+
* console.log(Buffer.isEncoding('hex'));
|
|
295
|
+
* // Prints: true
|
|
296
|
+
*
|
|
297
|
+
* console.log(Buffer.isEncoding('utf/8'));
|
|
298
|
+
* // Prints: false
|
|
299
|
+
*
|
|
300
|
+
* console.log(Buffer.isEncoding(''));
|
|
301
|
+
* // Prints: false
|
|
302
|
+
* ```
|
|
303
|
+
* @since v0.9.1
|
|
304
|
+
* @param encoding A character encoding name to check.
|
|
177
305
|
*/
|
|
178
306
|
isEncoding(encoding: string): encoding is BufferEncoding;
|
|
179
307
|
/**
|
|
180
|
-
*
|
|
181
|
-
* This is not the same as String.prototype.length
|
|
308
|
+
* Returns the byte length of a string when encoded using `encoding`.
|
|
309
|
+
* This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account
|
|
310
|
+
* for the encoding that is used to convert the string into bytes.
|
|
311
|
+
*
|
|
312
|
+
* For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.
|
|
313
|
+
* For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
|
|
314
|
+
* return value might be greater than the length of a `Buffer` created from the
|
|
315
|
+
* string.
|
|
316
|
+
*
|
|
317
|
+
* ```js
|
|
318
|
+
* import { Buffer } from 'buffer';
|
|
182
319
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
320
|
+
* const str = '\u00bd + \u00bc = \u00be';
|
|
321
|
+
*
|
|
322
|
+
* console.log(`${str}: ${str.length} characters, ` +
|
|
323
|
+
* `${Buffer.byteLength(str, 'utf8')} bytes`);
|
|
324
|
+
* // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* When `string` is a
|
|
328
|
+
* `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
|
|
329
|
+
* Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
|
|
330
|
+
* er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
|
|
331
|
+
* @since v0.1.90
|
|
332
|
+
* @param string A value to calculate the length of.
|
|
333
|
+
* @param [encoding='utf8'] If `string` is a string, this is its encoding.
|
|
334
|
+
* @return The number of bytes contained within `string`.
|
|
185
335
|
*/
|
|
186
|
-
byteLength(
|
|
187
|
-
string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
|
188
|
-
encoding?: BufferEncoding
|
|
189
|
-
): number;
|
|
336
|
+
byteLength(string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number;
|
|
190
337
|
/**
|
|
191
|
-
* Returns a
|
|
338
|
+
* Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
|
|
339
|
+
*
|
|
340
|
+
* If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned.
|
|
192
341
|
*
|
|
193
|
-
* If
|
|
194
|
-
*
|
|
195
|
-
* If the list has more than one item, then a new Buffer is created.
|
|
342
|
+
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
|
343
|
+
* in `list` by adding their lengths.
|
|
196
344
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
345
|
+
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
|
346
|
+
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
|
347
|
+
* truncated to `totalLength`.
|
|
348
|
+
*
|
|
349
|
+
* ```js
|
|
350
|
+
* import { Buffer } from 'buffer';
|
|
351
|
+
*
|
|
352
|
+
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
|
353
|
+
*
|
|
354
|
+
* const buf1 = Buffer.alloc(10);
|
|
355
|
+
* const buf2 = Buffer.alloc(14);
|
|
356
|
+
* const buf3 = Buffer.alloc(18);
|
|
357
|
+
* const totalLength = buf1.length + buf2.length + buf3.length;
|
|
358
|
+
*
|
|
359
|
+
* console.log(totalLength);
|
|
360
|
+
* // Prints: 42
|
|
361
|
+
*
|
|
362
|
+
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
|
363
|
+
*
|
|
364
|
+
* console.log(bufA);
|
|
365
|
+
* // Prints: <Buffer 00 00 00 00 ...>
|
|
366
|
+
* console.log(bufA.length);
|
|
367
|
+
* // Prints: 42
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
|
371
|
+
* @since v0.7.11
|
|
372
|
+
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
|
373
|
+
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
|
200
374
|
*/
|
|
201
375
|
concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
|
|
202
376
|
/**
|
|
203
|
-
*
|
|
377
|
+
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
|
378
|
+
*
|
|
379
|
+
* ```js
|
|
380
|
+
* import { Buffer } from 'buffer';
|
|
381
|
+
*
|
|
382
|
+
* const buf1 = Buffer.from('1234');
|
|
383
|
+
* const buf2 = Buffer.from('0123');
|
|
384
|
+
* const arr = [buf1, buf2];
|
|
385
|
+
*
|
|
386
|
+
* console.log(arr.sort(Buffer.compare));
|
|
387
|
+
* // Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]
|
|
388
|
+
* // (This result is equal to: [buf2, buf1].)
|
|
389
|
+
* ```
|
|
390
|
+
* @since v0.11.13
|
|
391
|
+
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
|
|
204
392
|
*/
|
|
205
393
|
compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
|
206
394
|
/**
|
|
207
|
-
* Allocates a new
|
|
395
|
+
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
|
208
396
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
397
|
+
* ```js
|
|
398
|
+
* import { Buffer } from 'buffer';
|
|
399
|
+
*
|
|
400
|
+
* const buf = Buffer.alloc(5);
|
|
401
|
+
*
|
|
402
|
+
* console.log(buf);
|
|
403
|
+
* // Prints: <Buffer 00 00 00 00 00>
|
|
404
|
+
* ```
|
|
405
|
+
*
|
|
406
|
+
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
|
|
407
|
+
*
|
|
408
|
+
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
|
409
|
+
*
|
|
410
|
+
* ```js
|
|
411
|
+
* import { Buffer } from 'buffer';
|
|
412
|
+
*
|
|
413
|
+
* const buf = Buffer.alloc(5, 'a');
|
|
414
|
+
*
|
|
415
|
+
* console.log(buf);
|
|
416
|
+
* // Prints: <Buffer 61 61 61 61 61>
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
|
420
|
+
* initialized by calling `buf.fill(fill, encoding)`.
|
|
421
|
+
*
|
|
422
|
+
* ```js
|
|
423
|
+
* import { Buffer } from 'buffer';
|
|
424
|
+
*
|
|
425
|
+
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
|
426
|
+
*
|
|
427
|
+
* console.log(buf);
|
|
428
|
+
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
|
429
|
+
* ```
|
|
430
|
+
*
|
|
431
|
+
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
|
432
|
+
* contents will never contain sensitive data from previous allocations, including
|
|
433
|
+
* data that might not have been allocated for `Buffer`s.
|
|
434
|
+
*
|
|
435
|
+
* A `TypeError` will be thrown if `size` is not a number.
|
|
436
|
+
* @since v5.10.0
|
|
437
|
+
* @param size The desired length of the new `Buffer`.
|
|
438
|
+
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
|
439
|
+
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
|
213
440
|
*/
|
|
214
441
|
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
|
215
442
|
/**
|
|
216
|
-
* Allocates a new
|
|
217
|
-
*
|
|
443
|
+
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
|
|
444
|
+
*
|
|
445
|
+
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
446
|
+
* _initialized_. The contents of the newly created `Buffer` are unknown and_may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
|
447
|
+
*
|
|
448
|
+
* ```js
|
|
449
|
+
* import { Buffer } from 'buffer';
|
|
450
|
+
*
|
|
451
|
+
* const buf = Buffer.allocUnsafe(10);
|
|
452
|
+
*
|
|
453
|
+
* console.log(buf);
|
|
454
|
+
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
|
455
|
+
*
|
|
456
|
+
* buf.fill(0);
|
|
457
|
+
*
|
|
458
|
+
* console.log(buf);
|
|
459
|
+
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* A `TypeError` will be thrown if `size` is not a number.
|
|
218
463
|
*
|
|
219
|
-
*
|
|
464
|
+
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
|
465
|
+
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`,`Buffer.from(array)`, `Buffer.concat()`, and the
|
|
466
|
+
* deprecated`new Buffer(size)` constructor only when `size` is less than or equal
|
|
467
|
+
* to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
|
|
468
|
+
*
|
|
469
|
+
* Use of this pre-allocated internal memory pool is a key difference between
|
|
470
|
+
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
|
471
|
+
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
|
472
|
+
* than or equal to half `Buffer.poolSize`. The
|
|
473
|
+
* difference is subtle but can be important when an application requires the
|
|
474
|
+
* additional performance that `Buffer.allocUnsafe()` provides.
|
|
475
|
+
* @since v5.10.0
|
|
476
|
+
* @param size The desired length of the new `Buffer`.
|
|
220
477
|
*/
|
|
221
478
|
allocUnsafe(size: number): Buffer;
|
|
222
479
|
/**
|
|
223
|
-
* Allocates a new
|
|
224
|
-
*
|
|
480
|
+
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. A zero-length `Buffer` is created
|
|
481
|
+
* if `size` is 0.
|
|
482
|
+
*
|
|
483
|
+
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
484
|
+
* _initialized_. The contents of the newly created `Buffer` are unknown and_may contain sensitive data_. Use `buf.fill(0)` to initialize
|
|
485
|
+
* such `Buffer` instances with zeroes.
|
|
486
|
+
*
|
|
487
|
+
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
|
488
|
+
* allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This
|
|
489
|
+
* allows applications to avoid the garbage collection overhead of creating many
|
|
490
|
+
* individually allocated `Buffer` instances. This approach improves both
|
|
491
|
+
* performance and memory usage by eliminating the need to track and clean up as
|
|
492
|
+
* many individual `ArrayBuffer` objects.
|
|
493
|
+
*
|
|
494
|
+
* However, in the case where a developer may need to retain a small chunk of
|
|
495
|
+
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
|
496
|
+
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
|
497
|
+
* then copying out the relevant bits.
|
|
498
|
+
*
|
|
499
|
+
* ```js
|
|
500
|
+
* import { Buffer } from 'buffer';
|
|
501
|
+
*
|
|
502
|
+
* // Need to keep around a few small chunks of memory.
|
|
503
|
+
* const store = [];
|
|
504
|
+
*
|
|
505
|
+
* socket.on('readable', () => {
|
|
506
|
+
* let data;
|
|
507
|
+
* while (null !== (data = readable.read())) {
|
|
508
|
+
* // Allocate for retained data.
|
|
509
|
+
* const sb = Buffer.allocUnsafeSlow(10);
|
|
510
|
+
*
|
|
511
|
+
* // Copy the data into the new allocation.
|
|
512
|
+
* data.copy(sb, 0, 0, 10);
|
|
225
513
|
*
|
|
226
|
-
*
|
|
514
|
+
* store.push(sb);
|
|
515
|
+
* }
|
|
516
|
+
* });
|
|
517
|
+
* ```
|
|
518
|
+
*
|
|
519
|
+
* A `TypeError` will be thrown if `size` is not a number.
|
|
520
|
+
* @since v5.12.0
|
|
521
|
+
* @param size The desired length of the new `Buffer`.
|
|
227
522
|
*/
|
|
228
523
|
allocUnsafeSlow(size: number): Buffer;
|
|
229
524
|
/**
|
|
230
|
-
* This is the
|
|
525
|
+
* This is the size (in bytes) of pre-allocated internal `Buffer` instances used
|
|
526
|
+
* for pooling. This value may be modified.
|
|
527
|
+
* @since v0.11.3
|
|
231
528
|
*/
|
|
232
529
|
poolSize: number;
|
|
233
530
|
}
|
|
234
|
-
|
|
235
531
|
interface Buffer extends Uint8Array {
|
|
532
|
+
/**
|
|
533
|
+
* Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
|
|
534
|
+
* not contain enough space to fit the entire string, only part of `string` will be
|
|
535
|
+
* written. However, partially encoded characters will not be written.
|
|
536
|
+
*
|
|
537
|
+
* ```js
|
|
538
|
+
* import { Buffer } from 'buffer';
|
|
539
|
+
*
|
|
540
|
+
* const buf = Buffer.alloc(256);
|
|
541
|
+
*
|
|
542
|
+
* const len = buf.write('\u00bd + \u00bc = \u00be', 0);
|
|
543
|
+
*
|
|
544
|
+
* console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
|
|
545
|
+
* // Prints: 12 bytes: ½ + ¼ = ¾
|
|
546
|
+
*
|
|
547
|
+
* const buffer = Buffer.alloc(10);
|
|
548
|
+
*
|
|
549
|
+
* const length = buffer.write('abcd', 8);
|
|
550
|
+
*
|
|
551
|
+
* console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
|
|
552
|
+
* // Prints: 2 bytes : ab
|
|
553
|
+
* ```
|
|
554
|
+
* @since v0.1.90
|
|
555
|
+
* @param string String to write to `buf`.
|
|
556
|
+
* @param [offset=0] Number of bytes to skip before starting to write `string`.
|
|
557
|
+
* @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).
|
|
558
|
+
* @param [encoding='utf8'] The character encoding of `string`.
|
|
559
|
+
* @return Number of bytes written.
|
|
560
|
+
*/
|
|
236
561
|
write(string: string, encoding?: BufferEncoding): number;
|
|
237
562
|
write(string: string, offset: number, encoding?: BufferEncoding): number;
|
|
238
563
|
write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
|
|
564
|
+
/**
|
|
565
|
+
* Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`.
|
|
566
|
+
*
|
|
567
|
+
* If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,
|
|
568
|
+
* then each invalid byte is replaced with the replacement character `U+FFFD`.
|
|
569
|
+
*
|
|
570
|
+
* The maximum length of a string instance (in UTF-16 code units) is available
|
|
571
|
+
* as {@link constants.MAX_STRING_LENGTH}.
|
|
572
|
+
*
|
|
573
|
+
* ```js
|
|
574
|
+
* import { Buffer } from 'buffer';
|
|
575
|
+
*
|
|
576
|
+
* const buf1 = Buffer.allocUnsafe(26);
|
|
577
|
+
*
|
|
578
|
+
* for (let i = 0; i < 26; i++) {
|
|
579
|
+
* // 97 is the decimal ASCII value for 'a'.
|
|
580
|
+
* buf1[i] = i + 97;
|
|
581
|
+
* }
|
|
582
|
+
*
|
|
583
|
+
* console.log(buf1.toString('utf8'));
|
|
584
|
+
* // Prints: abcdefghijklmnopqrstuvwxyz
|
|
585
|
+
* console.log(buf1.toString('utf8', 0, 5));
|
|
586
|
+
* // Prints: abcde
|
|
587
|
+
*
|
|
588
|
+
* const buf2 = Buffer.from('tést');
|
|
589
|
+
*
|
|
590
|
+
* console.log(buf2.toString('hex'));
|
|
591
|
+
* // Prints: 74c3a97374
|
|
592
|
+
* console.log(buf2.toString('utf8', 0, 3));
|
|
593
|
+
* // Prints: té
|
|
594
|
+
* console.log(buf2.toString(undefined, 0, 3));
|
|
595
|
+
* // Prints: té
|
|
596
|
+
* ```
|
|
597
|
+
* @since v0.1.90
|
|
598
|
+
* @param [encoding='utf8'] The character encoding to use.
|
|
599
|
+
* @param [start=0] The byte offset to start decoding at.
|
|
600
|
+
* @param [end=buf.length] The byte offset to stop decoding at (not inclusive).
|
|
601
|
+
*/
|
|
239
602
|
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
|
|
240
|
-
|
|
603
|
+
/**
|
|
604
|
+
* Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls
|
|
605
|
+
* this function when stringifying a `Buffer` instance.
|
|
606
|
+
*
|
|
607
|
+
* `Buffer.from()` accepts objects in the format returned from this method.
|
|
608
|
+
* In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
|
|
609
|
+
*
|
|
610
|
+
* ```js
|
|
611
|
+
* import { Buffer } from 'buffer';
|
|
612
|
+
*
|
|
613
|
+
* const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
|
|
614
|
+
* const json = JSON.stringify(buf);
|
|
615
|
+
*
|
|
616
|
+
* console.log(json);
|
|
617
|
+
* // Prints: {"type":"Buffer","data":[1,2,3,4,5]}
|
|
618
|
+
*
|
|
619
|
+
* const copy = JSON.parse(json, (key, value) => {
|
|
620
|
+
* return value && value.type === 'Buffer' ?
|
|
621
|
+
* Buffer.from(value) :
|
|
622
|
+
* value;
|
|
623
|
+
* });
|
|
624
|
+
*
|
|
625
|
+
* console.log(copy);
|
|
626
|
+
* // Prints: <Buffer 01 02 03 04 05>
|
|
627
|
+
* ```
|
|
628
|
+
* @since v0.9.2
|
|
629
|
+
*/
|
|
630
|
+
toJSON(): {
|
|
631
|
+
type: 'Buffer';
|
|
632
|
+
data: number[];
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
|
|
636
|
+
*
|
|
637
|
+
* ```js
|
|
638
|
+
* import { Buffer } from 'buffer';
|
|
639
|
+
*
|
|
640
|
+
* const buf1 = Buffer.from('ABC');
|
|
641
|
+
* const buf2 = Buffer.from('414243', 'hex');
|
|
642
|
+
* const buf3 = Buffer.from('ABCD');
|
|
643
|
+
*
|
|
644
|
+
* console.log(buf1.equals(buf2));
|
|
645
|
+
* // Prints: true
|
|
646
|
+
* console.log(buf1.equals(buf3));
|
|
647
|
+
* // Prints: false
|
|
648
|
+
* ```
|
|
649
|
+
* @since v0.11.13
|
|
650
|
+
* @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`.
|
|
651
|
+
*/
|
|
241
652
|
equals(otherBuffer: Uint8Array): boolean;
|
|
242
|
-
compare(
|
|
243
|
-
otherBuffer: Uint8Array,
|
|
244
|
-
targetStart?: number,
|
|
245
|
-
targetEnd?: number,
|
|
246
|
-
sourceStart?: number,
|
|
247
|
-
sourceEnd?: number
|
|
248
|
-
): number;
|
|
249
|
-
copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
250
653
|
/**
|
|
251
|
-
*
|
|
654
|
+
* Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order.
|
|
655
|
+
* Comparison is based on the actual sequence of bytes in each `Buffer`.
|
|
656
|
+
*
|
|
657
|
+
* * `0` is returned if `target` is the same as `buf`
|
|
658
|
+
* * `1` is returned if `target` should come _before_`buf` when sorted.
|
|
659
|
+
* * `-1` is returned if `target` should come _after_`buf` when sorted.
|
|
660
|
+
*
|
|
661
|
+
* ```js
|
|
662
|
+
* import { Buffer } from 'buffer';
|
|
663
|
+
*
|
|
664
|
+
* const buf1 = Buffer.from('ABC');
|
|
665
|
+
* const buf2 = Buffer.from('BCD');
|
|
666
|
+
* const buf3 = Buffer.from('ABCD');
|
|
667
|
+
*
|
|
668
|
+
* console.log(buf1.compare(buf1));
|
|
669
|
+
* // Prints: 0
|
|
670
|
+
* console.log(buf1.compare(buf2));
|
|
671
|
+
* // Prints: -1
|
|
672
|
+
* console.log(buf1.compare(buf3));
|
|
673
|
+
* // Prints: -1
|
|
674
|
+
* console.log(buf2.compare(buf1));
|
|
675
|
+
* // Prints: 1
|
|
676
|
+
* console.log(buf2.compare(buf3));
|
|
677
|
+
* // Prints: 1
|
|
678
|
+
* console.log([buf1, buf2, buf3].sort(Buffer.compare));
|
|
679
|
+
* // Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]
|
|
680
|
+
* // (This result is equal to: [buf1, buf3, buf2].)
|
|
681
|
+
* ```
|
|
682
|
+
*
|
|
683
|
+
* The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
|
|
684
|
+
*
|
|
685
|
+
* ```js
|
|
686
|
+
* import { Buffer } from 'buffer';
|
|
687
|
+
*
|
|
688
|
+
* const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
|
689
|
+
* const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
|
|
252
690
|
*
|
|
253
|
-
*
|
|
691
|
+
* console.log(buf1.compare(buf2, 5, 9, 0, 4));
|
|
692
|
+
* // Prints: 0
|
|
693
|
+
* console.log(buf1.compare(buf2, 0, 6, 4));
|
|
694
|
+
* // Prints: -1
|
|
695
|
+
* console.log(buf1.compare(buf2, 5, 6, 5));
|
|
696
|
+
* // Prints: 1
|
|
697
|
+
* ```
|
|
254
698
|
*
|
|
255
|
-
*
|
|
256
|
-
* @
|
|
699
|
+
* `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`,`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
|
|
700
|
+
* @since v0.11.13
|
|
701
|
+
* @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.
|
|
702
|
+
* @param [targetStart=0] The offset within `target` at which to begin comparison.
|
|
703
|
+
* @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive).
|
|
704
|
+
* @param [sourceStart=0] The offset within `buf` at which to begin comparison.
|
|
705
|
+
* @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
|
|
257
706
|
*/
|
|
258
|
-
|
|
707
|
+
compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
259
708
|
/**
|
|
260
|
-
*
|
|
709
|
+
* Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
|
|
710
|
+
*
|
|
711
|
+
* [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available
|
|
712
|
+
* for all TypedArrays, including Node.js `Buffer`s, although it takes
|
|
713
|
+
* different function arguments.
|
|
714
|
+
*
|
|
715
|
+
* ```js
|
|
716
|
+
* import { Buffer } from 'buffer';
|
|
717
|
+
*
|
|
718
|
+
* // Create two `Buffer` instances.
|
|
719
|
+
* const buf1 = Buffer.allocUnsafe(26);
|
|
720
|
+
* const buf2 = Buffer.allocUnsafe(26).fill('!');
|
|
721
|
+
*
|
|
722
|
+
* for (let i = 0; i < 26; i++) {
|
|
723
|
+
* // 97 is the decimal ASCII value for 'a'.
|
|
724
|
+
* buf1[i] = i + 97;
|
|
725
|
+
* }
|
|
726
|
+
*
|
|
727
|
+
* // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
|
|
728
|
+
* buf1.copy(buf2, 8, 16, 20);
|
|
729
|
+
* // This is equivalent to:
|
|
730
|
+
* // buf2.set(buf1.subarray(16, 20), 8);
|
|
731
|
+
*
|
|
732
|
+
* console.log(buf2.toString('ascii', 0, 25));
|
|
733
|
+
* // Prints: !!!!!!!!qrst!!!!!!!!!!!!!
|
|
734
|
+
* ```
|
|
735
|
+
*
|
|
736
|
+
* ```js
|
|
737
|
+
* import { Buffer } from 'buffer';
|
|
738
|
+
*
|
|
739
|
+
* // Create a `Buffer` and copy data from one region to an overlapping region
|
|
740
|
+
* // within the same `Buffer`.
|
|
261
741
|
*
|
|
262
|
-
*
|
|
742
|
+
* const buf = Buffer.allocUnsafe(26);
|
|
263
743
|
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
744
|
+
* for (let i = 0; i < 26; i++) {
|
|
745
|
+
* // 97 is the decimal ASCII value for 'a'.
|
|
746
|
+
* buf[i] = i + 97;
|
|
747
|
+
* }
|
|
748
|
+
*
|
|
749
|
+
* buf.copy(buf, 0, 4, 10);
|
|
750
|
+
*
|
|
751
|
+
* console.log(buf.toString());
|
|
752
|
+
* // Prints: efghijghijklmnopqrstuvwxyz
|
|
753
|
+
* ```
|
|
754
|
+
* @since v0.1.90
|
|
755
|
+
* @param target A `Buffer` or {@link Uint8Array} to copy into.
|
|
756
|
+
* @param [targetStart=0] The offset within `target` at which to begin writing.
|
|
757
|
+
* @param [sourceStart=0] The offset within `buf` from which to begin copying.
|
|
758
|
+
* @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).
|
|
759
|
+
* @return The number of bytes copied.
|
|
760
|
+
*/
|
|
761
|
+
copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
762
|
+
/**
|
|
763
|
+
* Returns a new `Buffer` that references the same memory as the original, but
|
|
764
|
+
* offset and cropped by the `start` and `end` indices.
|
|
765
|
+
*
|
|
766
|
+
* This is the same behavior as `buf.subarray()`.
|
|
767
|
+
*
|
|
768
|
+
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
|
769
|
+
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
|
770
|
+
*
|
|
771
|
+
* ```js
|
|
772
|
+
* import { Buffer } from 'buffer';
|
|
773
|
+
*
|
|
774
|
+
* const buf = Buffer.from('buffer');
|
|
775
|
+
*
|
|
776
|
+
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
|
777
|
+
* copiedBuf[0]++;
|
|
778
|
+
* console.log(copiedBuf.toString());
|
|
779
|
+
* // Prints: cuffer
|
|
780
|
+
*
|
|
781
|
+
* console.log(buf.toString());
|
|
782
|
+
* // Prints: buffer
|
|
783
|
+
* ```
|
|
784
|
+
* @since v0.3.0
|
|
785
|
+
* @param [start=0] Where the new `Buffer` will start.
|
|
786
|
+
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
|
787
|
+
*/
|
|
788
|
+
slice(start?: number, end?: number): Buffer;
|
|
789
|
+
/**
|
|
790
|
+
* Returns a new `Buffer` that references the same memory as the original, but
|
|
791
|
+
* offset and cropped by the `start` and `end` indices.
|
|
792
|
+
*
|
|
793
|
+
* Specifying `end` greater than `buf.length` will return the same result as
|
|
794
|
+
* that of `end` equal to `buf.length`.
|
|
795
|
+
*
|
|
796
|
+
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
|
797
|
+
*
|
|
798
|
+
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
|
799
|
+
*
|
|
800
|
+
* ```js
|
|
801
|
+
* import { Buffer } from 'buffer';
|
|
802
|
+
*
|
|
803
|
+
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
|
804
|
+
* // from the original `Buffer`.
|
|
805
|
+
*
|
|
806
|
+
* const buf1 = Buffer.allocUnsafe(26);
|
|
807
|
+
*
|
|
808
|
+
* for (let i = 0; i < 26; i++) {
|
|
809
|
+
* // 97 is the decimal ASCII value for 'a'.
|
|
810
|
+
* buf1[i] = i + 97;
|
|
811
|
+
* }
|
|
812
|
+
*
|
|
813
|
+
* const buf2 = buf1.subarray(0, 3);
|
|
814
|
+
*
|
|
815
|
+
* console.log(buf2.toString('ascii', 0, buf2.length));
|
|
816
|
+
* // Prints: abc
|
|
817
|
+
*
|
|
818
|
+
* buf1[0] = 33;
|
|
819
|
+
*
|
|
820
|
+
* console.log(buf2.toString('ascii', 0, buf2.length));
|
|
821
|
+
* // Prints: !bc
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* Specifying negative indexes causes the slice to be generated relative to the
|
|
825
|
+
* end of `buf` rather than the beginning.
|
|
826
|
+
*
|
|
827
|
+
* ```js
|
|
828
|
+
* import { Buffer } from 'buffer';
|
|
829
|
+
*
|
|
830
|
+
* const buf = Buffer.from('buffer');
|
|
831
|
+
*
|
|
832
|
+
* console.log(buf.subarray(-6, -1).toString());
|
|
833
|
+
* // Prints: buffe
|
|
834
|
+
* // (Equivalent to buf.subarray(0, 5).)
|
|
835
|
+
*
|
|
836
|
+
* console.log(buf.subarray(-6, -2).toString());
|
|
837
|
+
* // Prints: buff
|
|
838
|
+
* // (Equivalent to buf.subarray(0, 4).)
|
|
839
|
+
*
|
|
840
|
+
* console.log(buf.subarray(-5, -2).toString());
|
|
841
|
+
* // Prints: uff
|
|
842
|
+
* // (Equivalent to buf.subarray(1, 4).)
|
|
843
|
+
* ```
|
|
844
|
+
* @since v3.0.0
|
|
845
|
+
* @param [start=0] Where the new `Buffer` will start.
|
|
846
|
+
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
|
847
|
+
*/
|
|
848
|
+
subarray(start?: number, end?: number): Buffer;
|
|
849
|
+
/**
|
|
850
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian.
|
|
851
|
+
*
|
|
852
|
+
* `value` is interpreted and written as a two's complement signed integer.
|
|
853
|
+
*
|
|
854
|
+
* ```js
|
|
855
|
+
* import { Buffer } from 'buffer';
|
|
856
|
+
*
|
|
857
|
+
* const buf = Buffer.allocUnsafe(8);
|
|
858
|
+
*
|
|
859
|
+
* buf.writeBigInt64BE(0x0102030405060708n, 0);
|
|
860
|
+
*
|
|
861
|
+
* console.log(buf);
|
|
862
|
+
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
|
863
|
+
* ```
|
|
864
|
+
* @since v12.0.0, v10.20.0
|
|
865
|
+
* @param value Number to be written to `buf`.
|
|
866
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
867
|
+
* @return `offset` plus the number of bytes written.
|
|
266
868
|
*/
|
|
267
|
-
subarray(begin?: number, end?: number): Buffer;
|
|
268
869
|
writeBigInt64BE(value: bigint, offset?: number): number;
|
|
870
|
+
/**
|
|
871
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian.
|
|
872
|
+
*
|
|
873
|
+
* `value` is interpreted and written as a two's complement signed integer.
|
|
874
|
+
*
|
|
875
|
+
* ```js
|
|
876
|
+
* import { Buffer } from 'buffer';
|
|
877
|
+
*
|
|
878
|
+
* const buf = Buffer.allocUnsafe(8);
|
|
879
|
+
*
|
|
880
|
+
* buf.writeBigInt64LE(0x0102030405060708n, 0);
|
|
881
|
+
*
|
|
882
|
+
* console.log(buf);
|
|
883
|
+
* // Prints: <Buffer 08 07 06 05 04 03 02 01>
|
|
884
|
+
* ```
|
|
885
|
+
* @since v12.0.0, v10.20.0
|
|
886
|
+
* @param value Number to be written to `buf`.
|
|
887
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
888
|
+
* @return `offset` plus the number of bytes written.
|
|
889
|
+
*/
|
|
269
890
|
writeBigInt64LE(value: bigint, offset?: number): number;
|
|
891
|
+
/**
|
|
892
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian.
|
|
893
|
+
*
|
|
894
|
+
* This function is also available under the `writeBigUint64BE` alias.
|
|
895
|
+
*
|
|
896
|
+
* ```js
|
|
897
|
+
* import { Buffer } from 'buffer';
|
|
898
|
+
*
|
|
899
|
+
* const buf = Buffer.allocUnsafe(8);
|
|
900
|
+
*
|
|
901
|
+
* buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
|
|
902
|
+
*
|
|
903
|
+
* console.log(buf);
|
|
904
|
+
* // Prints: <Buffer de ca fa fe ca ce fa de>
|
|
905
|
+
* ```
|
|
906
|
+
* @since v12.0.0, v10.20.0
|
|
907
|
+
* @param value Number to be written to `buf`.
|
|
908
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
909
|
+
* @return `offset` plus the number of bytes written.
|
|
910
|
+
*/
|
|
270
911
|
writeBigUInt64BE(value: bigint, offset?: number): number;
|
|
912
|
+
/**
|
|
913
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian
|
|
914
|
+
*
|
|
915
|
+
* ```js
|
|
916
|
+
* import { Buffer } from 'buffer';
|
|
917
|
+
*
|
|
918
|
+
* const buf = Buffer.allocUnsafe(8);
|
|
919
|
+
*
|
|
920
|
+
* buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
|
|
921
|
+
*
|
|
922
|
+
* console.log(buf);
|
|
923
|
+
* // Prints: <Buffer de fa ce ca fe fa ca de>
|
|
924
|
+
* ```
|
|
925
|
+
*
|
|
926
|
+
* This function is also available under the `writeBigUint64LE` alias.
|
|
927
|
+
* @since v12.0.0, v10.20.0
|
|
928
|
+
* @param value Number to be written to `buf`.
|
|
929
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
930
|
+
* @return `offset` plus the number of bytes written.
|
|
931
|
+
*/
|
|
271
932
|
writeBigUInt64LE(value: bigint, offset?: number): number;
|
|
933
|
+
/**
|
|
934
|
+
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
|
|
935
|
+
* when `value` is anything other than an unsigned integer.
|
|
936
|
+
*
|
|
937
|
+
* This function is also available under the `writeUintLE` alias.
|
|
938
|
+
*
|
|
939
|
+
* ```js
|
|
940
|
+
* import { Buffer } from 'buffer';
|
|
941
|
+
*
|
|
942
|
+
* const buf = Buffer.allocUnsafe(6);
|
|
943
|
+
*
|
|
944
|
+
* buf.writeUIntLE(0x1234567890ab, 0, 6);
|
|
945
|
+
*
|
|
946
|
+
* console.log(buf);
|
|
947
|
+
* // Prints: <Buffer ab 90 78 56 34 12>
|
|
948
|
+
* ```
|
|
949
|
+
* @since v0.5.5
|
|
950
|
+
* @param value Number to be written to `buf`.
|
|
951
|
+
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
952
|
+
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
|
953
|
+
* @return `offset` plus the number of bytes written.
|
|
954
|
+
*/
|
|
272
955
|
writeUIntLE(value: number, offset: number, byteLength: number): number;
|
|
956
|
+
/**
|
|
957
|
+
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined
|
|
958
|
+
* when `value` is anything other than an unsigned integer.
|
|
959
|
+
*
|
|
960
|
+
* This function is also available under the `writeUintBE` alias.
|
|
961
|
+
*
|
|
962
|
+
* ```js
|
|
963
|
+
* import { Buffer } from 'buffer';
|
|
964
|
+
*
|
|
965
|
+
* const buf = Buffer.allocUnsafe(6);
|
|
966
|
+
*
|
|
967
|
+
* buf.writeUIntBE(0x1234567890ab, 0, 6);
|
|
968
|
+
*
|
|
969
|
+
* console.log(buf);
|
|
970
|
+
* // Prints: <Buffer 12 34 56 78 90 ab>
|
|
971
|
+
* ```
|
|
972
|
+
* @since v0.5.5
|
|
973
|
+
* @param value Number to be written to `buf`.
|
|
974
|
+
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
975
|
+
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
|
976
|
+
* @return `offset` plus the number of bytes written.
|
|
977
|
+
*/
|
|
273
978
|
writeUIntBE(value: number, offset: number, byteLength: number): number;
|
|
979
|
+
/**
|
|
980
|
+
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
|
|
981
|
+
* when `value` is anything other than a signed integer.
|
|
982
|
+
*
|
|
983
|
+
* ```js
|
|
984
|
+
* import { Buffer } from 'buffer';
|
|
985
|
+
*
|
|
986
|
+
* const buf = Buffer.allocUnsafe(6);
|
|
987
|
+
*
|
|
988
|
+
* buf.writeIntLE(0x1234567890ab, 0, 6);
|
|
989
|
+
*
|
|
990
|
+
* console.log(buf);
|
|
991
|
+
* // Prints: <Buffer ab 90 78 56 34 12>
|
|
992
|
+
* ```
|
|
993
|
+
* @since v0.11.15
|
|
994
|
+
* @param value Number to be written to `buf`.
|
|
995
|
+
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
996
|
+
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
|
997
|
+
* @return `offset` plus the number of bytes written.
|
|
998
|
+
*/
|
|
274
999
|
writeIntLE(value: number, offset: number, byteLength: number): number;
|
|
1000
|
+
/**
|
|
1001
|
+
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a
|
|
1002
|
+
* signed integer.
|
|
1003
|
+
*
|
|
1004
|
+
* ```js
|
|
1005
|
+
* import { Buffer } from 'buffer';
|
|
1006
|
+
*
|
|
1007
|
+
* const buf = Buffer.allocUnsafe(6);
|
|
1008
|
+
*
|
|
1009
|
+
* buf.writeIntBE(0x1234567890ab, 0, 6);
|
|
1010
|
+
*
|
|
1011
|
+
* console.log(buf);
|
|
1012
|
+
* // Prints: <Buffer 12 34 56 78 90 ab>
|
|
1013
|
+
* ```
|
|
1014
|
+
* @since v0.11.15
|
|
1015
|
+
* @param value Number to be written to `buf`.
|
|
1016
|
+
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
1017
|
+
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
|
1018
|
+
* @return `offset` plus the number of bytes written.
|
|
1019
|
+
*/
|
|
275
1020
|
writeIntBE(value: number, offset: number, byteLength: number): number;
|
|
1021
|
+
/**
|
|
1022
|
+
* Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.
|
|
1023
|
+
*
|
|
1024
|
+
* This function is also available under the `readBigUint64BE` alias.
|
|
1025
|
+
*
|
|
1026
|
+
* ```js
|
|
1027
|
+
* import { Buffer } from 'buffer';
|
|
1028
|
+
*
|
|
1029
|
+
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
|
1030
|
+
*
|
|
1031
|
+
* console.log(buf.readBigUInt64BE(0));
|
|
1032
|
+
* // Prints: 4294967295n
|
|
1033
|
+
* ```
|
|
1034
|
+
* @since v12.0.0, v10.20.0
|
|
1035
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
1036
|
+
*/
|
|
276
1037
|
readBigUInt64BE(offset?: number): bigint;
|
|
1038
|
+
/**
|
|
1039
|
+
* Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.
|
|
1040
|
+
*
|
|
1041
|
+
* This function is also available under the `readBigUint64LE` alias.
|
|
1042
|
+
*
|
|
1043
|
+
* ```js
|
|
1044
|
+
* import { Buffer } from 'buffer';
|
|
1045
|
+
*
|
|
1046
|
+
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
|
1047
|
+
*
|
|
1048
|
+
* console.log(buf.readBigUInt64LE(0));
|
|
1049
|
+
* // Prints: 18446744069414584320n
|
|
1050
|
+
* ```
|
|
1051
|
+
* @since v12.0.0, v10.20.0
|
|
1052
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
1053
|
+
*/
|
|
277
1054
|
readBigUInt64LE(offset?: number): bigint;
|
|
1055
|
+
/**
|
|
1056
|
+
* Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.
|
|
1057
|
+
*
|
|
1058
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed
|
|
1059
|
+
* values.
|
|
1060
|
+
* @since v12.0.0, v10.20.0
|
|
1061
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
1062
|
+
*/
|
|
278
1063
|
readBigInt64BE(offset?: number): bigint;
|
|
1064
|
+
/**
|
|
1065
|
+
* Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.
|
|
1066
|
+
*
|
|
1067
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed
|
|
1068
|
+
* values.
|
|
1069
|
+
* @since v12.0.0, v10.20.0
|
|
1070
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
|
1071
|
+
*/
|
|
279
1072
|
readBigInt64LE(offset?: number): bigint;
|
|
1073
|
+
/**
|
|
1074
|
+
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned, little-endian integer supporting
|
|
1075
|
+
* up to 48 bits of accuracy.
|
|
1076
|
+
*
|
|
1077
|
+
* This function is also available under the `readUintLE` alias.
|
|
1078
|
+
*
|
|
1079
|
+
* ```js
|
|
1080
|
+
* import { Buffer } from 'buffer';
|
|
1081
|
+
*
|
|
1082
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1083
|
+
*
|
|
1084
|
+
* console.log(buf.readUIntLE(0, 6).toString(16));
|
|
1085
|
+
* // Prints: ab9078563412
|
|
1086
|
+
* ```
|
|
1087
|
+
* @since v0.11.15
|
|
1088
|
+
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
1089
|
+
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
|
1090
|
+
*/
|
|
280
1091
|
readUIntLE(offset: number, byteLength: number): number;
|
|
1092
|
+
/**
|
|
1093
|
+
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned big-endian integer supporting
|
|
1094
|
+
* up to 48 bits of accuracy.
|
|
1095
|
+
*
|
|
1096
|
+
* This function is also available under the `readUintBE` alias.
|
|
1097
|
+
*
|
|
1098
|
+
* ```js
|
|
1099
|
+
* import { Buffer } from 'buffer';
|
|
1100
|
+
*
|
|
1101
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1102
|
+
*
|
|
1103
|
+
* console.log(buf.readUIntBE(0, 6).toString(16));
|
|
1104
|
+
* // Prints: 1234567890ab
|
|
1105
|
+
* console.log(buf.readUIntBE(1, 6).toString(16));
|
|
1106
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1107
|
+
* ```
|
|
1108
|
+
* @since v0.11.15
|
|
1109
|
+
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
1110
|
+
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
|
1111
|
+
*/
|
|
281
1112
|
readUIntBE(offset: number, byteLength: number): number;
|
|
1113
|
+
/**
|
|
1114
|
+
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a little-endian, two's complement signed value
|
|
1115
|
+
* supporting up to 48 bits of accuracy.
|
|
1116
|
+
*
|
|
1117
|
+
* ```js
|
|
1118
|
+
* import { Buffer } from 'buffer';
|
|
1119
|
+
*
|
|
1120
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1121
|
+
*
|
|
1122
|
+
* console.log(buf.readIntLE(0, 6).toString(16));
|
|
1123
|
+
* // Prints: -546f87a9cbee
|
|
1124
|
+
* ```
|
|
1125
|
+
* @since v0.11.15
|
|
1126
|
+
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
1127
|
+
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
|
1128
|
+
*/
|
|
282
1129
|
readIntLE(offset: number, byteLength: number): number;
|
|
1130
|
+
/**
|
|
1131
|
+
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a big-endian, two's complement signed value
|
|
1132
|
+
* supporting up to 48 bits of accuracy.
|
|
1133
|
+
*
|
|
1134
|
+
* ```js
|
|
1135
|
+
* import { Buffer } from 'buffer';
|
|
1136
|
+
*
|
|
1137
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1138
|
+
*
|
|
1139
|
+
* console.log(buf.readIntBE(0, 6).toString(16));
|
|
1140
|
+
* // Prints: 1234567890ab
|
|
1141
|
+
* console.log(buf.readIntBE(1, 6).toString(16));
|
|
1142
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1143
|
+
* console.log(buf.readIntBE(1, 0).toString(16));
|
|
1144
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1145
|
+
* ```
|
|
1146
|
+
* @since v0.11.15
|
|
1147
|
+
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
|
1148
|
+
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
|
1149
|
+
*/
|
|
283
1150
|
readIntBE(offset: number, byteLength: number): number;
|
|
1151
|
+
/**
|
|
1152
|
+
* Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
|
|
1153
|
+
*
|
|
1154
|
+
* This function is also available under the `readUint8` alias.
|
|
1155
|
+
*
|
|
1156
|
+
* ```js
|
|
1157
|
+
* import { Buffer } from 'buffer';
|
|
1158
|
+
*
|
|
1159
|
+
* const buf = Buffer.from([1, -2]);
|
|
1160
|
+
*
|
|
1161
|
+
* console.log(buf.readUInt8(0));
|
|
1162
|
+
* // Prints: 1
|
|
1163
|
+
* console.log(buf.readUInt8(1));
|
|
1164
|
+
* // Prints: 254
|
|
1165
|
+
* console.log(buf.readUInt8(2));
|
|
1166
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1167
|
+
* ```
|
|
1168
|
+
* @since v0.5.0
|
|
1169
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
|
|
1170
|
+
*/
|
|
284
1171
|
readUInt8(offset?: number): number;
|
|
1172
|
+
/**
|
|
1173
|
+
* Reads an unsigned, little-endian 16-bit integer from `buf` at the specified`offset`.
|
|
1174
|
+
*
|
|
1175
|
+
* This function is also available under the `readUint16LE` alias.
|
|
1176
|
+
*
|
|
1177
|
+
* ```js
|
|
1178
|
+
* import { Buffer } from 'buffer';
|
|
1179
|
+
*
|
|
1180
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
|
1181
|
+
*
|
|
1182
|
+
* console.log(buf.readUInt16LE(0).toString(16));
|
|
1183
|
+
* // Prints: 3412
|
|
1184
|
+
* console.log(buf.readUInt16LE(1).toString(16));
|
|
1185
|
+
* // Prints: 5634
|
|
1186
|
+
* console.log(buf.readUInt16LE(2).toString(16));
|
|
1187
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1188
|
+
* ```
|
|
1189
|
+
* @since v0.5.5
|
|
1190
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1191
|
+
*/
|
|
285
1192
|
readUInt16LE(offset?: number): number;
|
|
1193
|
+
/**
|
|
1194
|
+
* Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.
|
|
1195
|
+
*
|
|
1196
|
+
* This function is also available under the `readUint16BE` alias.
|
|
1197
|
+
*
|
|
1198
|
+
* ```js
|
|
1199
|
+
* import { Buffer } from 'buffer';
|
|
1200
|
+
*
|
|
1201
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
|
1202
|
+
*
|
|
1203
|
+
* console.log(buf.readUInt16BE(0).toString(16));
|
|
1204
|
+
* // Prints: 1234
|
|
1205
|
+
* console.log(buf.readUInt16BE(1).toString(16));
|
|
1206
|
+
* // Prints: 3456
|
|
1207
|
+
* ```
|
|
1208
|
+
* @since v0.5.5
|
|
1209
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1210
|
+
*/
|
|
286
1211
|
readUInt16BE(offset?: number): number;
|
|
1212
|
+
/**
|
|
1213
|
+
* Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.
|
|
1214
|
+
*
|
|
1215
|
+
* This function is also available under the `readUint32LE` alias.
|
|
1216
|
+
*
|
|
1217
|
+
* ```js
|
|
1218
|
+
* import { Buffer } from 'buffer';
|
|
1219
|
+
*
|
|
1220
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
1221
|
+
*
|
|
1222
|
+
* console.log(buf.readUInt32LE(0).toString(16));
|
|
1223
|
+
* // Prints: 78563412
|
|
1224
|
+
* console.log(buf.readUInt32LE(1).toString(16));
|
|
1225
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1226
|
+
* ```
|
|
1227
|
+
* @since v0.5.5
|
|
1228
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1229
|
+
*/
|
|
287
1230
|
readUInt32LE(offset?: number): number;
|
|
1231
|
+
/**
|
|
1232
|
+
* Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`.
|
|
1233
|
+
*
|
|
1234
|
+
* This function is also available under the `readUint32BE` alias.
|
|
1235
|
+
*
|
|
1236
|
+
* ```js
|
|
1237
|
+
* import { Buffer } from 'buffer';
|
|
1238
|
+
*
|
|
1239
|
+
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
1240
|
+
*
|
|
1241
|
+
* console.log(buf.readUInt32BE(0).toString(16));
|
|
1242
|
+
* // Prints: 12345678
|
|
1243
|
+
* ```
|
|
1244
|
+
* @since v0.5.5
|
|
1245
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1246
|
+
*/
|
|
288
1247
|
readUInt32BE(offset?: number): number;
|
|
1248
|
+
/**
|
|
1249
|
+
* Reads a signed 8-bit integer from `buf` at the specified `offset`.
|
|
1250
|
+
*
|
|
1251
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1252
|
+
*
|
|
1253
|
+
* ```js
|
|
1254
|
+
* import { Buffer } from 'buffer';
|
|
1255
|
+
*
|
|
1256
|
+
* const buf = Buffer.from([-1, 5]);
|
|
1257
|
+
*
|
|
1258
|
+
* console.log(buf.readInt8(0));
|
|
1259
|
+
* // Prints: -1
|
|
1260
|
+
* console.log(buf.readInt8(1));
|
|
1261
|
+
* // Prints: 5
|
|
1262
|
+
* console.log(buf.readInt8(2));
|
|
1263
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1264
|
+
* ```
|
|
1265
|
+
* @since v0.5.0
|
|
1266
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
|
|
1267
|
+
*/
|
|
289
1268
|
readInt8(offset?: number): number;
|
|
1269
|
+
/**
|
|
1270
|
+
* Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.
|
|
1271
|
+
*
|
|
1272
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1273
|
+
*
|
|
1274
|
+
* ```js
|
|
1275
|
+
* import { Buffer } from 'buffer';
|
|
1276
|
+
*
|
|
1277
|
+
* const buf = Buffer.from([0, 5]);
|
|
1278
|
+
*
|
|
1279
|
+
* console.log(buf.readInt16LE(0));
|
|
1280
|
+
* // Prints: 1280
|
|
1281
|
+
* console.log(buf.readInt16LE(1));
|
|
1282
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1283
|
+
* ```
|
|
1284
|
+
* @since v0.5.5
|
|
1285
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1286
|
+
*/
|
|
290
1287
|
readInt16LE(offset?: number): number;
|
|
1288
|
+
/**
|
|
1289
|
+
* Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.
|
|
1290
|
+
*
|
|
1291
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1292
|
+
*
|
|
1293
|
+
* ```js
|
|
1294
|
+
* import { Buffer } from 'buffer';
|
|
1295
|
+
*
|
|
1296
|
+
* const buf = Buffer.from([0, 5]);
|
|
1297
|
+
*
|
|
1298
|
+
* console.log(buf.readInt16BE(0));
|
|
1299
|
+
* // Prints: 5
|
|
1300
|
+
* ```
|
|
1301
|
+
* @since v0.5.5
|
|
1302
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1303
|
+
*/
|
|
291
1304
|
readInt16BE(offset?: number): number;
|
|
1305
|
+
/**
|
|
1306
|
+
* Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.
|
|
1307
|
+
*
|
|
1308
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1309
|
+
*
|
|
1310
|
+
* ```js
|
|
1311
|
+
* import { Buffer } from 'buffer';
|
|
1312
|
+
*
|
|
1313
|
+
* const buf = Buffer.from([0, 0, 0, 5]);
|
|
1314
|
+
*
|
|
1315
|
+
* console.log(buf.readInt32LE(0));
|
|
1316
|
+
* // Prints: 83886080
|
|
1317
|
+
* console.log(buf.readInt32LE(1));
|
|
1318
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1319
|
+
* ```
|
|
1320
|
+
* @since v0.5.5
|
|
1321
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1322
|
+
*/
|
|
292
1323
|
readInt32LE(offset?: number): number;
|
|
1324
|
+
/**
|
|
1325
|
+
* Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.
|
|
1326
|
+
*
|
|
1327
|
+
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1328
|
+
*
|
|
1329
|
+
* ```js
|
|
1330
|
+
* import { Buffer } from 'buffer';
|
|
1331
|
+
*
|
|
1332
|
+
* const buf = Buffer.from([0, 0, 0, 5]);
|
|
1333
|
+
*
|
|
1334
|
+
* console.log(buf.readInt32BE(0));
|
|
1335
|
+
* // Prints: 5
|
|
1336
|
+
* ```
|
|
1337
|
+
* @since v0.5.5
|
|
1338
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1339
|
+
*/
|
|
293
1340
|
readInt32BE(offset?: number): number;
|
|
1341
|
+
/**
|
|
1342
|
+
* Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
|
|
1343
|
+
*
|
|
1344
|
+
* ```js
|
|
1345
|
+
* import { Buffer } from 'buffer';
|
|
1346
|
+
*
|
|
1347
|
+
* const buf = Buffer.from([1, 2, 3, 4]);
|
|
1348
|
+
*
|
|
1349
|
+
* console.log(buf.readFloatLE(0));
|
|
1350
|
+
* // Prints: 1.539989614439558e-36
|
|
1351
|
+
* console.log(buf.readFloatLE(1));
|
|
1352
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1353
|
+
* ```
|
|
1354
|
+
* @since v0.11.15
|
|
1355
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1356
|
+
*/
|
|
294
1357
|
readFloatLE(offset?: number): number;
|
|
1358
|
+
/**
|
|
1359
|
+
* Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
|
|
1360
|
+
*
|
|
1361
|
+
* ```js
|
|
1362
|
+
* import { Buffer } from 'buffer';
|
|
1363
|
+
*
|
|
1364
|
+
* const buf = Buffer.from([1, 2, 3, 4]);
|
|
1365
|
+
*
|
|
1366
|
+
* console.log(buf.readFloatBE(0));
|
|
1367
|
+
* // Prints: 2.387939260590663e-38
|
|
1368
|
+
* ```
|
|
1369
|
+
* @since v0.11.15
|
|
1370
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1371
|
+
*/
|
|
295
1372
|
readFloatBE(offset?: number): number;
|
|
1373
|
+
/**
|
|
1374
|
+
* Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
|
|
1375
|
+
*
|
|
1376
|
+
* ```js
|
|
1377
|
+
* import { Buffer } from 'buffer';
|
|
1378
|
+
*
|
|
1379
|
+
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
1380
|
+
*
|
|
1381
|
+
* console.log(buf.readDoubleLE(0));
|
|
1382
|
+
* // Prints: 5.447603722011605e-270
|
|
1383
|
+
* console.log(buf.readDoubleLE(1));
|
|
1384
|
+
* // Throws ERR_OUT_OF_RANGE.
|
|
1385
|
+
* ```
|
|
1386
|
+
* @since v0.11.15
|
|
1387
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
|
|
1388
|
+
*/
|
|
296
1389
|
readDoubleLE(offset?: number): number;
|
|
1390
|
+
/**
|
|
1391
|
+
* Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
|
|
1392
|
+
*
|
|
1393
|
+
* ```js
|
|
1394
|
+
* import { Buffer } from 'buffer';
|
|
1395
|
+
*
|
|
1396
|
+
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
1397
|
+
*
|
|
1398
|
+
* console.log(buf.readDoubleBE(0));
|
|
1399
|
+
* // Prints: 8.20788039913184e-304
|
|
1400
|
+
* ```
|
|
1401
|
+
* @since v0.11.15
|
|
1402
|
+
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
|
|
1403
|
+
*/
|
|
297
1404
|
readDoubleBE(offset?: number): number;
|
|
298
1405
|
reverse(): this;
|
|
1406
|
+
/**
|
|
1407
|
+
* Interprets `buf` as an array of unsigned 16-bit integers and swaps the
|
|
1408
|
+
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
|
|
1409
|
+
*
|
|
1410
|
+
* ```js
|
|
1411
|
+
* import { Buffer } from 'buffer';
|
|
1412
|
+
*
|
|
1413
|
+
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1414
|
+
*
|
|
1415
|
+
* console.log(buf1);
|
|
1416
|
+
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
|
1417
|
+
*
|
|
1418
|
+
* buf1.swap16();
|
|
1419
|
+
*
|
|
1420
|
+
* console.log(buf1);
|
|
1421
|
+
* // Prints: <Buffer 02 01 04 03 06 05 08 07>
|
|
1422
|
+
*
|
|
1423
|
+
* const buf2 = Buffer.from([0x1, 0x2, 0x3]);
|
|
1424
|
+
*
|
|
1425
|
+
* buf2.swap16();
|
|
1426
|
+
* // Throws ERR_INVALID_BUFFER_SIZE.
|
|
1427
|
+
* ```
|
|
1428
|
+
*
|
|
1429
|
+
* One convenient use of `buf.swap16()` is to perform a fast in-place conversion
|
|
1430
|
+
* between UTF-16 little-endian and UTF-16 big-endian:
|
|
1431
|
+
*
|
|
1432
|
+
* ```js
|
|
1433
|
+
* import { Buffer } from 'buffer';
|
|
1434
|
+
*
|
|
1435
|
+
* const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
|
|
1436
|
+
* buf.swap16(); // Convert to big-endian UTF-16 text.
|
|
1437
|
+
* ```
|
|
1438
|
+
* @since v5.10.0
|
|
1439
|
+
* @return A reference to `buf`.
|
|
1440
|
+
*/
|
|
299
1441
|
swap16(): Buffer;
|
|
1442
|
+
/**
|
|
1443
|
+
* Interprets `buf` as an array of unsigned 32-bit integers and swaps the
|
|
1444
|
+
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
|
|
1445
|
+
*
|
|
1446
|
+
* ```js
|
|
1447
|
+
* import { Buffer } from 'buffer';
|
|
1448
|
+
*
|
|
1449
|
+
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1450
|
+
*
|
|
1451
|
+
* console.log(buf1);
|
|
1452
|
+
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
|
1453
|
+
*
|
|
1454
|
+
* buf1.swap32();
|
|
1455
|
+
*
|
|
1456
|
+
* console.log(buf1);
|
|
1457
|
+
* // Prints: <Buffer 04 03 02 01 08 07 06 05>
|
|
1458
|
+
*
|
|
1459
|
+
* const buf2 = Buffer.from([0x1, 0x2, 0x3]);
|
|
1460
|
+
*
|
|
1461
|
+
* buf2.swap32();
|
|
1462
|
+
* // Throws ERR_INVALID_BUFFER_SIZE.
|
|
1463
|
+
* ```
|
|
1464
|
+
* @since v5.10.0
|
|
1465
|
+
* @return A reference to `buf`.
|
|
1466
|
+
*/
|
|
300
1467
|
swap32(): Buffer;
|
|
1468
|
+
/**
|
|
1469
|
+
* Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
|
|
1470
|
+
* Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
|
|
1471
|
+
*
|
|
1472
|
+
* ```js
|
|
1473
|
+
* import { Buffer } from 'buffer';
|
|
1474
|
+
*
|
|
1475
|
+
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1476
|
+
*
|
|
1477
|
+
* console.log(buf1);
|
|
1478
|
+
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
|
1479
|
+
*
|
|
1480
|
+
* buf1.swap64();
|
|
1481
|
+
*
|
|
1482
|
+
* console.log(buf1);
|
|
1483
|
+
* // Prints: <Buffer 08 07 06 05 04 03 02 01>
|
|
1484
|
+
*
|
|
1485
|
+
* const buf2 = Buffer.from([0x1, 0x2, 0x3]);
|
|
1486
|
+
*
|
|
1487
|
+
* buf2.swap64();
|
|
1488
|
+
* // Throws ERR_INVALID_BUFFER_SIZE.
|
|
1489
|
+
* ```
|
|
1490
|
+
* @since v6.3.0
|
|
1491
|
+
* @return A reference to `buf`.
|
|
1492
|
+
*/
|
|
301
1493
|
swap64(): Buffer;
|
|
1494
|
+
/**
|
|
1495
|
+
* Writes `value` to `buf` at the specified `offset`. `value` must be a
|
|
1496
|
+
* valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
|
|
1497
|
+
* other than an unsigned 8-bit integer.
|
|
1498
|
+
*
|
|
1499
|
+
* This function is also available under the `writeUint8` alias.
|
|
1500
|
+
*
|
|
1501
|
+
* ```js
|
|
1502
|
+
* import { Buffer } from 'buffer';
|
|
1503
|
+
*
|
|
1504
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1505
|
+
*
|
|
1506
|
+
* buf.writeUInt8(0x3, 0);
|
|
1507
|
+
* buf.writeUInt8(0x4, 1);
|
|
1508
|
+
* buf.writeUInt8(0x23, 2);
|
|
1509
|
+
* buf.writeUInt8(0x42, 3);
|
|
1510
|
+
*
|
|
1511
|
+
* console.log(buf);
|
|
1512
|
+
* // Prints: <Buffer 03 04 23 42>
|
|
1513
|
+
* ```
|
|
1514
|
+
* @since v0.5.0
|
|
1515
|
+
* @param value Number to be written to `buf`.
|
|
1516
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
|
|
1517
|
+
* @return `offset` plus the number of bytes written.
|
|
1518
|
+
*/
|
|
302
1519
|
writeUInt8(value: number, offset?: number): number;
|
|
1520
|
+
/**
|
|
1521
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
|
|
1522
|
+
* anything other than an unsigned 16-bit integer.
|
|
1523
|
+
*
|
|
1524
|
+
* This function is also available under the `writeUint16LE` alias.
|
|
1525
|
+
*
|
|
1526
|
+
* ```js
|
|
1527
|
+
* import { Buffer } from 'buffer';
|
|
1528
|
+
*
|
|
1529
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1530
|
+
*
|
|
1531
|
+
* buf.writeUInt16LE(0xdead, 0);
|
|
1532
|
+
* buf.writeUInt16LE(0xbeef, 2);
|
|
1533
|
+
*
|
|
1534
|
+
* console.log(buf);
|
|
1535
|
+
* // Prints: <Buffer ad de ef be>
|
|
1536
|
+
* ```
|
|
1537
|
+
* @since v0.5.5
|
|
1538
|
+
* @param value Number to be written to `buf`.
|
|
1539
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1540
|
+
* @return `offset` plus the number of bytes written.
|
|
1541
|
+
*/
|
|
303
1542
|
writeUInt16LE(value: number, offset?: number): number;
|
|
1543
|
+
/**
|
|
1544
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
|
|
1545
|
+
* unsigned 16-bit integer.
|
|
1546
|
+
*
|
|
1547
|
+
* This function is also available under the `writeUint16BE` alias.
|
|
1548
|
+
*
|
|
1549
|
+
* ```js
|
|
1550
|
+
* import { Buffer } from 'buffer';
|
|
1551
|
+
*
|
|
1552
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1553
|
+
*
|
|
1554
|
+
* buf.writeUInt16BE(0xdead, 0);
|
|
1555
|
+
* buf.writeUInt16BE(0xbeef, 2);
|
|
1556
|
+
*
|
|
1557
|
+
* console.log(buf);
|
|
1558
|
+
* // Prints: <Buffer de ad be ef>
|
|
1559
|
+
* ```
|
|
1560
|
+
* @since v0.5.5
|
|
1561
|
+
* @param value Number to be written to `buf`.
|
|
1562
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1563
|
+
* @return `offset` plus the number of bytes written.
|
|
1564
|
+
*/
|
|
304
1565
|
writeUInt16BE(value: number, offset?: number): number;
|
|
1566
|
+
/**
|
|
1567
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
|
|
1568
|
+
* anything other than an unsigned 32-bit integer.
|
|
1569
|
+
*
|
|
1570
|
+
* This function is also available under the `writeUint32LE` alias.
|
|
1571
|
+
*
|
|
1572
|
+
* ```js
|
|
1573
|
+
* import { Buffer } from 'buffer';
|
|
1574
|
+
*
|
|
1575
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1576
|
+
*
|
|
1577
|
+
* buf.writeUInt32LE(0xfeedface, 0);
|
|
1578
|
+
*
|
|
1579
|
+
* console.log(buf);
|
|
1580
|
+
* // Prints: <Buffer ce fa ed fe>
|
|
1581
|
+
* ```
|
|
1582
|
+
* @since v0.5.5
|
|
1583
|
+
* @param value Number to be written to `buf`.
|
|
1584
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1585
|
+
* @return `offset` plus the number of bytes written.
|
|
1586
|
+
*/
|
|
305
1587
|
writeUInt32LE(value: number, offset?: number): number;
|
|
1588
|
+
/**
|
|
1589
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
|
|
1590
|
+
* unsigned 32-bit integer.
|
|
1591
|
+
*
|
|
1592
|
+
* This function is also available under the `writeUint32BE` alias.
|
|
1593
|
+
*
|
|
1594
|
+
* ```js
|
|
1595
|
+
* import { Buffer } from 'buffer';
|
|
1596
|
+
*
|
|
1597
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1598
|
+
*
|
|
1599
|
+
* buf.writeUInt32BE(0xfeedface, 0);
|
|
1600
|
+
*
|
|
1601
|
+
* console.log(buf);
|
|
1602
|
+
* // Prints: <Buffer fe ed fa ce>
|
|
1603
|
+
* ```
|
|
1604
|
+
* @since v0.5.5
|
|
1605
|
+
* @param value Number to be written to `buf`.
|
|
1606
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1607
|
+
* @return `offset` plus the number of bytes written.
|
|
1608
|
+
*/
|
|
306
1609
|
writeUInt32BE(value: number, offset?: number): number;
|
|
1610
|
+
/**
|
|
1611
|
+
* Writes `value` to `buf` at the specified `offset`. `value` must be a valid
|
|
1612
|
+
* signed 8-bit integer. Behavior is undefined when `value` is anything other than
|
|
1613
|
+
* a signed 8-bit integer.
|
|
1614
|
+
*
|
|
1615
|
+
* `value` is interpreted and written as a two's complement signed integer.
|
|
1616
|
+
*
|
|
1617
|
+
* ```js
|
|
1618
|
+
* import { Buffer } from 'buffer';
|
|
1619
|
+
*
|
|
1620
|
+
* const buf = Buffer.allocUnsafe(2);
|
|
1621
|
+
*
|
|
1622
|
+
* buf.writeInt8(2, 0);
|
|
1623
|
+
* buf.writeInt8(-2, 1);
|
|
1624
|
+
*
|
|
1625
|
+
* console.log(buf);
|
|
1626
|
+
* // Prints: <Buffer 02 fe>
|
|
1627
|
+
* ```
|
|
1628
|
+
* @since v0.5.0
|
|
1629
|
+
* @param value Number to be written to `buf`.
|
|
1630
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
|
|
1631
|
+
* @return `offset` plus the number of bytes written.
|
|
1632
|
+
*/
|
|
307
1633
|
writeInt8(value: number, offset?: number): number;
|
|
1634
|
+
/**
|
|
1635
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
|
1636
|
+
* anything other than a signed 16-bit integer.
|
|
1637
|
+
*
|
|
1638
|
+
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1639
|
+
*
|
|
1640
|
+
* ```js
|
|
1641
|
+
* import { Buffer } from 'buffer';
|
|
1642
|
+
*
|
|
1643
|
+
* const buf = Buffer.allocUnsafe(2);
|
|
1644
|
+
*
|
|
1645
|
+
* buf.writeInt16LE(0x0304, 0);
|
|
1646
|
+
*
|
|
1647
|
+
* console.log(buf);
|
|
1648
|
+
* // Prints: <Buffer 04 03>
|
|
1649
|
+
* ```
|
|
1650
|
+
* @since v0.5.5
|
|
1651
|
+
* @param value Number to be written to `buf`.
|
|
1652
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1653
|
+
* @return `offset` plus the number of bytes written.
|
|
1654
|
+
*/
|
|
308
1655
|
writeInt16LE(value: number, offset?: number): number;
|
|
1656
|
+
/**
|
|
1657
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
|
1658
|
+
* anything other than a signed 16-bit integer.
|
|
1659
|
+
*
|
|
1660
|
+
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1661
|
+
*
|
|
1662
|
+
* ```js
|
|
1663
|
+
* import { Buffer } from 'buffer';
|
|
1664
|
+
*
|
|
1665
|
+
* const buf = Buffer.allocUnsafe(2);
|
|
1666
|
+
*
|
|
1667
|
+
* buf.writeInt16BE(0x0102, 0);
|
|
1668
|
+
*
|
|
1669
|
+
* console.log(buf);
|
|
1670
|
+
* // Prints: <Buffer 01 02>
|
|
1671
|
+
* ```
|
|
1672
|
+
* @since v0.5.5
|
|
1673
|
+
* @param value Number to be written to `buf`.
|
|
1674
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
|
1675
|
+
* @return `offset` plus the number of bytes written.
|
|
1676
|
+
*/
|
|
309
1677
|
writeInt16BE(value: number, offset?: number): number;
|
|
1678
|
+
/**
|
|
1679
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
|
1680
|
+
* anything other than a signed 32-bit integer.
|
|
1681
|
+
*
|
|
1682
|
+
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1683
|
+
*
|
|
1684
|
+
* ```js
|
|
1685
|
+
* import { Buffer } from 'buffer';
|
|
1686
|
+
*
|
|
1687
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1688
|
+
*
|
|
1689
|
+
* buf.writeInt32LE(0x05060708, 0);
|
|
1690
|
+
*
|
|
1691
|
+
* console.log(buf);
|
|
1692
|
+
* // Prints: <Buffer 08 07 06 05>
|
|
1693
|
+
* ```
|
|
1694
|
+
* @since v0.5.5
|
|
1695
|
+
* @param value Number to be written to `buf`.
|
|
1696
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1697
|
+
* @return `offset` plus the number of bytes written.
|
|
1698
|
+
*/
|
|
310
1699
|
writeInt32LE(value: number, offset?: number): number;
|
|
1700
|
+
/**
|
|
1701
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
|
1702
|
+
* anything other than a signed 32-bit integer.
|
|
1703
|
+
*
|
|
1704
|
+
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1705
|
+
*
|
|
1706
|
+
* ```js
|
|
1707
|
+
* import { Buffer } from 'buffer';
|
|
1708
|
+
*
|
|
1709
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1710
|
+
*
|
|
1711
|
+
* buf.writeInt32BE(0x01020304, 0);
|
|
1712
|
+
*
|
|
1713
|
+
* console.log(buf);
|
|
1714
|
+
* // Prints: <Buffer 01 02 03 04>
|
|
1715
|
+
* ```
|
|
1716
|
+
* @since v0.5.5
|
|
1717
|
+
* @param value Number to be written to `buf`.
|
|
1718
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1719
|
+
* @return `offset` plus the number of bytes written.
|
|
1720
|
+
*/
|
|
311
1721
|
writeInt32BE(value: number, offset?: number): number;
|
|
1722
|
+
/**
|
|
1723
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is
|
|
1724
|
+
* undefined when `value` is anything other than a JavaScript number.
|
|
1725
|
+
*
|
|
1726
|
+
* ```js
|
|
1727
|
+
* import { Buffer } from 'buffer';
|
|
1728
|
+
*
|
|
1729
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1730
|
+
*
|
|
1731
|
+
* buf.writeFloatLE(0xcafebabe, 0);
|
|
1732
|
+
*
|
|
1733
|
+
* console.log(buf);
|
|
1734
|
+
* // Prints: <Buffer bb fe 4a 4f>
|
|
1735
|
+
* ```
|
|
1736
|
+
* @since v0.11.15
|
|
1737
|
+
* @param value Number to be written to `buf`.
|
|
1738
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1739
|
+
* @return `offset` plus the number of bytes written.
|
|
1740
|
+
*/
|
|
312
1741
|
writeFloatLE(value: number, offset?: number): number;
|
|
1742
|
+
/**
|
|
1743
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is
|
|
1744
|
+
* undefined when `value` is anything other than a JavaScript number.
|
|
1745
|
+
*
|
|
1746
|
+
* ```js
|
|
1747
|
+
* import { Buffer } from 'buffer';
|
|
1748
|
+
*
|
|
1749
|
+
* const buf = Buffer.allocUnsafe(4);
|
|
1750
|
+
*
|
|
1751
|
+
* buf.writeFloatBE(0xcafebabe, 0);
|
|
1752
|
+
*
|
|
1753
|
+
* console.log(buf);
|
|
1754
|
+
* // Prints: <Buffer 4f 4a fe bb>
|
|
1755
|
+
* ```
|
|
1756
|
+
* @since v0.11.15
|
|
1757
|
+
* @param value Number to be written to `buf`.
|
|
1758
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
|
1759
|
+
* @return `offset` plus the number of bytes written.
|
|
1760
|
+
*/
|
|
313
1761
|
writeFloatBE(value: number, offset?: number): number;
|
|
1762
|
+
/**
|
|
1763
|
+
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything
|
|
1764
|
+
* other than a JavaScript number.
|
|
1765
|
+
*
|
|
1766
|
+
* ```js
|
|
1767
|
+
* import { Buffer } from 'buffer';
|
|
1768
|
+
*
|
|
1769
|
+
* const buf = Buffer.allocUnsafe(8);
|
|
1770
|
+
*
|
|
1771
|
+
* buf.writeDoubleLE(123.456, 0);
|
|
1772
|
+
*
|
|
1773
|
+
* console.log(buf);
|
|
1774
|
+
* // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>
|
|
1775
|
+
* ```
|
|
1776
|
+
* @since v0.11.15
|
|
1777
|
+
* @param value Number to be written to `buf`.
|
|
1778
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
|
|
1779
|
+
* @return `offset` plus the number of bytes written.
|
|
1780
|
+
*/
|
|
314
1781
|
writeDoubleLE(value: number, offset?: number): number;
|
|
1782
|
+
/**
|
|
1783
|
+
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything
|
|
1784
|
+
* other than a JavaScript number.
|
|
1785
|
+
*
|
|
1786
|
+
* ```js
|
|
1787
|
+
* import { Buffer } from 'buffer';
|
|
1788
|
+
*
|
|
1789
|
+
* const buf = Buffer.allocUnsafe(8);
|
|
1790
|
+
*
|
|
1791
|
+
* buf.writeDoubleBE(123.456, 0);
|
|
1792
|
+
*
|
|
1793
|
+
* console.log(buf);
|
|
1794
|
+
* // Prints: <Buffer 40 5e dd 2f 1a 9f be 77>
|
|
1795
|
+
* ```
|
|
1796
|
+
* @since v0.11.15
|
|
1797
|
+
* @param value Number to be written to `buf`.
|
|
1798
|
+
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
|
|
1799
|
+
* @return `offset` plus the number of bytes written.
|
|
1800
|
+
*/
|
|
315
1801
|
writeDoubleBE(value: number, offset?: number): number;
|
|
316
|
-
|
|
1802
|
+
/**
|
|
1803
|
+
* Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
|
|
1804
|
+
* the entire `buf` will be filled:
|
|
1805
|
+
*
|
|
1806
|
+
* ```js
|
|
1807
|
+
* import { Buffer } from 'buffer';
|
|
1808
|
+
*
|
|
1809
|
+
* // Fill a `Buffer` with the ASCII character 'h'.
|
|
1810
|
+
*
|
|
1811
|
+
* const b = Buffer.allocUnsafe(50).fill('h');
|
|
1812
|
+
*
|
|
1813
|
+
* console.log(b.toString());
|
|
1814
|
+
* // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
1815
|
+
* ```
|
|
1816
|
+
*
|
|
1817
|
+
* `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
|
|
1818
|
+
* integer. If the resulting integer is greater than `255` (decimal), `buf` will be
|
|
1819
|
+
* filled with `value & 255`.
|
|
1820
|
+
*
|
|
1821
|
+
* If the final write of a `fill()` operation falls on a multi-byte character,
|
|
1822
|
+
* then only the bytes of that character that fit into `buf` are written:
|
|
1823
|
+
*
|
|
1824
|
+
* ```js
|
|
1825
|
+
* import { Buffer } from 'buffer';
|
|
1826
|
+
*
|
|
1827
|
+
* // Fill a `Buffer` with character that takes up two bytes in UTF-8.
|
|
1828
|
+
*
|
|
1829
|
+
* console.log(Buffer.allocUnsafe(5).fill('\u0222'));
|
|
1830
|
+
* // Prints: <Buffer c8 a2 c8 a2 c8>
|
|
1831
|
+
* ```
|
|
1832
|
+
*
|
|
1833
|
+
* If `value` contains invalid characters, it is truncated; if no valid
|
|
1834
|
+
* fill data remains, an exception is thrown:
|
|
1835
|
+
*
|
|
1836
|
+
* ```js
|
|
1837
|
+
* import { Buffer } from 'buffer';
|
|
1838
|
+
*
|
|
1839
|
+
* const buf = Buffer.allocUnsafe(5);
|
|
1840
|
+
*
|
|
1841
|
+
* console.log(buf.fill('a'));
|
|
1842
|
+
* // Prints: <Buffer 61 61 61 61 61>
|
|
1843
|
+
* console.log(buf.fill('aazz', 'hex'));
|
|
1844
|
+
* // Prints: <Buffer aa aa aa aa aa>
|
|
1845
|
+
* console.log(buf.fill('zz', 'hex'));
|
|
1846
|
+
* // Throws an exception.
|
|
1847
|
+
* ```
|
|
1848
|
+
* @since v0.5.0
|
|
1849
|
+
* @param value The value with which to fill `buf`.
|
|
1850
|
+
* @param [offset=0] Number of bytes to skip before starting to fill `buf`.
|
|
1851
|
+
* @param [end=buf.length] Where to stop filling `buf` (not inclusive).
|
|
1852
|
+
* @param [encoding='utf8'] The encoding for `value` if `value` is a string.
|
|
1853
|
+
* @return A reference to `buf`.
|
|
1854
|
+
*/
|
|
317
1855
|
fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
|
|
318
|
-
|
|
1856
|
+
/**
|
|
1857
|
+
* If `value` is:
|
|
1858
|
+
*
|
|
1859
|
+
* * a string, `value` is interpreted according to the character encoding in`encoding`.
|
|
1860
|
+
* * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
|
|
1861
|
+
* To compare a partial `Buffer`, use `buf.slice()`.
|
|
1862
|
+
* * a number, `value` will be interpreted as an unsigned 8-bit integer
|
|
1863
|
+
* value between `0` and `255`.
|
|
1864
|
+
*
|
|
1865
|
+
* ```js
|
|
1866
|
+
* import { Buffer } from 'buffer';
|
|
1867
|
+
*
|
|
1868
|
+
* const buf = Buffer.from('this is a buffer');
|
|
1869
|
+
*
|
|
1870
|
+
* console.log(buf.indexOf('this'));
|
|
1871
|
+
* // Prints: 0
|
|
1872
|
+
* console.log(buf.indexOf('is'));
|
|
1873
|
+
* // Prints: 2
|
|
1874
|
+
* console.log(buf.indexOf(Buffer.from('a buffer')));
|
|
1875
|
+
* // Prints: 8
|
|
1876
|
+
* console.log(buf.indexOf(97));
|
|
1877
|
+
* // Prints: 8 (97 is the decimal ASCII value for 'a')
|
|
1878
|
+
* console.log(buf.indexOf(Buffer.from('a buffer example')));
|
|
1879
|
+
* // Prints: -1
|
|
1880
|
+
* console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));
|
|
1881
|
+
* // Prints: 8
|
|
1882
|
+
*
|
|
1883
|
+
* const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
|
|
1884
|
+
*
|
|
1885
|
+
* console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le'));
|
|
1886
|
+
* // Prints: 4
|
|
1887
|
+
* console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le'));
|
|
1888
|
+
* // Prints: 6
|
|
1889
|
+
* ```
|
|
1890
|
+
*
|
|
1891
|
+
* If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
|
1892
|
+
* an integer between 0 and 255.
|
|
1893
|
+
*
|
|
1894
|
+
* If `byteOffset` is not a number, it will be coerced to a number. If the result
|
|
1895
|
+
* of coercion is `NaN` or `0`, then the entire buffer will be searched. This
|
|
1896
|
+
* behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
|
|
1897
|
+
*
|
|
1898
|
+
* ```js
|
|
1899
|
+
* import { Buffer } from 'buffer';
|
|
1900
|
+
*
|
|
1901
|
+
* const b = Buffer.from('abcdef');
|
|
1902
|
+
*
|
|
1903
|
+
* // Passing a value that's a number, but not a valid byte.
|
|
1904
|
+
* // Prints: 2, equivalent to searching for 99 or 'c'.
|
|
1905
|
+
* console.log(b.indexOf(99.9));
|
|
1906
|
+
* console.log(b.indexOf(256 + 99));
|
|
1907
|
+
*
|
|
1908
|
+
* // Passing a byteOffset that coerces to NaN or 0.
|
|
1909
|
+
* // Prints: 1, searching the whole buffer.
|
|
1910
|
+
* console.log(b.indexOf('b', undefined));
|
|
1911
|
+
* console.log(b.indexOf('b', {}));
|
|
1912
|
+
* console.log(b.indexOf('b', null));
|
|
1913
|
+
* console.log(b.indexOf('b', []));
|
|
1914
|
+
* ```
|
|
1915
|
+
*
|
|
1916
|
+
* If `value` is an empty string or empty `Buffer` and `byteOffset` is less
|
|
1917
|
+
* than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned.
|
|
1918
|
+
* @since v1.5.0
|
|
1919
|
+
* @param value What to search for.
|
|
1920
|
+
* @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
|
|
1921
|
+
* @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
|
|
1922
|
+
* @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
|
|
1923
|
+
*/
|
|
319
1924
|
indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
|
1925
|
+
/**
|
|
1926
|
+
* Identical to `buf.indexOf()`, except the last occurrence of `value` is found
|
|
1927
|
+
* rather than the first occurrence.
|
|
1928
|
+
*
|
|
1929
|
+
* ```js
|
|
1930
|
+
* import { Buffer } from 'buffer';
|
|
1931
|
+
*
|
|
1932
|
+
* const buf = Buffer.from('this buffer is a buffer');
|
|
1933
|
+
*
|
|
1934
|
+
* console.log(buf.lastIndexOf('this'));
|
|
1935
|
+
* // Prints: 0
|
|
1936
|
+
* console.log(buf.lastIndexOf('buffer'));
|
|
1937
|
+
* // Prints: 17
|
|
1938
|
+
* console.log(buf.lastIndexOf(Buffer.from('buffer')));
|
|
1939
|
+
* // Prints: 17
|
|
1940
|
+
* console.log(buf.lastIndexOf(97));
|
|
1941
|
+
* // Prints: 15 (97 is the decimal ASCII value for 'a')
|
|
1942
|
+
* console.log(buf.lastIndexOf(Buffer.from('yolo')));
|
|
1943
|
+
* // Prints: -1
|
|
1944
|
+
* console.log(buf.lastIndexOf('buffer', 5));
|
|
1945
|
+
* // Prints: 5
|
|
1946
|
+
* console.log(buf.lastIndexOf('buffer', 4));
|
|
1947
|
+
* // Prints: -1
|
|
1948
|
+
*
|
|
1949
|
+
* const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
|
|
1950
|
+
*
|
|
1951
|
+
* console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le'));
|
|
1952
|
+
* // Prints: 6
|
|
1953
|
+
* console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le'));
|
|
1954
|
+
* // Prints: 4
|
|
1955
|
+
* ```
|
|
1956
|
+
*
|
|
1957
|
+
* If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
|
1958
|
+
* an integer between 0 and 255.
|
|
1959
|
+
*
|
|
1960
|
+
* If `byteOffset` is not a number, it will be coerced to a number. Any arguments
|
|
1961
|
+
* that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
|
|
1962
|
+
* This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
|
|
1963
|
+
*
|
|
1964
|
+
* ```js
|
|
1965
|
+
* import { Buffer } from 'buffer';
|
|
1966
|
+
*
|
|
1967
|
+
* const b = Buffer.from('abcdef');
|
|
1968
|
+
*
|
|
1969
|
+
* // Passing a value that's a number, but not a valid byte.
|
|
1970
|
+
* // Prints: 2, equivalent to searching for 99 or 'c'.
|
|
1971
|
+
* console.log(b.lastIndexOf(99.9));
|
|
1972
|
+
* console.log(b.lastIndexOf(256 + 99));
|
|
1973
|
+
*
|
|
1974
|
+
* // Passing a byteOffset that coerces to NaN.
|
|
1975
|
+
* // Prints: 1, searching the whole buffer.
|
|
1976
|
+
* console.log(b.lastIndexOf('b', undefined));
|
|
1977
|
+
* console.log(b.lastIndexOf('b', {}));
|
|
1978
|
+
*
|
|
1979
|
+
* // Passing a byteOffset that coerces to 0.
|
|
1980
|
+
* // Prints: -1, equivalent to passing 0.
|
|
1981
|
+
* console.log(b.lastIndexOf('b', null));
|
|
1982
|
+
* console.log(b.lastIndexOf('b', []));
|
|
1983
|
+
* ```
|
|
1984
|
+
*
|
|
1985
|
+
* If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.
|
|
1986
|
+
* @since v6.0.0
|
|
1987
|
+
* @param value What to search for.
|
|
1988
|
+
* @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
|
|
1989
|
+
* @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
|
|
1990
|
+
* @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
|
|
1991
|
+
*/
|
|
320
1992
|
lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
|
1993
|
+
/**
|
|
1994
|
+
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents
|
|
1995
|
+
* of `buf`.
|
|
1996
|
+
*
|
|
1997
|
+
* ```js
|
|
1998
|
+
* import { Buffer } from 'buffer';
|
|
1999
|
+
*
|
|
2000
|
+
* // Log the entire contents of a `Buffer`.
|
|
2001
|
+
*
|
|
2002
|
+
* const buf = Buffer.from('buffer');
|
|
2003
|
+
*
|
|
2004
|
+
* for (const pair of buf.entries()) {
|
|
2005
|
+
* console.log(pair);
|
|
2006
|
+
* }
|
|
2007
|
+
* // Prints:
|
|
2008
|
+
* // [0, 98]
|
|
2009
|
+
* // [1, 117]
|
|
2010
|
+
* // [2, 102]
|
|
2011
|
+
* // [3, 102]
|
|
2012
|
+
* // [4, 101]
|
|
2013
|
+
* // [5, 114]
|
|
2014
|
+
* ```
|
|
2015
|
+
* @since v1.1.0
|
|
2016
|
+
*/
|
|
321
2017
|
entries(): IterableIterator<[number, number]>;
|
|
2018
|
+
/**
|
|
2019
|
+
* Equivalent to `buf.indexOf() !== -1`.
|
|
2020
|
+
*
|
|
2021
|
+
* ```js
|
|
2022
|
+
* import { Buffer } from 'buffer';
|
|
2023
|
+
*
|
|
2024
|
+
* const buf = Buffer.from('this is a buffer');
|
|
2025
|
+
*
|
|
2026
|
+
* console.log(buf.includes('this'));
|
|
2027
|
+
* // Prints: true
|
|
2028
|
+
* console.log(buf.includes('is'));
|
|
2029
|
+
* // Prints: true
|
|
2030
|
+
* console.log(buf.includes(Buffer.from('a buffer')));
|
|
2031
|
+
* // Prints: true
|
|
2032
|
+
* console.log(buf.includes(97));
|
|
2033
|
+
* // Prints: true (97 is the decimal ASCII value for 'a')
|
|
2034
|
+
* console.log(buf.includes(Buffer.from('a buffer example')));
|
|
2035
|
+
* // Prints: false
|
|
2036
|
+
* console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
|
|
2037
|
+
* // Prints: true
|
|
2038
|
+
* console.log(buf.includes('this', 4));
|
|
2039
|
+
* // Prints: false
|
|
2040
|
+
* ```
|
|
2041
|
+
* @since v5.3.0
|
|
2042
|
+
* @param value What to search for.
|
|
2043
|
+
* @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
|
|
2044
|
+
* @param [encoding='utf8'] If `value` is a string, this is its encoding.
|
|
2045
|
+
* @return `true` if `value` was found in `buf`, `false` otherwise.
|
|
2046
|
+
*/
|
|
322
2047
|
includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
|
|
2048
|
+
/**
|
|
2049
|
+
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
|
|
2050
|
+
*
|
|
2051
|
+
* ```js
|
|
2052
|
+
* import { Buffer } from 'buffer';
|
|
2053
|
+
*
|
|
2054
|
+
* const buf = Buffer.from('buffer');
|
|
2055
|
+
*
|
|
2056
|
+
* for (const key of buf.keys()) {
|
|
2057
|
+
* console.log(key);
|
|
2058
|
+
* }
|
|
2059
|
+
* // Prints:
|
|
2060
|
+
* // 0
|
|
2061
|
+
* // 1
|
|
2062
|
+
* // 2
|
|
2063
|
+
* // 3
|
|
2064
|
+
* // 4
|
|
2065
|
+
* // 5
|
|
2066
|
+
* ```
|
|
2067
|
+
* @since v1.1.0
|
|
2068
|
+
*/
|
|
323
2069
|
keys(): IterableIterator<number>;
|
|
2070
|
+
/**
|
|
2071
|
+
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is
|
|
2072
|
+
* called automatically when a `Buffer` is used in a `for..of` statement.
|
|
2073
|
+
*
|
|
2074
|
+
* ```js
|
|
2075
|
+
* import { Buffer } from 'buffer';
|
|
2076
|
+
*
|
|
2077
|
+
* const buf = Buffer.from('buffer');
|
|
2078
|
+
*
|
|
2079
|
+
* for (const value of buf.values()) {
|
|
2080
|
+
* console.log(value);
|
|
2081
|
+
* }
|
|
2082
|
+
* // Prints:
|
|
2083
|
+
* // 98
|
|
2084
|
+
* // 117
|
|
2085
|
+
* // 102
|
|
2086
|
+
* // 102
|
|
2087
|
+
* // 101
|
|
2088
|
+
* // 114
|
|
2089
|
+
*
|
|
2090
|
+
* for (const value of buf) {
|
|
2091
|
+
* console.log(value);
|
|
2092
|
+
* }
|
|
2093
|
+
* // Prints:
|
|
2094
|
+
* // 98
|
|
2095
|
+
* // 117
|
|
2096
|
+
* // 102
|
|
2097
|
+
* // 102
|
|
2098
|
+
* // 101
|
|
2099
|
+
* // 114
|
|
2100
|
+
* ```
|
|
2101
|
+
* @since v1.1.0
|
|
2102
|
+
*/
|
|
324
2103
|
values(): IterableIterator<number>;
|
|
325
2104
|
}
|
|
326
2105
|
var Buffer: BufferConstructor;
|
|
327
|
-
|
|
328
2106
|
/**
|
|
329
|
-
* Decodes a string of Base64-encoded data into bytes, and encodes those bytes
|
|
2107
|
+
* Decodes a string of Base64-encoded data into bytes, and encodes those bytes
|
|
2108
|
+
* into a string using Latin-1 (ISO-8859-1).
|
|
330
2109
|
*
|
|
331
|
-
*
|
|
332
|
-
* and should never be used in new code, because they use strings to represent
|
|
333
|
-
* binary data and predate the introduction of typed arrays in JavaScript.
|
|
334
|
-
* For code running using Node.js APIs, converting between base64-encoded strings
|
|
335
|
-
* and binary data should be performed using `Buffer.from(str, 'base64')` and
|
|
336
|
-
* `buf.toString('base64')`.
|
|
2110
|
+
* The `data` may be any JavaScript-value that can be coerced into a string.
|
|
337
2111
|
*
|
|
338
|
-
*
|
|
2112
|
+
* **This function is only provided for compatibility with legacy web platform APIs**
|
|
2113
|
+
* **and should never be used in new code, because they use strings to represent**
|
|
2114
|
+
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
|
2115
|
+
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
|
2116
|
+
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
|
2117
|
+
* @since v15.13.0
|
|
2118
|
+
* @deprecated Use `Buffer.from(data, 'base64')` instead.
|
|
2119
|
+
* @param data The Base64-encoded input string.
|
|
339
2120
|
*/
|
|
340
|
-
function atob(
|
|
341
|
-
|
|
2121
|
+
function atob(data: string): string;
|
|
342
2122
|
/**
|
|
343
|
-
* Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes
|
|
2123
|
+
* Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes
|
|
2124
|
+
* into a string using Base64.
|
|
344
2125
|
*
|
|
345
|
-
*
|
|
346
|
-
* and should never be used in new code, because they use strings to represent
|
|
347
|
-
* binary data and predate the introduction of typed arrays in JavaScript.
|
|
348
|
-
* For code running using Node.js APIs, converting between base64-encoded strings
|
|
349
|
-
* and binary data should be performed using `Buffer.from(str, 'base64')` and
|
|
350
|
-
* `buf.toString('base64')`.
|
|
2126
|
+
* The `data` may be any JavaScript-value that can be coerced into a string.
|
|
351
2127
|
*
|
|
352
|
-
*
|
|
2128
|
+
* **This function is only provided for compatibility with legacy web platform APIs**
|
|
2129
|
+
* **and should never be used in new code, because they use strings to represent**
|
|
2130
|
+
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
|
2131
|
+
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
|
2132
|
+
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
|
2133
|
+
* @since v15.13.0
|
|
2134
|
+
* @deprecated Use `buf.toString('base64')` instead.
|
|
2135
|
+
* @param data An ASCII (Latin1) string.
|
|
353
2136
|
*/
|
|
354
|
-
function btoa(
|
|
2137
|
+
function btoa(data: string): string;
|
|
355
2138
|
}
|
|
356
2139
|
}
|
|
357
|
-
|
|
358
2140
|
declare module 'node:buffer' {
|
|
359
2141
|
export * from 'buffer';
|
|
360
2142
|
}
|