UNPKG

web-search

Version:

A package to provide search URLs for websites from a search term.

27 lines (26 loc) 1.03 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; exports.__esModule = true; var fs_1 = require("fs"); var data_json_1 = __importDefault(require("./data.json")); console.log("> Sorting websites by name"); data_json_1["default"].websites.sort(function (a, b) { var nameA = a.name.toUpperCase(); var nameB = b.name.toUpperCase(); return nameA < nameB ? -1 : nameA > nameB ? 1 : 0; }); console.log("> Filtering websites, excluding duplicated elements"); data_json_1["default"].websites.filter(function (website, index) { return data_json_1["default"].websites.indexOf(website) == index; }); console.log("> Rendering the object to a JSON string"); var JSONOutput = JSON.stringify(data_json_1["default"], undefined, 4) + "\n"; console.log("> Saving result to 'src/data.json'"); fs_1.writeFile("src/data.json", JSONOutput, function (err) { if (err) { console.error(err); process.exit(1); } });