From a12da99962194847264da457678a274f6cc2e7db Mon Sep 17 00:00:00 2001 From: Alexandre Ferrando Date: Tue, 30 Oct 2018 10:45:23 +0100 Subject: [PATCH] Add sonic-boom package --- types/sonic-boom/index.d.ts | 50 ++++++++++++++++++++++++++++ types/sonic-boom/sonic-boom-tests.ts | 19 +++++++++++ types/sonic-boom/tsconfig.json | 23 +++++++++++++ types/sonic-boom/tslint.json | 1 + 4 files changed, 93 insertions(+) create mode 100644 types/sonic-boom/index.d.ts create mode 100644 types/sonic-boom/sonic-boom-tests.ts create mode 100644 types/sonic-boom/tsconfig.json create mode 100644 types/sonic-boom/tslint.json diff --git a/types/sonic-boom/index.d.ts b/types/sonic-boom/index.d.ts new file mode 100644 index 0000000000..eca15c0cb7 --- /dev/null +++ b/types/sonic-boom/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for sonic-boom 0.6 +// Project: https://github.com/mcollina/sonic-boom.git +// Definitions by: Alex Ferrando +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { EventEmitter } from 'events'; + +export = 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) + + /** + * 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(file: String): 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; +} diff --git a/types/sonic-boom/sonic-boom-tests.ts b/types/sonic-boom/sonic-boom-tests.ts new file mode 100644 index 0000000000..a819ec635f --- /dev/null +++ b/types/sonic-boom/sonic-boom-tests.ts @@ -0,0 +1,19 @@ + +import SonicBoom = require('sonic-boom') +const sonic = new SonicBoom(1) + +sonic.write('hello sonic\n') + +sonic.flush() + +sonic.flushSync() + +sonic.end() + +sonic.destroy() + + + + + + diff --git a/types/sonic-boom/tsconfig.json b/types/sonic-boom/tsconfig.json new file mode 100644 index 0000000000..46c62493b0 --- /dev/null +++ b/types/sonic-boom/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sonic-boom-tests.ts" + ] +} diff --git a/types/sonic-boom/tslint.json b/types/sonic-boom/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sonic-boom/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }