Sha256: 4266c8b9c623242cac97efef8bc1b571c13b186086722b3fa3accbf070182f39
Contents?: true
Size: 730 Bytes
Versions: 7
Compression:
Stored size: 730 Bytes
Contents
module.exports = { "@int": (path, _opts, _print) => { const { body } = path.getValue(); // If the number is octal and does not contain the optional "o" character // after the leading 0, add it in. if (/^0[0-9]/.test(body)) { return `0o${body.slice(1)}`; } // If the number is a base 10 number, is sufficiently large, and is not // already formatted with underscores, then add them in in between the // numbers every three characters starting from the right. if (!body.startsWith("0") && body.length >= 4 && !body.includes("_")) { return ` ${body}` .slice((body.length + 2) % 3) .match(/.{3}/g) .join("_") .trim(); } return body; } };
Version data entries
7 entries across 7 versions & 1 rubygems