1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 | const fs = require("fs");
|
5 | function flatMap(arr, fn) {
|
6 | return arr.reduce((arr, i) => arr.concat(fn(i)), []);
|
7 | }
|
8 | exports.flatMap = flatMap;
|
9 | function mapValues(obj, fn) {
|
10 | return Object.entries(obj)
|
11 | .reduce((o, [k, v]) => {
|
12 | o[k] = fn(v, k);
|
13 | return o;
|
14 | }, {});
|
15 | }
|
16 | exports.mapValues = mapValues;
|
17 | function loadJSONSync(path) {
|
18 | let loadJSON;
|
19 | try {
|
20 | loadJSON = require('load-json-file');
|
21 | }
|
22 | catch (_a) { }
|
23 | if (loadJSON)
|
24 | return loadJSON.sync(path);
|
25 | return JSON.parse(fs.readFileSync(path, 'utf8'));
|
26 | }
|
27 | exports.loadJSONSync = loadJSONSync;
|
28 | function compact(a) {
|
29 | return a.filter((a) => !!a);
|
30 | }
|
31 | exports.compact = compact;
|
32 | function uniq(arr) {
|
33 | return arr.filter((a, i) => arr.findIndex(b => b === a) === i);
|
34 | }
|
35 | exports.uniq = uniq;
|