How to use r2-utils-js - 2 common examples

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" });
});
github readium / readium-desktop / scripts / translate-scan.js View on Github external
console.log(`props?! ${props}`);
            continue;
        }
        for (const prop of props) {
            if (!prop || !prop.length) {
                console.log(`prop?! ${prop}`);
                continue;
            }
            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 3 months ago

Package Health Score

56 / 100
Full package analysis