Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b504268
Showing
10 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### git template | ||
.idea | ||
|
||
~ci.list.txt | ||
~ci.log.txt | ||
~ci.errors.txt | ||
|
||
*.stackdump | ||
*.bak | ||
*.old | ||
|
||
package-lock.json | ||
|
||
test/**/*.js | ||
test/**/*.d.ts | ||
test/*.js | ||
test/*.d.ts | ||
test/temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### npm template | ||
.idea | ||
|
||
~ci.list.txt | ||
~ci.log.txt | ||
~ci.errors.txt | ||
|
||
*.stackdump | ||
*.bak | ||
*.old | ||
|
||
tsconfig.json | ||
#package-lock.json | ||
|
||
test | ||
|
||
.github | ||
.gitkeep | ||
|
||
/.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference types="node" /> | ||
/** | ||
* Created by user on 2018/4/10/010. | ||
*/ | ||
import * as fs from "fs"; | ||
import { IOptionsStreamPipe, IPipe } from './index'; | ||
export declare type IOptionsFsCreateReadStream = { | ||
flags?: string; | ||
encoding?: string; | ||
fd?: number; | ||
mode?: number; | ||
autoClose?: boolean; | ||
start?: number; | ||
end?: number; | ||
highWaterMark?: number; | ||
}; | ||
export declare class ReadStream extends fs.ReadStream { | ||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: IOptionsStreamPipe): IPipe<this, T>; | ||
static createReadStream(file: string | Buffer, options?: IOptionsFsCreateReadStream, ...argv: any[]): ReadStream & fs.ReadStream; | ||
} | ||
export declare const createReadStream: typeof ReadStream.createReadStream; | ||
export default createReadStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
/** | ||
* Created by user on 2018/4/10/010. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = require("fs"); | ||
const index_1 = require("./index"); | ||
class ReadStream extends fs.ReadStream { | ||
pipe(destination, options) { | ||
return index_1.pipe(this, destination, options); | ||
} | ||
static createReadStream(file, options, ...argv) { | ||
// @ts-ignore | ||
return new this(file, options, ...argv); | ||
} | ||
} | ||
exports.ReadStream = ReadStream; | ||
exports.createReadStream = ReadStream.createReadStream.bind(ReadStream); | ||
exports.default = exports.createReadStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Created by user on 2018/4/10/010. | ||
*/ | ||
|
||
import * as fs from "fs"; | ||
import * as stream from "stream"; | ||
|
||
import { IOptionsStreamPipe, pipe, IPipe } from './index'; | ||
|
||
export type IOptionsFsCreateReadStream = { | ||
flags?: string; | ||
encoding?: string; | ||
fd?: number; | ||
mode?: number; | ||
autoClose?: boolean; | ||
start?: number; | ||
end?: number; | ||
highWaterMark?: number; | ||
}; | ||
|
||
export class ReadStream extends fs.ReadStream | ||
{ | ||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: IOptionsStreamPipe): IPipe<this, T> | ||
{ | ||
return pipe(this, destination, options) as IPipe<this, T>; | ||
} | ||
|
||
static createReadStream(file: string | Buffer, options?: IOptionsFsCreateReadStream, ...argv): ReadStream & fs.ReadStream | ||
{ | ||
// @ts-ignore | ||
return new this(file, options, ...argv); | ||
} | ||
} | ||
|
||
export const createReadStream = ReadStream.createReadStream.bind(ReadStream) as typeof ReadStream.createReadStream; | ||
|
||
export default createReadStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// <reference types="node" /> | ||
/** | ||
* Created by user on 2018/4/10/010. | ||
*/ | ||
export declare type IOptionsStreamPipe = { | ||
end?: boolean; | ||
}; | ||
export declare type IPipe<U extends NodeJS.ReadableStream, T extends NodeJS.WritableStream> = T & { | ||
pipFrom: U; | ||
}; | ||
export declare function pipe<U extends NodeJS.ReadableStream, T extends NodeJS.WritableStream>(srcStream: U, destStream: T, options?: IOptionsStreamPipe): T & { | ||
pipFrom?: U; | ||
}; | ||
import * as self from './index'; | ||
export default self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict"; | ||
/** | ||
* Created by user on 2018/4/10/010. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function pipe(srcStream, destStream, options) { | ||
let _dest = destStream; | ||
_dest.pipFrom = srcStream; | ||
return srcStream.pipe(_dest); | ||
} | ||
exports.pipe = pipe; | ||
const self = require("./index"); | ||
exports.default = self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Created by user on 2018/4/10/010. | ||
*/ | ||
|
||
export type IOptionsStreamPipe = { | ||
end?: boolean; | ||
} | ||
|
||
export type IPipe<U extends NodeJS.ReadableStream, T extends NodeJS.WritableStream> = T & { | ||
pipFrom: U, | ||
}; | ||
|
||
export function pipe<U extends NodeJS.ReadableStream, T extends NodeJS.WritableStream>(srcStream: U, destStream: T, options?: IOptionsStreamPipe) | ||
{ | ||
let _dest = destStream as T & { | ||
pipFrom?: U, | ||
}; | ||
|
||
_dest.pipFrom = srcStream; | ||
|
||
return srcStream.pipe(_dest); | ||
} | ||
|
||
import * as self from './index'; | ||
export default self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "stream-pipe", | ||
"version": "1.0.0", | ||
"description": "", | ||
"homepage": "https://github.com/bluelovers/node-stream-pipe#readme", | ||
"bugs": { | ||
"url": "https://github.com/bluelovers/node-stream-pipe/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/bluelovers/node-stream-pipe.git" | ||
}, | ||
"license": "ISC", | ||
"author": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/node": "^9.6.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"target": "es2017", | ||
|
||
"moduleResolution": "node", | ||
"allowJs": false, | ||
|
||
//"sourceMap": true, | ||
//"inlineSourceMap": true, | ||
//"inlineSources": true, | ||
|
||
"declaration": true, | ||
"experimentalDecorators": true, | ||
|
||
"allowSyntheticDefaultImports": true, | ||
|
||
"strict": false, | ||
|
||
//"forceConsistentCasingInFileNames": true, | ||
|
||
"locale": "zh-TW", | ||
"pretty": true, | ||
|
||
// "removeComments": true, | ||
|
||
// "baseUrl": ".", | ||
// "sourceRoot": ".", | ||
// "rootDir": ".", | ||
// "outDir": ".", | ||
|
||
// "paths": { | ||
// | ||
// }, | ||
|
||
"traceResolution": true, | ||
"newLine": "lf" | ||
}, | ||
|
||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |