1 | /// <reference types="node" />
|
2 | export interface EncodingOpts {
|
3 | /** Defaults to 24 */
|
4 | chunkLength?: number;
|
5 | /** If not provided, will check the start, beginning, and end */
|
6 | chunkBegin?: number;
|
7 | }
|
8 | /**
|
9 | * Determine if the filename and/or buffer is text.
|
10 | * Determined by extension checks first (if filename is available), otherwise if unknown extension or no filename, will perform a slower buffer encoding detection.
|
11 | * This order is done, as extension checks are quicker, and also because encoding checks cannot guarantee accuracy for chars between utf8 and utf16.
|
12 | * The extension checks are performed using the resources https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions
|
13 | * @param filename The filename for the file/buffer if available
|
14 | * @param buffer The buffer for the file if available
|
15 | * @returns Will be `null` if neither `filename` nor `buffer` were provided. Otherwise will be a boolean value with the detection result.
|
16 | */
|
17 | export declare function isText(filename?: string | null, buffer?: Buffer | null): boolean | null;
|
18 | /**
|
19 | * Determine if the filename and/or buffer is binary.
|
20 | * Determined by extension checks first (if filename is available), otherwise if unknown extension or no filename, will perform a slower buffer encoding detection.
|
21 | * This order is done, as extension checks are quicker, and also because encoding checks cannot guarantee accuracy for chars between utf8 and utf16.
|
22 | * The extension checks are performed using the resources https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions
|
23 | * @param filename The filename for the file/buffer if available
|
24 | * @param buffer The buffer for the file if available
|
25 | * @returns Will be `null` if neither `filename` nor `buffer` were provided. Otherwise will be a boolean value with the detection result.
|
26 | */
|
27 | export declare function isBinary(filename?: string | null, buffer?: Buffer | null): boolean | null;
|
28 | /**
|
29 | * Get the encoding of a buffer.
|
30 | * Checks the start, middle, and end of the buffer for characters that are unrecognized within UTF8 encoding.
|
31 | * History has shown that inspection at all three locations is necessary.
|
32 | * @returns Will be `null` if `buffer` was not provided. Otherwise will be either `'utf8'` or `'binary'`
|
33 | */
|
34 | export declare function getEncoding(buffer: Buffer | null, opts?: EncodingOpts): 'utf8' | 'binary' | null;
|
35 | //# sourceMappingURL=index.d.ts.map |
\ | No newline at end of file |