mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
Add typings for read-chunk
This commit is contained in:
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for read-chunk v2.1.0
|
||||
// Project: https://github.com/sindresorhus/read-chunk
|
||||
// Definitions by: crispybee <https://github.com/crispybee>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export = ReadChunk;
|
||||
|
||||
/**
|
||||
* Asynchronous: Reads a chunk from a file. Returns a Promise<Buffer>.
|
||||
* @param {string} filePath The path to the file.
|
||||
* @param {number} startingPosition Position to start reading.
|
||||
* @param {number} length Number of bytes to read.
|
||||
* @return {Promise<Buffer>} Returns a Promise<Buffer>.
|
||||
*/
|
||||
declare function ReadChunk(filePath: string, startingPosition: number, length: number): Promise<Buffer>;
|
||||
|
||||
declare namespace ReadChunk {
|
||||
/**
|
||||
* Synchronous: Reads a chunk from a file. Returns a Buffer.
|
||||
* @param {string} filePath The path to the file.
|
||||
* @param {number} startingPosition Position to start reading.
|
||||
* @param {number} length Number of bytes to read.
|
||||
* @return {Buffer} Returns a Buffer.
|
||||
*/
|
||||
function sync(filePath: string, startingPosition: number, length: number): Buffer;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import readChunk = require('read-chunk');
|
||||
|
||||
let chunk: Buffer = readChunk.sync('foo.txt', 1, 3);
|
||||
|
||||
readChunk('foo.txt', 1, 3).then(value => {
|
||||
console.log(value);
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"read-chunk-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user