Add typings for read-chunk

This commit is contained in:
crispybee
2017-08-27 23:25:45 +02:00
parent b84df2925f
commit 38e351fa5a
3 changed files with 60 additions and 0 deletions
+29
View File
@@ -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;
}
+9
View File
@@ -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);
});
+22
View File
@@ -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"
]
}