Browse Source

use BufferEncoding type for file.enc

master
Conduitry 1 year ago
parent
commit
5a7951ef0b
2 changed files with 4 additions and 4 deletions
  1. +3
    -3
      src/File.ts
  2. +1
    -1
      types/index.d.ts

+ 3
- 3
src/File.ts View File

@ -12,7 +12,7 @@ export default class File {
// stats of file
stats: fs.Stats = null;
// encoding
private _enc: string = 'utf8';
private _enc: BufferEncoding = 'utf8';
// Buffer of file contents
private _bytes: Buffer = null;
// string of file contents
@ -80,11 +80,11 @@ export default class File {
this.path = (old ? this._path.slice(0, -old.length) : this._path) + ext;
}
get enc(): string {
get enc(): BufferEncoding {
return this._enc;
}
set enc(enc: string) {
set enc(enc: BufferEncoding) {
if (!Buffer.isEncoding(enc)) {
throw new TypeError('file.enc must be a supported encoding');
}

+ 1
- 1
types/index.d.ts View File

@ -18,7 +18,7 @@ export class File {
dir: string;
filename: string;
ext: string;
enc: string;
enc: BufferEncoding;
bytes: Buffer;
text: string;
}

Loading…
Cancel
Save