-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add TS types * Fix npm script * Replaces `files` with `.npmignore`
- Loading branch information
Showing
6 changed files
with
102 additions
and
2 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,2 @@ | ||
types/index.d.ts | ||
types/index.test-d.ts |
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,10 @@ | ||
.editorconfig | ||
.gitattributes | ||
.git | ||
.DS_Store | ||
.gitignore | ||
.github | ||
.dependabot | ||
.clinic | ||
tsconfig.json | ||
types/index.test-d.ts |
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
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"lib": [ "es2015" ], | ||
"module": "commonjs", | ||
"noEmit": true, | ||
"strict": true | ||
}, | ||
"include": [ | ||
"./types/index.test-d.ts", | ||
"./types/index.d.ts" | ||
] | ||
} |
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,48 @@ | ||
// Type definitions for sonic-boom 0.7 | ||
// Definitions by: Alex Ferrando <https://github.com/alferpal> | ||
// Igor Savin <https://github.com/kibertoad> | ||
/// <reference types="node"/> | ||
|
||
import { EventEmitter } from 'events'; | ||
|
||
export default SonicBoom; | ||
|
||
declare class SonicBoom extends EventEmitter { | ||
/** | ||
* @param [fileDescriptor] File path or numerical file descriptor | ||
* relative protocol is enabled. Default: process.stdout | ||
* @returns a new sonic-boom instance | ||
*/ | ||
constructor(fileDescriptor: string | number, minLength?: number, sync?: boolean) | ||
|
||
/** | ||
* Writes the string to the file. It will return false to signal the producer to slow down. | ||
*/ | ||
write(string: string): void; | ||
|
||
/** | ||
* Writes the current buffer to the file if a write was not in progress. | ||
* Do nothing if minLength is zero or if it is already writing. | ||
*/ | ||
flush(): void; | ||
|
||
/** | ||
* Reopen the file in place, useful for log rotation. | ||
*/ | ||
reopen(fileDescriptor?: string | number): void; | ||
|
||
/** | ||
* Flushes the buffered data synchronously. This is a costly operation. | ||
*/ | ||
flushSync(): void; | ||
|
||
/** | ||
* Closes the stream, the data will be flushed down asynchronously | ||
*/ | ||
end(): void; | ||
|
||
/** | ||
* Closes the stream immediately, the data is not flushed. | ||
*/ | ||
destroy(): void; | ||
} |
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,18 @@ | ||
import SonicBoom from '../'; | ||
const sonic = new SonicBoom(1); | ||
|
||
sonic.write('hello sonic\n'); | ||
|
||
sonic.flush(); | ||
|
||
sonic.flushSync(); | ||
|
||
sonic.reopen(); | ||
|
||
sonic.end(); | ||
|
||
sonic.destroy(); | ||
|
||
const extraSonic = new SonicBoom(1, 0, true); | ||
|
||
extraSonic.write('extra sonic\n'); |