This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

90
book/node_modules/is-stream/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,90 @@
import {
type Stream,
type Writable as WritableStream,
type Readable as ReadableStream,
type Duplex as DuplexStream,
type Transform as TransformStream,
} from 'node:stream';
export type Options = {
/**
When this option is `true`, the method returns `false` if the stream has already been closed.
@default true
*/
checkOpen?: boolean;
};
/**
@returns Whether `stream` is a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
@example
```
import fs from 'node:fs';
import {isStream} from 'is-stream';
isStream(fs.createReadStream('unicorn.png'));
//=> true
isStream({});
//=> false
```
*/
export function isStream(stream: unknown, options?: Options): stream is Stream;
/**
@returns Whether `stream` is a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable), an [`http.OutgoingMessage`](https://nodejs.org/api/http.html#class-httpoutgoingmessage), an [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) or an [`http.ClientRequest`](https://nodejs.org/api/http.html#class-httpserverresponse).
@example
```
import fs from 'node:fs';
import {isWritableStream} from 'is-stream';
isWritableStream(fs.createWriteStrem('unicorn.txt'));
//=> true
```
*/
export function isWritableStream(stream: unknown, options?: Options): stream is WritableStream;
/**
@returns Whether `stream` is a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable) or an [`http.IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage).
@example
```
import fs from 'node:fs';
import {isReadableStream} from 'is-stream';
isReadableStream(fs.createReadStream('unicorn.png'));
//=> true
```
*/
export function isReadableStream(stream: unknown, options?: Options): stream is ReadableStream;
/**
@returns Whether `stream` is a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
@example
```
import {Duplex as DuplexStream} from 'node:stream';
import {isDuplexStream} from 'is-stream';
isDuplexStream(new DuplexStream());
//=> true
```
*/
export function isDuplexStream(stream: unknown, options?: Options): stream is DuplexStream;
/**
@returns Whether `stream` is a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform).
@example
```
import fs from 'node:fs';
import StringifyStream from 'streaming-json-stringify';
import {isTransformStream} from 'is-stream';
isTransformStream(StringifyStream());
//=> true
```
*/
export function isTransformStream(stream: unknown, options?: Options): stream is TransformStream;

37
book/node_modules/is-stream/index.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
export function isStream(stream, {checkOpen = true} = {}) {
return stream !== null
&& typeof stream === 'object'
&& (stream.writable || stream.readable || !checkOpen || (stream.writable === undefined && stream.readable === undefined))
&& typeof stream.pipe === 'function';
}
export function isWritableStream(stream, {checkOpen = true} = {}) {
return isStream(stream, {checkOpen})
&& (stream.writable || !checkOpen)
&& typeof stream.write === 'function'
&& typeof stream.end === 'function'
&& typeof stream.writable === 'boolean'
&& typeof stream.writableObjectMode === 'boolean'
&& typeof stream.destroy === 'function'
&& typeof stream.destroyed === 'boolean';
}
export function isReadableStream(stream, {checkOpen = true} = {}) {
return isStream(stream, {checkOpen})
&& (stream.readable || !checkOpen)
&& typeof stream.read === 'function'
&& typeof stream.readable === 'boolean'
&& typeof stream.readableObjectMode === 'boolean'
&& typeof stream.destroy === 'function'
&& typeof stream.destroyed === 'boolean';
}
export function isDuplexStream(stream, options) {
return isWritableStream(stream, options)
&& isReadableStream(stream, options);
}
export function isTransformStream(stream, options) {
return isDuplexStream(stream, options)
&& typeof stream._transform === 'function';
}

9
book/node_modules/is-stream/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

48
book/node_modules/is-stream/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "is-stream",
"version": "4.0.1",
"description": "Check if something is a Node.js stream",
"license": "MIT",
"repository": "sindresorhus/is-stream",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"stream",
"type",
"streams",
"writable",
"readable",
"duplex",
"transform",
"check",
"detect",
"is"
],
"devDependencies": {
"@types/node": "^20.11.19",
"ava": "^5.3.1",
"tempy": "^3.1.0",
"tsd": "^0.30.5",
"xo": "^0.57.0"
}
}

57
book/node_modules/is-stream/readme.md generated vendored Normal file
View File

@@ -0,0 +1,57 @@
# is-stream
> Check if something is a [Node.js stream](https://nodejs.org/api/stream.html)
## Install
```sh
npm install is-stream
```
## Usage
```js
import fs from 'node:fs';
import {isStream} from 'is-stream';
isStream(fs.createReadStream('unicorn.png'));
//=> true
isStream({});
//=> false
```
## API
### isStream(stream, options?)
Returns a `boolean` for whether it's a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
### isWritableStream(stream, options?)
Returns a `boolean` for whether it's a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable), an [`http.OutgoingMessage`](https://nodejs.org/api/http.html#class-httpoutgoingmessage), an [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) or an [`http.ClientRequest`](https://nodejs.org/api/http.html#class-httpserverresponse).
### isReadableStream(stream, options?)
Returns a `boolean` for whether it's a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable) or an [`http.IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage).
### isDuplexStream(stream, options?)
Returns a `boolean` for whether it's a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
### isTransformStream(stream, options?)
Returns a `boolean` for whether it's a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform).
### Options
#### checkOpen
Type: `boolean`\
Default: `true`
When this option is `true`, the method returns `false` if the stream has already been closed.
## Related
- [is-file-stream](https://github.com/jamestalmage/is-file-stream) - Detect if a stream is a file stream