summaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-08-25 12:36:37 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-08-25 12:36:37 +0200
commite5de70f2c1dcac767bd34a6b90ac1797a7acb433 (patch)
tree25a8c8f339fb5b496b460391ee06a9effeb64855 /lib/util.js
parent6b909d95ec07848136a6f337db28318c1cd46c60 (diff)
parentd7bc21d19e168f3a99f54e5ba4866ed49f1187f1 (diff)
Merge branch 'rust'
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js82
1 files changed, 0 insertions, 82 deletions
diff --git a/lib/util.js b/lib/util.js
deleted file mode 100644
index 65f14ae..0000000
--- a/lib/util.js
+++ /dev/null
@@ -1,82 +0,0 @@
-'use strict';
-
-const Fs = require('fs');
-const Path = require('path');
-
-/**
- * Module containing utility functions
- *
- * @name Util
- * @type Object
- */
-const Util = {
-
- /**
- * Parses a 16 bit number buffer
- *
- * @function parse16BitBuffer
- * @memberof Util
- * @param {Array<String>} buffer the buffer to parse
- * @return {Number} the parsed value
- */
- parse16BitBuffer(buffer) {
-
- return buffer[0] * 256 + buffer[1];
- },
-
- /**
- * Picks a random element from an array
- *
- * @function pickRandom
- * @memberof Util
- * @param {Array} array the array to use
- * @return {Any} the picked element
- */
- pickRandom(array) {
-
- return array[Math.floor(Math.random() * array.length)];
- },
-
- /**
- * For a gi ven path, requires all of the files and returns an array
- * with the results. If the directory contains any non-requireable
- * files, it will fail.
- *
- * @function loadFiles
- * @memberof Util
- * @param {String} path the path where the files are located
- * @return {Array} the array of all the loaded modules
- */
- loadFiles(path) {
-
- return new Promise((resolve, reject) => {
-
- Fs.readdir(path, (err, files) => {
-
- if (err) {
- return reject(err);
- }
-
- const loadedFiles = [];
-
- for (const file of files) {
- const filePath = Path.join(path, file);
- let loadedFile;
-
- try {
- loadedFile = require(filePath);
- }
- catch (err) {
- return reject(err);
- }
-
- loadedFiles.push(loadedFile);
- }
-
- resolve(loadedFiles);
- });
- });
- }
-};
-
-module.exports = Util;