Skip to content

Commit

Permalink
fixup! use FileState class
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed Sep 25, 2024
1 parent ff96083 commit 00fd459
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/internal/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,21 @@ function isFile(object) {
return object?.[kState] !== undefined;
}

class File extends Blob {
[kState] = { __proto__: null };
class FileState {
name;
lastModified;

/**
* @param {string} name
* @param {number} lastModified
*/
constructor(name, lastModified) {
this.name = name;
this.lastModified = lastModified;
}
}

class File extends Blob {
constructor(fileBits, fileName, options = kEmptyObject) {
if (arguments.length < 2) {
throw new ERR_MISSING_ARGS('fileBits', 'fileName');
Expand All @@ -67,8 +79,7 @@ class File extends Blob {
lastModified = DateNow();
}

this[kState].name = StringPrototypeToWellFormed(`${fileName}`);
this[kState].lastModified = lastModified;
this[kState] = new FileState(StringPrototypeToWellFormed(`${fileName}`), lastModified);
}

get name() {
Expand Down Expand Up @@ -113,11 +124,7 @@ class File extends Blob {
[kDeserialize](data) {
super[kDeserialize](data);

this[kState] = {
__proto__: null,
name: data.name,
lastModified: data.lastModified,
};
this[kState] = new FileState(data.name, data.lastModified);
}
}

Expand Down

0 comments on commit 00fd459

Please sign in to comment.