typia
Version:
Superfast runtime validators with only one line
36 lines (34 loc) • 935 B
JavaScript
var ProtobufNameEncoder;
(function (ProtobufNameEncoder) {
ProtobufNameEncoder.encode = (str) => {
for (const [before, after] of REPLACERS)
str = str.split(before).join(after);
return str;
};
ProtobufNameEncoder.decode = (str) => {
for (const [before, after] of REPLACERS)
if (after !== "")
str = str.split(after).join(before);
return str;
};
})(ProtobufNameEncoder || (ProtobufNameEncoder = {}));
const REPLACERS = [
["$", "_dollar_"],
["&", "_and_"],
["|", "_or_"],
["{", "_blt_"],
["}", "_bgt_"],
["<", "_lt_"],
[">", "_gt_"],
["(", "_lp_"],
[")", "_rp_"],
["[", "_alt_"],
["]", "_agt_"],
[",", "_comma_"],
["`", "_backquote_"],
["'", "_singlequote_"],
['"', "_doublequote_"],
[" ", "_space_"],
];
export { ProtobufNameEncoder };
//# sourceMappingURL=ProtobufNameEncoder.mjs.map