UNPKG

@anycli/config

Version:

base config object and standard interfaces for anycli components

28 lines (27 loc) 719 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // tslint:disable no-implicit-dependencies const fs = require("fs"); function flatMap(arr, fn) { return arr.reduce((arr, i) => arr.concat(fn(i)), []); } exports.flatMap = flatMap; function mapValues(obj, fn) { return Object.entries(obj) .reduce((o, [k, v]) => { o[k] = fn(v, k); return o; }, {}); } exports.mapValues = mapValues; function loadJSONSync(path) { let loadJSON; try { loadJSON = require('load-json-file'); } catch (_a) { } if (loadJSON) return loadJSON.sync(path); return JSON.parse(fs.readFileSync(path, 'utf8')); } exports.loadJSONSync = loadJSONSync;