15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const FS = require("fs");
exports.isArray = Array.isArray || (arg => arg instanceof Array);
/**
 * Converts a single value into an array containing that value, unless the value is already an array.
 */
function arrayify(v) {
    return exports.isArray(v) ? v : [v];
}
exports.arrayify = arrayify;
/**
 * Converts an array of length 1 to the one value in it. Other arrays are passed through unchanged.
 */
function unarrayify(v) {
    return v.length === 1 ? v[0] : v;
}
exports.unarrayify = unarrayify;
function readFileP(path) {
    return new Promise((resolve, reject) => {
        FS.readFile(path, (error, data) => {
            if (error)
                reject(error);
            else
                resolve(data);
        });
    });
}
exports.readFileP = readFileP;
function mapObjByKeys(obj, keys, fun, target) {
    if (!target)
        target = {};
    for (const key of keys)
        target[key] = fun(obj[key], key);
    return target;
}
exports.mapObjByKeys = mapObjByKeys;
//# sourceMappingURL=index.js.map