laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
30 lines (29 loc) • 1.27 kB
JavaScript
"use client";
var o = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function d(t) {
if (!(n = o.exec(t))) throw new Error("invalid format: " + t);
var n;
return new i({
fill: n[1],
align: n[2],
sign: n[3],
symbol: n[4],
zero: n[5],
width: n[6],
comma: n[7],
precision: n[8] && n[8].slice(1),
trim: n[9],
type: n[10]
});
}
d.prototype = i.prototype;
function i(t) {
this.fill = t.fill === void 0 ? " " : t.fill + "", this.align = t.align === void 0 ? ">" : t.align + "", this.sign = t.sign === void 0 ? "-" : t.sign + "", this.symbol = t.symbol === void 0 ? "" : t.symbol + "", this.zero = !!t.zero, this.width = t.width === void 0 ? void 0 : +t.width, this.comma = !!t.comma, this.precision = t.precision === void 0 ? void 0 : +t.precision, this.trim = !!t.trim, this.type = t.type === void 0 ? "" : t.type + "";
}
i.prototype.toString = function() {
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
};
export {
i as FormatSpecifier,
d as default
};