mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add type definitions for fs-readfile-promise.
This commit is contained in:
parent
dc0c4811d4
commit
922ea86c89
32
types/fs-readfile-promise/fs-readfile-promise-tests.ts
Normal file
32
types/fs-readfile-promise/fs-readfile-promise-tests.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import * as readFile from "fs-readfile-promise";
|
||||
|
||||
declare const path: string;
|
||||
declare const encoding: string;
|
||||
declare const nullable: null;
|
||||
declare const options: { encoding: string, flag: string };
|
||||
|
||||
async function testPathOnly() {
|
||||
return readFile(path);
|
||||
}
|
||||
async function testPathEncoding() {
|
||||
return readFile(path, encoding);
|
||||
}
|
||||
async function testPathNull() {
|
||||
return readFile(path, nullable);
|
||||
}
|
||||
async function testPathOption() {
|
||||
return readFile(path, options);
|
||||
}
|
||||
|
||||
testPathOnly()
|
||||
.then(console.log)
|
||||
.catch(console.log);
|
||||
testPathEncoding()
|
||||
.then(console.log)
|
||||
.catch(console.log);
|
||||
testPathNull()
|
||||
.then(console.log)
|
||||
.catch(console.log);
|
||||
testPathOption()
|
||||
.then(console.log)
|
||||
.catch(console.log);
|
||||
29
types/fs-readfile-promise/index.d.ts
vendored
Normal file
29
types/fs-readfile-promise/index.d.ts
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Type definitions for fs-readfile-promise 3.0
|
||||
// Project: https://github.com/shinnn/fs-readfile-promise
|
||||
// Definitions by: Motosugi Murata <https://github.com/mtsg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
import { PathLike } from "fs";
|
||||
type PathType = PathLike | number;
|
||||
type OptionsType = { encoding: string; flag?: string; } | string;
|
||||
|
||||
export = fsReadFilePromise;
|
||||
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
||||
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
||||
* If a flag is not provided, it defaults to `'r'`.
|
||||
*/
|
||||
declare function fsReadFilePromise(path: PathType, options: OptionsType): Promise<string>;
|
||||
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
||||
*/
|
||||
declare function fsReadFilePromise(path: PathType, options?: null): Promise<Buffer>;
|
||||
|
||||
declare namespace fsReadFilePromise { }
|
||||
24
types/fs-readfile-promise/tsconfig.json
Normal file
24
types/fs-readfile-promise/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"fs-readfile-promise-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/fs-readfile-promise/tslint.json
Normal file
1
types/fs-readfile-promise/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user