mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add type definition for buffer-reader
This commit is contained in:
parent
b3563f18c1
commit
ddf6cf66f2
28
types/buffer-reader/buffer-reader-tests.ts
Normal file
28
types/buffer-reader/buffer-reader-tests.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import BufferReader from 'buffer-reader';
|
||||
|
||||
const buffer = new Buffer(1000);
|
||||
const reader = new BufferReader(buffer);
|
||||
reader.append(new Buffer(1));
|
||||
reader.tell();
|
||||
reader.seek(1);
|
||||
reader.move(2);
|
||||
reader.restAll();
|
||||
reader.nextBuffer(2);
|
||||
reader.nextString(5);
|
||||
reader.nextString(5, 'utf8');
|
||||
reader.nextStringZero();
|
||||
reader.nextStringZero('utf8');
|
||||
reader.nextInt8();
|
||||
reader.nextUInt8();
|
||||
reader.nextInt16LE();
|
||||
reader.nextUInt16LE();
|
||||
reader.nextInt16BE();
|
||||
reader.nextUInt16BE();
|
||||
reader.nextInt32LE();
|
||||
reader.nextUInt32LE();
|
||||
reader.nextInt32BE();
|
||||
reader.nextUInt32BE();
|
||||
reader.nextFloatLE();
|
||||
reader.nextFloatBE();
|
||||
reader.nextDouble32LE();
|
||||
reader.nextDouble32BE();
|
||||
111
types/buffer-reader/index.d.ts
vendored
Normal file
111
types/buffer-reader/index.d.ts
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
// Type definitions for buffer-reader 0.1
|
||||
// Project: https://github.com/villadora/node-buffer-reader
|
||||
// Definitions by: nrlquaker <https://github.com/nrlquaker>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
export = BufferReader;
|
||||
|
||||
declare class BufferReader {
|
||||
/**
|
||||
* Create a new reader, if no buffer provided, a empty buffer will be used.
|
||||
*/
|
||||
constructor(buffer?: Buffer)
|
||||
/**
|
||||
* Append new buffer to the end of current reader.
|
||||
* @param buffer buffer to append
|
||||
*/
|
||||
append(buffer: Buffer): void;
|
||||
/**
|
||||
* Return current position of the reader.
|
||||
*/
|
||||
tell(): number;
|
||||
/**
|
||||
* Set new position of the reader, if the pos is invalid, an exception will be raised.
|
||||
* @param position new position
|
||||
*/
|
||||
seek(position: number): void;
|
||||
/**
|
||||
* Move the position of reader by offset, offset can be negative; it can be used to skip some bytes.
|
||||
* @param offset offset to move by
|
||||
*/
|
||||
move(offset: number): void;
|
||||
/**
|
||||
* Get all the remaining bytes as a Buffer.
|
||||
*/
|
||||
restAll(): Buffer;
|
||||
/**
|
||||
* Read a buffer with specified length.
|
||||
* @param length specified length
|
||||
*/
|
||||
nextBuffer(length: number): Buffer;
|
||||
/**
|
||||
* Read next length of bytes as String, encoding default is 'utf8'.
|
||||
* @param length length of the string to read
|
||||
* @param encoding encoding of the string
|
||||
*/
|
||||
nextString(length: number, encoding?: string): string;
|
||||
/**
|
||||
* Read next bytes till the end of buffer as null-terminated string, encoding default is 'utf8'.
|
||||
* @param encoding encoding of the string
|
||||
*/
|
||||
nextStringZero(encoding?: string): string;
|
||||
/**
|
||||
* Read next bytes as Int8, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextInt8(): number;
|
||||
/**
|
||||
* Read next bytes as UInt8, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextUInt8(): number;
|
||||
/**
|
||||
* Read next bytes as Int16LE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextInt16LE(): number;
|
||||
/**
|
||||
* Read next bytes as UInt16LE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextUInt16LE(): number;
|
||||
/**
|
||||
* Read next bytes as Int16BE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextInt16BE(): number;
|
||||
/**
|
||||
* Read next bytes as UInt16BE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextUInt16BE(): number;
|
||||
/**
|
||||
* Read next bytes as Int32LE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextInt32LE(): number;
|
||||
/**
|
||||
* Read next bytes as UInt32LE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextUInt32LE(): number;
|
||||
/**
|
||||
* Read next bytes as Int32BE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextInt32BE(): number;
|
||||
/**
|
||||
* Read next bytes as UInt32BE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextUInt32BE(): number;
|
||||
/**
|
||||
* Read next bytes as FloatLE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextFloatLE(): number;
|
||||
/**
|
||||
* Read next bytes as FloatBE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextFloatBE(): number;
|
||||
/**
|
||||
* Read next bytes as Double32LE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextDouble32LE(): number;
|
||||
/**
|
||||
* Read next bytes as Double32BE, the value is just as the same format Buffer in nodejs doc.
|
||||
*/
|
||||
nextDouble32BE(): number;
|
||||
}
|
||||
24
types/buffer-reader/tsconfig.json
Normal file
24
types/buffer-reader/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"esModuleInterop": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"buffer-reader-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/buffer-reader/tslint.json
Normal file
1
types/buffer-reader/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user