How to use the r2-utils-js/dist/es8-es2017/src/_utils/JsonUtils.sortObject function in r2-utils-js

To help you get started, we’ve selected a few r2-utils-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github readium / readium-desktop / scripts / translate-scan.js View on Github external
}
            if (!jsonRoot[prop]) {
                jsonRoot[prop] = {};
            }
            jsonRoot = jsonRoot[prop];
        }
    }

    jsonUtils.traverseJsonObjects(jsonObj, (obj) => {
        Object.keys(obj).forEach((prop) => {
            if (!Object.keys(obj[prop]).length) {
                obj[prop] = "";
            }
        });
    });
    jsonObj = jsonUtils.sortObject(jsonObj);

    console.log(util.inspect(jsonObj, { colors: true, depth: null, compact: false }));

    const jsonStr = JSON.stringify(jsonObj, null, "    ") + "\n";
    fs.writeFileSync(path.join(process.cwd(), jsonFilePath), jsonStr, { encoding: "utf8" });
});

r2-utils-js

Readium 2 'utils' for NodeJS (TypeScript)

BSD-3-Clause
Latest version published 2 months ago

Package Health Score

60 / 100
Full package analysis