Skip to content

Commit 01fbf5d

Browse files
committed
feat: add buffer property to method toContract
1 parent 11e0a29 commit 01fbf5d

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/utils",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "",
55
"license": "MIT",
66
"author": "João Lenon",

src/Classes/File.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ export class File {
9999
)
100100
}
101101

102-
toContract(): FileContract {
102+
toContract(buffer = false): FileContract {
103+
const value = this.getContentSync()
104+
103105
return {
104106
base: this.base,
105-
value: this.getContentSync().toString(),
107+
value: buffer ? value : value.toString(),
106108
}
107109
}
108110

src/Classes/Folder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ export class Folder {
7676
this.createFolderValues(mockedValues)
7777
}
7878

79-
toContract(): DirectoryContract {
79+
toContract(buffer = false): DirectoryContract {
8080
return {
8181
name: this.name,
82-
files: this.files.map(file => file.toContract()),
83-
folders: this.folders.map(folder => folder.toContract()),
82+
files: this.files.map(file => file.toContract(buffer)),
83+
folders: this.folders.map(folder => folder.toContract(buffer)),
8484
}
8585
}
8686

src/utils/global.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ declare global {
7070
isCopy?: boolean,
7171
)
7272

73-
toContract(): FileContract
73+
toContract(buffer?: boolean): FileContract
7474
toJSON(): FileJsonContract
7575
createSync(): File
7676
create(): Promise<File>
@@ -202,7 +202,7 @@ declare global {
202202
*/
203203
constructor(folderPath: string, mockedValues?: boolean, isCopy?: boolean)
204204

205-
toContract(): DirectoryContract
205+
toContract(buffer?: boolean): DirectoryContract
206206
toJSON(): FolderJsonContract
207207
createSync(): Folder
208208
create(): Promise<Folder>

0 commit comments

Comments
 (0)