rsformat
Version:
Formatting/printing library for JavaScript that takes after rust's string formatting
27 lines (26 loc) • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rs = exports.dbg = exports.eprintln = exports.eprint = exports.println = exports.print = void 0;
const format_1 = require("./format");
var print_1 = require("./print");
Object.defineProperty(exports, "print", { enumerable: true, get: function () { return print_1.print; } });
Object.defineProperty(exports, "println", { enumerable: true, get: function () { return print_1.println; } });
Object.defineProperty(exports, "eprint", { enumerable: true, get: function () { return print_1.eprint; } });
Object.defineProperty(exports, "eprintln", { enumerable: true, get: function () { return print_1.eprintln; } });
Object.defineProperty(exports, "dbg", { enumerable: true, get: function () { return print_1.dbg; } });
/**
* Tag to use Rust-style formatting in a template literal.
* Returns an extended `String` object.
*
* ```js
* let number = 14;
* let info = rs`${number+1} is ${rs.ref(0)}:x in hex`;
* // info == '15 is f in hex'
* ```
*
* @returns a String object with the formatted string
*/
exports.rs = ((strings, ...params) => new format_1.RsString(strings, params));
exports.rs.raw = (strings, ...params) => (0, format_1.buildString)(strings, params).raw;
exports.rs.ref = (n) => ({ __rs_param_ref: n });
exports.rs.style = format_1.style;