UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

48 lines (47 loc) 1.24 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { Character } from "../support/Character.js"; class Utils { static { __name(this, "Utils"); } static stripFileExtension(name) { const lastDot = name.lastIndexOf("."); if (lastDot < 0) { return name; } return name.substring(0, lastDot); } static sortLinesInString(s) { const lines = s.split("\n"); lines.sort(); return lines.join("\n") + "\n"; } static capitalize(s) { return Character.toUpperCase(s.charAt(0)) + s.substring(1); } static decapitalize(s) { return Character.toLowerCase(s.charAt(0)) + s.substring(1); } static setSize(list, size) { const oldLength = list.length; list.length = size; if (oldLength < size) { list.fill(null, oldLength, size); } } /** * Type guard for accessing a member in an object without an index signature. * * @param obj The object to check. * @param key The key to check. * * @returns True if the key is a member of the object. */ static hasKey = /* @__PURE__ */ __name((obj, key) => { return key in obj; }, "hasKey"); } export { Utils };