-
-
Notifications
You must be signed in to change notification settings - Fork 1
Raoul de Heer edited this page Dec 17, 2021
·
2 revisions
The buf object consists of:
Loads buffer data from file asynchronous.
- path {string} path to load from.
- callback {objectCallback<Buffer} callback to call.
load: (path: string, callback?: objectCallback<Buffer> | undefined) => Promise<Buffer>;
Using imported Buf object.
Using Await.
import { Buf } from "mylas";
const loadedBuffer = await Buf.load("./file.txt");
console.log(loadedBuffer);
Using imported default mylas object.
Using callback.
import mylas from "mylas";
mylas.buf.load("./file.txt", dataBuffer => {
console.log(dataBuffer);
});
Saves buffer data to file asynchronous.
- path {string} path to save to.
- data {Buffer} data to save.
- callback {voidCallback} callback to call.
save: (path: string, data: Buffer, callback?: voidCallback | undefined) => Promise<void>;
Using imported Buf object.
Using callback.
import { Buf } from "mylas";
const data = Buffer.from("hello: world");
Buf.save("./file.txt", data, () => {
console.log("Saved!");
});
Using imported default mylas object.
Using Await.
import mylas from "mylas";
const data = Buffer.from("hello: world");
await mylas.file.save("./file.txt", data);
Loads buffer data from file multithreaded.
- path {string} path to load from.
- callback {objectCallback} callback to call.
loadW: (path: string, callback?: objectCallback<Buffer> | undefined) => Promise<Buffer>;
Using imported Buf object.
Using Await.
import { Buf } from "mylas";
const loadedBuffer = await Buf.loadW("./file.txt");
console.log(loadedBuffer);
Using imported default mylas object.
Using callback.
import mylas from "mylas";
mylas.buf.loadW("./file.txt", dataBuffer => {
console.log(dataBuffer);
});
Saves buffer data to file multithreaded.
- path {string} path to save to.
- data {Buffer} data to save.
- callback {voidCallback} callback to call.
saveW: (path: string, data: Buffer, callback?: voidCallback | undefined) => Promise<void>;
Using imported Buf object.
Using callback.
import { Buf } from "mylas";
const data = Buffer.from("hello: world");
Buf.saveW("./file.txt", data, () => {
console.log("Saved!");
});
Using imported default mylas object.
Using Await.
import mylas from "mylas";
const data = Buffer.from("hello: world");
await mylas.file.saveW("./file.txt", data);