fix price and modular

This commit is contained in:
2026-02-01 17:38:39 +03:30
parent 55f34aa15d
commit 164542d3e2
801 changed files with 16129 additions and 14478 deletions
+18 -8
View File
@@ -5,37 +5,47 @@
const fs = require('fs');
/**
* The path where we can find the ldd
*/
const LDD_PATH = '/usr/bin/ldd';
const SELF_PATH = '/proc/self/exe';
const MAX_LENGTH = 2048;
/**
* Read the content of a file synchronous
*
* @param {string} path
* @returns {string}
* @returns {Buffer}
*/
const readFileSync = (path) => fs.readFileSync(path, 'utf-8');
const readFileSync = (path) => {
const fd = fs.openSync(path, 'r');
const buffer = Buffer.alloc(MAX_LENGTH);
const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
fs.close(fd, () => {});
return buffer.subarray(0, bytesRead);
};
/**
* Read the content of a file
*
* @param {string} path
* @returns {Promise<string>}
* @returns {Promise<Buffer>}
*/
const readFile = (path) => new Promise((resolve, reject) => {
fs.readFile(path, 'utf-8', (err, data) => {
fs.open(path, 'r', (err, fd) => {
if (err) {
reject(err);
} else {
resolve(data);
const buffer = Buffer.alloc(MAX_LENGTH);
fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
resolve(buffer.subarray(0, bytesRead));
fs.close(fd, () => {});
});
}
});
});
module.exports = {
LDD_PATH,
SELF_PATH,
readFileSync,
readFile
};