added type for bufferhelper (#38954)

* added @type/bufferhelper

* added typescript version

* added space
This commit is contained in:
Max Boguslavsky 2019-10-08 03:10:45 +03:00 committed by Armando Aguirre
parent 7a00793d5a
commit a9cf1ec909
4 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import BufferHelper from 'bufferhelper';
// test data
const buffer = new BufferHelper();
// tests
buffer.concat('');
buffer.toBuffer().toString();
buffer.empty();
buffer.load('', () => {});
buffer.toString('ascii');

24
types/bufferhelper/index.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
// Type definitions for bufferhelper 0.2
// Project: https://github.com/JacksonTian/bufferhelper
// Definitions by: Vladimir Grenaderov <https://github.com/VladimirGrenaderov>,
// Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
/// <reference types="node" />
declare namespace BufferHelper {
type encoding = 'ascii'|'utf8'|'utf16le'|'ucs2'|'base64'|'binary'|'hex';
}
declare class BufferHelper {
constructor();
concat(buffer: any): BufferHelper;
empty(): BufferHelper;
load(stream: any, callback: (arg: any) => any): void;
toBuffer(): Buffer;
toString(encoding: BufferHelper.encoding): string;
}
export = BufferHelper;

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bufferhelper-tests.ts"
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}