@synstack/str 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/str.index.ts","../src/str.bundle.ts","../src/str.chainable.ts","../src/str.lib.ts"],"sourcesContent":["export * from \"./str.bundle\";\nexport type { Str } from \"./str.chainable\";\n","export {\n camelCase,\n capitalCase,\n constantCase,\n dotCase,\n kebabCase,\n noCase,\n pascalCase,\n pascalSnakeCase,\n pathCase,\n sentenceCase,\n snakeCase,\n trainCase,\n} from \"change-case\";\nexport { str } from \"./str.chainable\";\nexport * from \"./str.lib\";\n","import { Pipeable } from \"@synstack/pipe\";\nimport * as changeCase from \"change-case\";\nimport * as lib from \"./str.lib\";\n\nexport type Stringable = {\n toString: () => string;\n};\n\nexport class Str extends Pipeable<Str, string> {\n public constructor(private readonly text: string) {\n super();\n }\n\n public valueOf(): string {\n return this.text;\n }\n\n public toString() {\n return this.text;\n }\n\n public instanceOf(): Str {\n return this;\n }\n\n /**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\n public chopEmptyLinesStart() {\n return new Str(lib.chopEmptyLinesStart(this.text));\n }\n\n /**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\n public chopEmptyLinesEnd() {\n return new Str(lib.chopEmptyLinesEnd(this.text));\n }\n\n /**\n * Remove all space (\\s) characters in lines without content\n */\n public trimEmptyLines() {\n return new Str(lib.trimEmptyLines(this.text));\n }\n\n /**\n * Remove all spaces (\\s) characters at the end of lines\n */\n public trimLinesTrailingSpaces() {\n return new Str(lib.trimLinesTrailingSpaces(this.text));\n }\n\n /**\n * Removes the leading and trailing white space and line terminator characters\n */\n public trim() {\n return new Str(lib.trim(this.text));\n }\n\n /**\n * Removes the leading white space and line terminator characters\n */\n public trimStart() {\n return new Str(lib.trimStart(this.text));\n }\n\n /**\n * Removes the trailing white space and line terminator characters\n */\n public trimEnd() {\n return new Str(lib.trimEnd(this.text));\n }\n\n /**\n * Split a string into substrings using the specified separator and return them as an array\n */\n public split(separator: string | RegExp, limit?: number) {\n return lib.split(this.text, separator, limit).map((v) => new Str(v));\n }\n\n /**\n * Add line numbers to a string\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\n public addLineNumbers(separator: string = \":\") {\n return new Str(lib.addLineNumbers(this.text, separator));\n }\n\n /**\n * Returns the character at the specified index\n * @return string or undefined if the index is out of bounds\n */\n public at(index: number) {\n return this.text.at(index);\n }\n\n /**\n * Returns the length of the string\n */\n public length() {\n return this.text.length;\n }\n\n /**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\n public indent(size: number, char: string = \" \") {\n return new Str(lib.indent(this.text, size, char));\n }\n\n /**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\n public dedent(indentation?: number) {\n return new Str(lib.dedent(this.text, indentation));\n }\n\n /**\n * Chop the string at the start by the specified number of characters\n */\n public chopStart(count: number) {\n return new Str(lib.chopStart(this.text, count));\n }\n\n /**\n * Chop the string at the end by the specified number of characters\n */\n public chopEnd(count: number) {\n if (count === 0) return this;\n return new Str(lib.chopEnd(this.text, count));\n }\n\n /**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\n public chopRepeatNewlines(maxRepeat: number) {\n if (maxRepeat === 0) return this;\n return new Str(lib.chopRepeatNewlines(this.text, maxRepeat));\n }\n\n /**\n * Take the first n characters of the string\n */\n public takeStart(count: number) {\n return new Str(lib.takeStart(this.text, count));\n }\n\n /**\n * Take the last n characters of the string\n */\n public takeEnd(count: number) {\n return new Str(lib.takeEnd(this.text, count));\n }\n\n /**\n * Returns the last line of the string\n */\n public lastLine() {\n return new Str(lib.lastLine(this.text));\n }\n\n /**\n * Returns the first line of the string\n */\n public firstLine() {\n return new Str(lib.firstLine(this.text));\n }\n\n /**\n * Returns the number of leading spaces in the string\n */\n public leadingSpacesCount() {\n return lib.leadingSpacesCount(this.text);\n }\n\n /**\n * Returns the indentation level of the string skipping empty lines in the process\n */\n public indentation() {\n return lib.indentation(this.text);\n }\n\n /**\n * Returns true if the string is empty or contains only whitespace\n */\n public isEmpty() {\n return lib.isEmpty(this.text);\n }\n\n /**\n * Converts the string to camel case\n */\n public camelCase() {\n return new Str(changeCase.camelCase(this.text));\n }\n\n /**\n * Converts the string to capital case\n */\n public capitalCase() {\n return new Str(changeCase.capitalCase(this.text));\n }\n\n /**\n * Converts the string to constant case\n */\n public constantCase() {\n return new Str(changeCase.constantCase(this.text));\n }\n\n /**\n * Converts the string to dot case\n */\n public dotCase() {\n return new Str(changeCase.dotCase(this.text));\n }\n\n /**\n * Converts the string to kebab case\n */\n public kebabCase() {\n return new Str(changeCase.kebabCase(this.text));\n }\n\n /**\n * Converts the string to no case\n */\n public noCase() {\n return new Str(changeCase.noCase(this.text));\n }\n\n /**\n * Converts the string to pascal case\n */\n public pascalCase() {\n return new Str(changeCase.pascalCase(this.text));\n }\n\n /**\n * Converts the string to pascal snake case\n */\n public pascalSnakeCase() {\n return new Str(changeCase.pascalSnakeCase(this.text));\n }\n\n /**\n * Converts the string to path case\n */\n public pathCase() {\n return new Str(changeCase.pathCase(this.text));\n }\n\n /**\n * Converts the string to sentence case\n */\n public sentenceCase() {\n return new Str(changeCase.sentenceCase(this.text));\n }\n\n /**\n * Converts the string to snake case\n */\n public snakeCase() {\n return new Str(changeCase.snakeCase(this.text));\n }\n\n /**\n * Converts the string to train case\n */\n public trainCase() {\n return new Str(changeCase.trainCase(this.text));\n }\n\n /**\n * Shorthand for `.toString()`\n */\n public get str() {\n return this.toString();\n }\n}\n\nexport const str = (text: Stringable) => {\n return new Str(text.toString());\n};\n","/**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\nexport const chopEmptyLinesStart = (text: string) => {\n return text.replace(/^(\\s*\\n)+/, \"\");\n};\n\n/**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\nexport const chopEmptyLinesEnd = (text: string) => {\n return text.replace(/(\\n\\s*)+$/, \"\");\n};\n\n/**\n * Remove all space (\\s) characters in lines without content\n */\nexport const trimEmptyLines = (text: string) => {\n return text.replace(/(^|\\n)\\s+(\\n|$)/g, \"$1$2\");\n};\n\n/**\n * Remove all space (\\s) characters at the end of lines\n */\nexport const trimLinesTrailingSpaces = (text: string) => {\n return text.replace(/ +(\\n|$)/g, \"$1\");\n};\n\n/**\n * Removes the leading and trailing white space and line terminator characters\n */\nexport const trim = (text: string) => {\n return text.trim();\n};\n\n/**\n * Removes the leading white space and line terminator characters\n */\nexport const trimStart = (text: string) => {\n return text.trimStart();\n};\n\n/**\n * Removes the trailing white space and line terminator characters\n */\nexport const trimEnd = (text: string) => {\n return text.trimEnd();\n};\n\n/**\n * Split a string into substrings using the specified separator and return them as an array\n */\nexport const split = (\n text: string,\n separator: string | RegExp,\n limit?: number,\n) => {\n return text.split(separator, limit);\n};\n\n/**\n * Add line numbers to a string\n * @param text The string to add line numbers to\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\nexport const addLineNumbers = (text: string, separator: string = \":\") => {\n return text\n .split(\"\\n\")\n .map((line, index) => `${index}${separator}${line}`)\n .join(\"\\n\");\n};\n\n/**\n * Returns the indentation level of the string skipping empty lines in the process\n */\nexport const indentation = (text: string) => {\n return (\n text.split(\"\\n\").reduce((acc: number | null, line) => {\n if (line.trim() === \"\") return acc;\n const indentation = leadingSpacesCount(line);\n if (acc === null) return indentation;\n return Math.min(acc, indentation);\n }, null) ?? 0\n );\n};\n\n/**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\nexport const indent = (text: string, size: number, char: string = \" \") => {\n if (size === 0) return text;\n\n const indentStr = char.repeat(size);\n return text\n .split(\"\\n\")\n .map((line) => indentStr + line)\n .join(\"\\n\");\n};\n\n/**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\nexport const dedent = (text: string, size?: number) => {\n const _size = size ?? indentation(text);\n if (_size === 0) return text;\n const regex = new RegExp(`^\\\\s{1,${_size}}`);\n return text\n .split(\"\\n\")\n .map((line) => line.replace(regex, \"\"))\n .join(\"\\n\");\n};\n\n/**\n * Chop the string at the end by the specified number of characters\n */\nexport const chopEnd = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(0, -count);\n};\n\n/**\n * Chop the string at the start by the specified number of characters\n */\nexport const chopStart = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(count);\n};\n\n/**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\nexport const chopRepeatNewlines = (text: string, maxRepeat: number) => {\n if (maxRepeat === 0) return text;\n return text.replace(\n new RegExp(`\\n{${maxRepeat + 1},}`, \"g\"),\n \"\\n\".repeat(maxRepeat),\n );\n};\n\n/**\n * Take the first n characters of the string\n */\nexport const takeStart = (text: string, count: number) => {\n return text.slice(0, count);\n};\n\n/**\n * Take the last n characters of the string\n */\nexport const takeEnd = (text: string, count: number) => {\n return text.slice(-count);\n};\n\n/**\n * Returns the last line of the string\n */\nexport const lastLine = (text: string) => {\n return text.split(\"\\n\").at(-1) ?? \"\";\n};\n\n/**\n * Returns the first line of the string\n */\nexport const firstLine = (text: string) => {\n return text.split(\"\\n\").at(0) ?? \"\";\n};\n\n/**\n * Returns the number of leading spaces in the string\n */\nexport const leadingSpacesCount = (text: string) => {\n return text.match(/^\\s+/)?.at(0)?.length ?? 0;\n};\n\n/**\n * Returns true if the string is empty or contains only whitespace\n */\nexport const isEmpty = (text: string) => {\n return text.trim() === \"\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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A,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKO,eAAe;AACpB,WAAO,IAAI,KAAe,wBAAa,KAAK,IAAI,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,MAAM;AACf,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAEO,IAAM,MAAM,CAAC,SAAqB;AACvC,SAAO,IAAI,IAAI,KAAK,SAAS,CAAC;AAChC;","names":["indentation","indentation"]}
1
+ {"version":3,"sources":["../src/str.index.ts","../src/str.bundle.ts","../src/str.chainable.ts","../src/str.lib.ts"],"sourcesContent":["export * from \"./str.bundle\";\nexport type { Str } from \"./str.chainable\";\n","export {\n camelCase,\n capitalCase,\n constantCase,\n dotCase,\n kebabCase,\n noCase,\n pascalCase,\n pascalSnakeCase,\n pathCase,\n sentenceCase,\n snakeCase,\n trainCase,\n} from \"change-case\";\nexport { str } from \"./str.chainable\";\nexport * from \"./str.lib\";\n","import { Stringable } from \"@shared/ts.utils\";\nimport { Pipeable } from \"@synstack/pipe\";\nimport * as changeCase from \"change-case\";\nimport * as lib from \"./str.lib\";\n\nexport class Str extends Pipeable<Str, string> {\n public constructor(private readonly text: string) {\n super();\n }\n\n public valueOf(): string {\n return this.text;\n }\n\n public toString() {\n return this.text;\n }\n\n public instanceOf(): Str {\n return this;\n }\n\n /**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\n public chopEmptyLinesStart() {\n return new Str(lib.chopEmptyLinesStart(this.text));\n }\n\n /**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\n public chopEmptyLinesEnd() {\n return new Str(lib.chopEmptyLinesEnd(this.text));\n }\n\n /**\n * Remove all space (\\s) characters in lines without content\n */\n public trimEmptyLines() {\n return new Str(lib.trimEmptyLines(this.text));\n }\n\n /**\n * Remove all spaces (\\s) characters at the end of lines\n */\n public trimLinesTrailingSpaces() {\n return new Str(lib.trimLinesTrailingSpaces(this.text));\n }\n\n /**\n * Removes the leading and trailing white space and line terminator characters\n */\n public trim() {\n return new Str(lib.trim(this.text));\n }\n\n /**\n * Removes the leading white space and line terminator characters\n */\n public trimStart() {\n return new Str(lib.trimStart(this.text));\n }\n\n /**\n * Removes the trailing white space and line terminator characters\n */\n public trimEnd() {\n return new Str(lib.trimEnd(this.text));\n }\n\n /**\n * Split a string into substrings using the specified separator and return them as an array\n */\n public split(separator: string | RegExp, limit?: number) {\n return lib.split(this.text, separator, limit).map((v) => new Str(v));\n }\n\n /**\n * Add line numbers to a string\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\n public addLineNumbers(separator: string = \":\") {\n return new Str(lib.addLineNumbers(this.text, separator));\n }\n\n /**\n * Returns the character at the specified index\n * @return string or undefined if the index is out of bounds\n */\n public at(index: number) {\n return this.text.at(index);\n }\n\n /**\n * Returns the length of the string\n */\n public length() {\n return this.text.length;\n }\n\n /**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\n public indent(size: number, char: string = \" \") {\n return new Str(lib.indent(this.text, size, char));\n }\n\n /**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\n public dedent(indentation?: number) {\n return new Str(lib.dedent(this.text, indentation));\n }\n\n /**\n * Chop the string at the start by the specified number of characters\n */\n public chopStart(count: number) {\n return new Str(lib.chopStart(this.text, count));\n }\n\n /**\n * Chop the string at the end by the specified number of characters\n */\n public chopEnd(count: number) {\n if (count === 0) return this;\n return new Str(lib.chopEnd(this.text, count));\n }\n\n /**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\n public chopRepeatNewlines(maxRepeat: number) {\n if (maxRepeat === 0) return this;\n return new Str(lib.chopRepeatNewlines(this.text, maxRepeat));\n }\n\n /**\n * Take the first n characters of the string\n */\n public takeStart(count: number) {\n return new Str(lib.takeStart(this.text, count));\n }\n\n /**\n * Take the last n characters of the string\n */\n public takeEnd(count: number) {\n return new Str(lib.takeEnd(this.text, count));\n }\n\n /**\n * Returns the last line of the string\n */\n public lastLine() {\n return new Str(lib.lastLine(this.text));\n }\n\n /**\n * Returns the first line of the string\n */\n public firstLine() {\n return new Str(lib.firstLine(this.text));\n }\n\n /**\n * Returns the number of leading spaces in the string\n */\n public leadingSpacesCount() {\n return lib.leadingSpacesCount(this.text);\n }\n\n /**\n * Returns the indentation level of the string skipping empty lines in the process\n */\n public indentation() {\n return lib.indentation(this.text);\n }\n\n /**\n * Returns true if the string is empty or contains only whitespace\n */\n public isEmpty() {\n return lib.isEmpty(this.text);\n }\n\n /**\n * Converts the string to camel case\n */\n public camelCase() {\n return new Str(changeCase.camelCase(this.text));\n }\n\n /**\n * Converts the string to capital case\n */\n public capitalCase() {\n return new Str(changeCase.capitalCase(this.text));\n }\n\n /**\n * Converts the string to constant case\n */\n public constantCase() {\n return new Str(changeCase.constantCase(this.text));\n }\n\n /**\n * Converts the string to dot case\n */\n public dotCase() {\n return new Str(changeCase.dotCase(this.text));\n }\n\n /**\n * Converts the string to kebab case\n */\n public kebabCase() {\n return new Str(changeCase.kebabCase(this.text));\n }\n\n /**\n * Converts the string to no case\n */\n public noCase() {\n return new Str(changeCase.noCase(this.text));\n }\n\n /**\n * Converts the string to pascal case\n */\n public pascalCase() {\n return new Str(changeCase.pascalCase(this.text));\n }\n\n /**\n * Converts the string to pascal snake case\n */\n public pascalSnakeCase() {\n return new Str(changeCase.pascalSnakeCase(this.text));\n }\n\n /**\n * Converts the string to path case\n */\n public pathCase() {\n return new Str(changeCase.pathCase(this.text));\n }\n\n /**\n * Converts the string to sentence case\n */\n public sentenceCase() {\n return new Str(changeCase.sentenceCase(this.text));\n }\n\n /**\n * Converts the string to snake case\n */\n public snakeCase() {\n return new Str(changeCase.snakeCase(this.text));\n }\n\n /**\n * Converts the string to train case\n */\n public trainCase() {\n return new Str(changeCase.trainCase(this.text));\n }\n\n /**\n * Shorthand for `.toString()`\n */\n public get str() {\n return this.toString();\n }\n}\n\nexport const str = (text: Stringable) => {\n return new Str(text.toString());\n};\n","/**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\nexport const chopEmptyLinesStart = (text: string) => {\n return text.replace(/^(\\s*\\n)+/, \"\");\n};\n\n/**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\nexport const chopEmptyLinesEnd = (text: string) => {\n return text.replace(/(\\n\\s*)+$/, \"\");\n};\n\n/**\n * Remove all space (\\s) characters in lines without content\n */\nexport const trimEmptyLines = (text: string) => {\n return text.replace(/(^|\\n)\\s+(\\n|$)/g, \"$1$2\");\n};\n\n/**\n * Remove all space (\\s) characters at the end of lines\n */\nexport const trimLinesTrailingSpaces = (text: string) => {\n return text.replace(/ +(\\n|$)/g, \"$1\");\n};\n\n/**\n * Removes the leading and trailing white space and line terminator characters\n */\nexport const trim = (text: string) => {\n return text.trim();\n};\n\n/**\n * Removes the leading white space and line terminator characters\n */\nexport const trimStart = (text: string) => {\n return text.trimStart();\n};\n\n/**\n * Removes the trailing white space and line terminator characters\n */\nexport const trimEnd = (text: string) => {\n return text.trimEnd();\n};\n\n/**\n * Split a string into substrings using the specified separator and return them as an array\n */\nexport const split = (\n text: string,\n separator: string | RegExp,\n limit?: number,\n) => {\n return text.split(separator, limit);\n};\n\n/**\n * Add line numbers to a string\n * @param text The string to add line numbers to\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\nexport const addLineNumbers = (text: string, separator: string = \":\") => {\n return text\n .split(\"\\n\")\n .map((line, index) => `${index}${separator}${line}`)\n .join(\"\\n\");\n};\n\n/**\n * Returns the indentation level of the string skipping empty lines in the process\n */\nexport const indentation = (text: string) => {\n return (\n text.split(\"\\n\").reduce((acc: number | null, line) => {\n if (line.trim() === \"\") return acc;\n const indentation = leadingSpacesCount(line);\n if (acc === null) return indentation;\n return Math.min(acc, indentation);\n }, null) ?? 0\n );\n};\n\n/**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\nexport const indent = (text: string, size: number, char: string = \" \") => {\n if (size === 0) return text;\n\n const indentStr = char.repeat(size);\n return text\n .split(\"\\n\")\n .map((line) => indentStr + line)\n .join(\"\\n\");\n};\n\n/**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\nexport const dedent = (text: string, size?: number) => {\n const _size = size ?? indentation(text);\n if (_size === 0) return text;\n const regex = new RegExp(`^\\\\s{1,${_size}}`);\n return text\n .split(\"\\n\")\n .map((line) => line.replace(regex, \"\"))\n .join(\"\\n\");\n};\n\n/**\n * Chop the string at the end by the specified number of characters\n */\nexport const chopEnd = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(0, -count);\n};\n\n/**\n * Chop the string at the start by the specified number of characters\n */\nexport const chopStart = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(count);\n};\n\n/**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\nexport const chopRepeatNewlines = (text: string, maxRepeat: number) => {\n if (maxRepeat === 0) return text;\n return text.replace(\n new RegExp(`\\n{${maxRepeat + 1},}`, \"g\"),\n \"\\n\".repeat(maxRepeat),\n );\n};\n\n/**\n * Take the first n characters of the string\n */\nexport const takeStart = (text: string, count: number) => {\n return text.slice(0, count);\n};\n\n/**\n * Take the last n characters of the string\n */\nexport const takeEnd = (text: string, count: number) => {\n return text.slice(-count);\n};\n\n/**\n * Returns the last line of the string\n */\nexport const lastLine = (text: string) => {\n return text.split(\"\\n\").at(-1) ?? \"\";\n};\n\n/**\n * Returns the first line of the string\n */\nexport const firstLine = (text: string) => {\n return text.split(\"\\n\").at(0) ?? \"\";\n};\n\n/**\n * Returns the number of leading spaces in the string\n */\nexport const leadingSpacesCount = (text: string) => {\n return text.match(/^\\s+/)?.at(0)?.length ?? 0;\n};\n\n/**\n * Returns true if the string is empty or contains only whitespace\n */\nexport const isEmpty = (text: string) => {\n return text.trim() === \"\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAaO;;;ACZP,kBAAyB;AACzB,iBAA4B;;;ACCrB,IAAM,sBAAsB,CAAC,SAAiB;AACnD,SAAO,KAAK,QAAQ,aAAa,EAAE;AACrC;AAKO,IAAM,oBAAoB,CAAC,SAAiB;AACjD,SAAO,KAAK,QAAQ,aAAa,EAAE;AACrC;AAKO,IAAM,iBAAiB,CAAC,SAAiB;AAC9C,SAAO,KAAK,QAAQ,oBAAoB,MAAM;AAChD;AAKO,IAAM,0BAA0B,CAAC,SAAiB;AACvD,SAAO,KAAK,QAAQ,aAAa,IAAI;AACvC;AAKO,IAAM,OAAO,CAAC,SAAiB;AACpC,SAAO,KAAK,KAAK;AACnB;AAKO,IAAM,YAAY,CAAC,SAAiB;AACzC,SAAO,KAAK,UAAU;AACxB;AAKO,IAAM,UAAU,CAAC,SAAiB;AACvC,SAAO,KAAK,QAAQ;AACtB;AAKO,IAAM,QAAQ,CACnB,MACA,WACA,UACG;AACH,SAAO,KAAK,MAAM,WAAW,KAAK;AACpC;AAQO,IAAM,iBAAiB,CAAC,MAAc,YAAoB,QAAQ;AACvE,SAAO,KACJ,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,UAAU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KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKO,SAAS;AACd,WAAO,IAAI,KAAe,kBAAO,KAAK,IAAI,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA,EAKO,aAAa;AAClB,WAAO,IAAI,KAAe,sBAAW,KAAK,IAAI,CAAC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA,EAKO,kBAAkB;AACvB,WAAO,IAAI,KAAe,2BAAgB,KAAK,IAAI,CAAC;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,WAAO,IAAI,KAAe,oBAAS,KAAK,IAAI,CAAC;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKO,eAAe;AACpB,WAAO,IAAI,KAAe,wBAAa,KAAK,IAAI,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,MAAM;AACf,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAEO,IAAM,MAAM,CAAC,SAAqB;AACvC,SAAO,IAAI,IAAI,KAAK,SAAS,CAAC;AAChC;","names":["indentation","indentation"]}
@@ -1,9 +1,13 @@
1
1
  export { camelCase, capitalCase, constantCase, dotCase, kebabCase, noCase, pascalCase, pascalSnakeCase, pathCase, sentenceCase, snakeCase, trainCase } from 'change-case';
2
2
  import { Pipeable } from '@synstack/pipe';
3
3
 
4
+ /**
5
+ * A type serializable to string
6
+ */
4
7
  type Stringable = {
5
- toString: () => string;
8
+ toString(): string;
6
9
  };
10
+
7
11
  declare class Str extends Pipeable<Str, string> {
8
12
  private readonly text;
9
13
  constructor(text: string);
@@ -1,9 +1,13 @@
1
1
  export { camelCase, capitalCase, constantCase, dotCase, kebabCase, noCase, pascalCase, pascalSnakeCase, pathCase, sentenceCase, snakeCase, trainCase } from 'change-case';
2
2
  import { Pipeable } from '@synstack/pipe';
3
3
 
4
+ /**
5
+ * A type serializable to string
6
+ */
4
7
  type Stringable = {
5
- toString: () => string;
8
+ toString(): string;
6
9
  };
10
+
7
11
  declare class Str extends Pipeable<Str, string> {
8
12
  private readonly text;
9
13
  constructor(text: string);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/str.bundle.ts","../src/str.chainable.ts","../src/str.lib.ts"],"sourcesContent":["export {\n camelCase,\n capitalCase,\n constantCase,\n dotCase,\n kebabCase,\n noCase,\n pascalCase,\n pascalSnakeCase,\n pathCase,\n sentenceCase,\n snakeCase,\n trainCase,\n} from \"change-case\";\nexport { str } from \"./str.chainable\";\nexport * from \"./str.lib\";\n","import { Pipeable } from \"@synstack/pipe\";\nimport * as changeCase from \"change-case\";\nimport * as lib from \"./str.lib\";\n\nexport type Stringable = {\n toString: () => string;\n};\n\nexport class Str extends Pipeable<Str, string> {\n public constructor(private readonly text: string) {\n super();\n }\n\n public valueOf(): string {\n return this.text;\n }\n\n public toString() {\n return this.text;\n }\n\n public instanceOf(): Str {\n return this;\n }\n\n /**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\n public chopEmptyLinesStart() {\n return new Str(lib.chopEmptyLinesStart(this.text));\n }\n\n /**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\n public chopEmptyLinesEnd() {\n return new Str(lib.chopEmptyLinesEnd(this.text));\n }\n\n /**\n * Remove all space (\\s) characters in lines without content\n */\n public trimEmptyLines() {\n return new Str(lib.trimEmptyLines(this.text));\n }\n\n /**\n * Remove all spaces (\\s) characters at the end of lines\n */\n public trimLinesTrailingSpaces() {\n return new Str(lib.trimLinesTrailingSpaces(this.text));\n }\n\n /**\n * Removes the leading and trailing white space and line terminator characters\n */\n public trim() {\n return new Str(lib.trim(this.text));\n }\n\n /**\n * Removes the leading white space and line terminator characters\n */\n public trimStart() {\n return new Str(lib.trimStart(this.text));\n }\n\n /**\n * Removes the trailing white space and line terminator characters\n */\n public trimEnd() {\n return new Str(lib.trimEnd(this.text));\n }\n\n /**\n * Split a string into substrings using the specified separator and return them as an array\n */\n public split(separator: string | RegExp, limit?: number) {\n return lib.split(this.text, separator, limit).map((v) => new Str(v));\n }\n\n /**\n * Add line numbers to a string\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\n public addLineNumbers(separator: string = \":\") {\n return new Str(lib.addLineNumbers(this.text, separator));\n }\n\n /**\n * Returns the character at the specified index\n * @return string or undefined if the index is out of bounds\n */\n public at(index: number) {\n return this.text.at(index);\n }\n\n /**\n * Returns the length of the string\n */\n public length() {\n return this.text.length;\n }\n\n /**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\n public indent(size: number, char: string = \" \") {\n return new Str(lib.indent(this.text, size, char));\n }\n\n /**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\n public dedent(indentation?: number) {\n return new Str(lib.dedent(this.text, indentation));\n }\n\n /**\n * Chop the string at the start by the specified number of characters\n */\n public chopStart(count: number) {\n return new Str(lib.chopStart(this.text, count));\n }\n\n /**\n * Chop the string at the end by the specified number of characters\n */\n public chopEnd(count: number) {\n if (count === 0) return this;\n return new Str(lib.chopEnd(this.text, count));\n }\n\n /**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\n public chopRepeatNewlines(maxRepeat: number) {\n if (maxRepeat === 0) return this;\n return new Str(lib.chopRepeatNewlines(this.text, maxRepeat));\n }\n\n /**\n * Take the first n characters of the string\n */\n public takeStart(count: number) {\n return new Str(lib.takeStart(this.text, count));\n }\n\n /**\n * Take the last n characters of the string\n */\n public takeEnd(count: number) {\n return new Str(lib.takeEnd(this.text, count));\n }\n\n /**\n * Returns the last line of the string\n */\n public lastLine() {\n return new Str(lib.lastLine(this.text));\n }\n\n /**\n * Returns the first line of the string\n */\n public firstLine() {\n return new Str(lib.firstLine(this.text));\n }\n\n /**\n * Returns the number of leading spaces in the string\n */\n public leadingSpacesCount() {\n return lib.leadingSpacesCount(this.text);\n }\n\n /**\n * Returns the indentation level of the string skipping empty lines in the process\n */\n public indentation() {\n return lib.indentation(this.text);\n }\n\n /**\n * Returns true if the string is empty or contains only whitespace\n */\n public isEmpty() {\n return lib.isEmpty(this.text);\n }\n\n /**\n * Converts the string to camel case\n */\n public camelCase() {\n return new Str(changeCase.camelCase(this.text));\n }\n\n /**\n * Converts the string to capital case\n */\n public capitalCase() {\n return new Str(changeCase.capitalCase(this.text));\n }\n\n /**\n * Converts the string to constant case\n */\n public constantCase() {\n return new Str(changeCase.constantCase(this.text));\n }\n\n /**\n * Converts the string to dot case\n */\n public dotCase() {\n return new Str(changeCase.dotCase(this.text));\n }\n\n /**\n * Converts the string to kebab case\n */\n public kebabCase() {\n return new Str(changeCase.kebabCase(this.text));\n }\n\n /**\n * Converts the string to no case\n */\n public noCase() {\n return new Str(changeCase.noCase(this.text));\n }\n\n /**\n * Converts the string to pascal case\n */\n public pascalCase() {\n return new Str(changeCase.pascalCase(this.text));\n }\n\n /**\n * Converts the string to pascal snake case\n */\n public pascalSnakeCase() {\n return new Str(changeCase.pascalSnakeCase(this.text));\n }\n\n /**\n * Converts the string to path case\n */\n public pathCase() {\n return new Str(changeCase.pathCase(this.text));\n }\n\n /**\n * Converts the string to sentence case\n */\n public sentenceCase() {\n return new Str(changeCase.sentenceCase(this.text));\n }\n\n /**\n * Converts the string to snake case\n */\n public snakeCase() {\n return new Str(changeCase.snakeCase(this.text));\n }\n\n /**\n * Converts the string to train case\n */\n public trainCase() {\n return new Str(changeCase.trainCase(this.text));\n }\n\n /**\n * Shorthand for `.toString()`\n */\n public get str() {\n return this.toString();\n }\n}\n\nexport const str = (text: Stringable) => {\n return new Str(text.toString());\n};\n","/**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\nexport const chopEmptyLinesStart = (text: string) => {\n return text.replace(/^(\\s*\\n)+/, \"\");\n};\n\n/**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\nexport const chopEmptyLinesEnd = (text: string) => {\n return text.replace(/(\\n\\s*)+$/, \"\");\n};\n\n/**\n * Remove all space (\\s) characters in lines without content\n */\nexport const trimEmptyLines = (text: string) => {\n return text.replace(/(^|\\n)\\s+(\\n|$)/g, \"$1$2\");\n};\n\n/**\n * Remove all space (\\s) characters at the end of lines\n */\nexport const trimLinesTrailingSpaces = (text: string) => {\n return text.replace(/ +(\\n|$)/g, \"$1\");\n};\n\n/**\n * Removes the leading and trailing white space and line terminator characters\n */\nexport const trim = (text: string) => {\n return text.trim();\n};\n\n/**\n * Removes the leading white space and line terminator characters\n */\nexport const trimStart = (text: string) => {\n return text.trimStart();\n};\n\n/**\n * Removes the trailing white space and line terminator characters\n */\nexport const trimEnd = (text: string) => {\n return text.trimEnd();\n};\n\n/**\n * Split a string into substrings using the specified separator and return them as an array\n */\nexport const split = (\n text: string,\n separator: string | RegExp,\n limit?: number,\n) => {\n return text.split(separator, limit);\n};\n\n/**\n * Add line numbers to a string\n * @param text The string to add line numbers to\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\nexport const addLineNumbers = (text: string, separator: string = \":\") => {\n return text\n .split(\"\\n\")\n .map((line, index) => `${index}${separator}${line}`)\n .join(\"\\n\");\n};\n\n/**\n * Returns the indentation level of the string skipping empty lines in the process\n */\nexport const indentation = (text: string) => {\n return (\n text.split(\"\\n\").reduce((acc: number | null, line) => {\n if (line.trim() === \"\") return acc;\n const indentation = leadingSpacesCount(line);\n if (acc === null) return indentation;\n return Math.min(acc, indentation);\n }, null) ?? 0\n );\n};\n\n/**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\nexport const indent = (text: string, size: number, char: string = \" \") => {\n if (size === 0) return text;\n\n const indentStr = char.repeat(size);\n return text\n .split(\"\\n\")\n .map((line) => indentStr + line)\n .join(\"\\n\");\n};\n\n/**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\nexport const dedent = (text: string, size?: number) => {\n const _size = size ?? indentation(text);\n if (_size === 0) return text;\n const regex = new RegExp(`^\\\\s{1,${_size}}`);\n return text\n .split(\"\\n\")\n .map((line) => line.replace(regex, \"\"))\n .join(\"\\n\");\n};\n\n/**\n * Chop the string at the end by the specified number of characters\n */\nexport const chopEnd = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(0, -count);\n};\n\n/**\n * Chop the string at the start by the specified number of characters\n */\nexport const chopStart = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(count);\n};\n\n/**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\nexport const chopRepeatNewlines = (text: string, maxRepeat: number) => {\n if (maxRepeat === 0) return text;\n return text.replace(\n new RegExp(`\\n{${maxRepeat + 1},}`, \"g\"),\n \"\\n\".repeat(maxRepeat),\n );\n};\n\n/**\n * Take the first n characters of the string\n */\nexport const takeStart = (text: string, count: number) => {\n return text.slice(0, count);\n};\n\n/**\n * Take the last n characters of the string\n */\nexport const takeEnd = (text: string, count: number) => {\n return text.slice(-count);\n};\n\n/**\n * Returns the last line of the string\n */\nexport const lastLine = (text: string) => {\n return text.split(\"\\n\").at(-1) ?? \"\";\n};\n\n/**\n * Returns the first line of the string\n */\nexport const firstLine = (text: string) => {\n return text.split(\"\\n\").at(0) ?? \"\";\n};\n\n/**\n * Returns the number of leading spaces in the string\n */\nexport const leadingSpacesCount = (text: string) => {\n return text.match(/^\\s+/)?.at(0)?.length ?? 0;\n};\n\n/**\n * Returns true if the string is empty or contains only whitespace\n */\nexport const isEmpty = (text: string) => {\n return text.trim() === \"\";\n};\n"],"mappings":";AAAA;AA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AAI,KAAe,2BAAgB,KAAK,IAAI,CAAC;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,WAAO,IAAI,KAAe,oBAAS,KAAK,IAAI,CAAC;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKO,eAAe;AACpB,WAAO,IAAI,KAAe,wBAAa,KAAK,IAAI,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,MAAM;AACf,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAEO,IAAM,MAAM,CAAC,SAAqB;AACvC,SAAO,IAAI,IAAI,KAAK,SAAS,CAAC;AAChC;","names":["camelCase","capitalCase","constantCase","dotCase","kebabCase","noCase","pascalCase","pascalSnakeCase","pathCase","sentenceCase","snakeCase","trainCase","indentation","indentation"]}
1
+ {"version":3,"sources":["../src/str.bundle.ts","../src/str.chainable.ts","../src/str.lib.ts"],"sourcesContent":["export {\n camelCase,\n capitalCase,\n constantCase,\n dotCase,\n kebabCase,\n noCase,\n pascalCase,\n pascalSnakeCase,\n pathCase,\n sentenceCase,\n snakeCase,\n trainCase,\n} from \"change-case\";\nexport { str } from \"./str.chainable\";\nexport * from \"./str.lib\";\n","import { Stringable } from \"@shared/ts.utils\";\nimport { Pipeable } from \"@synstack/pipe\";\nimport * as changeCase from \"change-case\";\nimport * as lib from \"./str.lib\";\n\nexport class Str extends Pipeable<Str, string> {\n public constructor(private readonly text: string) {\n super();\n }\n\n public valueOf(): string {\n return this.text;\n }\n\n public toString() {\n return this.text;\n }\n\n public instanceOf(): Str {\n return this;\n }\n\n /**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\n public chopEmptyLinesStart() {\n return new Str(lib.chopEmptyLinesStart(this.text));\n }\n\n /**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\n public chopEmptyLinesEnd() {\n return new Str(lib.chopEmptyLinesEnd(this.text));\n }\n\n /**\n * Remove all space (\\s) characters in lines without content\n */\n public trimEmptyLines() {\n return new Str(lib.trimEmptyLines(this.text));\n }\n\n /**\n * Remove all spaces (\\s) characters at the end of lines\n */\n public trimLinesTrailingSpaces() {\n return new Str(lib.trimLinesTrailingSpaces(this.text));\n }\n\n /**\n * Removes the leading and trailing white space and line terminator characters\n */\n public trim() {\n return new Str(lib.trim(this.text));\n }\n\n /**\n * Removes the leading white space and line terminator characters\n */\n public trimStart() {\n return new Str(lib.trimStart(this.text));\n }\n\n /**\n * Removes the trailing white space and line terminator characters\n */\n public trimEnd() {\n return new Str(lib.trimEnd(this.text));\n }\n\n /**\n * Split a string into substrings using the specified separator and return them as an array\n */\n public split(separator: string | RegExp, limit?: number) {\n return lib.split(this.text, separator, limit).map((v) => new Str(v));\n }\n\n /**\n * Add line numbers to a string\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\n public addLineNumbers(separator: string = \":\") {\n return new Str(lib.addLineNumbers(this.text, separator));\n }\n\n /**\n * Returns the character at the specified index\n * @return string or undefined if the index is out of bounds\n */\n public at(index: number) {\n return this.text.at(index);\n }\n\n /**\n * Returns the length of the string\n */\n public length() {\n return this.text.length;\n }\n\n /**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\n public indent(size: number, char: string = \" \") {\n return new Str(lib.indent(this.text, size, char));\n }\n\n /**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\n public dedent(indentation?: number) {\n return new Str(lib.dedent(this.text, indentation));\n }\n\n /**\n * Chop the string at the start by the specified number of characters\n */\n public chopStart(count: number) {\n return new Str(lib.chopStart(this.text, count));\n }\n\n /**\n * Chop the string at the end by the specified number of characters\n */\n public chopEnd(count: number) {\n if (count === 0) return this;\n return new Str(lib.chopEnd(this.text, count));\n }\n\n /**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\n public chopRepeatNewlines(maxRepeat: number) {\n if (maxRepeat === 0) return this;\n return new Str(lib.chopRepeatNewlines(this.text, maxRepeat));\n }\n\n /**\n * Take the first n characters of the string\n */\n public takeStart(count: number) {\n return new Str(lib.takeStart(this.text, count));\n }\n\n /**\n * Take the last n characters of the string\n */\n public takeEnd(count: number) {\n return new Str(lib.takeEnd(this.text, count));\n }\n\n /**\n * Returns the last line of the string\n */\n public lastLine() {\n return new Str(lib.lastLine(this.text));\n }\n\n /**\n * Returns the first line of the string\n */\n public firstLine() {\n return new Str(lib.firstLine(this.text));\n }\n\n /**\n * Returns the number of leading spaces in the string\n */\n public leadingSpacesCount() {\n return lib.leadingSpacesCount(this.text);\n }\n\n /**\n * Returns the indentation level of the string skipping empty lines in the process\n */\n public indentation() {\n return lib.indentation(this.text);\n }\n\n /**\n * Returns true if the string is empty or contains only whitespace\n */\n public isEmpty() {\n return lib.isEmpty(this.text);\n }\n\n /**\n * Converts the string to camel case\n */\n public camelCase() {\n return new Str(changeCase.camelCase(this.text));\n }\n\n /**\n * Converts the string to capital case\n */\n public capitalCase() {\n return new Str(changeCase.capitalCase(this.text));\n }\n\n /**\n * Converts the string to constant case\n */\n public constantCase() {\n return new Str(changeCase.constantCase(this.text));\n }\n\n /**\n * Converts the string to dot case\n */\n public dotCase() {\n return new Str(changeCase.dotCase(this.text));\n }\n\n /**\n * Converts the string to kebab case\n */\n public kebabCase() {\n return new Str(changeCase.kebabCase(this.text));\n }\n\n /**\n * Converts the string to no case\n */\n public noCase() {\n return new Str(changeCase.noCase(this.text));\n }\n\n /**\n * Converts the string to pascal case\n */\n public pascalCase() {\n return new Str(changeCase.pascalCase(this.text));\n }\n\n /**\n * Converts the string to pascal snake case\n */\n public pascalSnakeCase() {\n return new Str(changeCase.pascalSnakeCase(this.text));\n }\n\n /**\n * Converts the string to path case\n */\n public pathCase() {\n return new Str(changeCase.pathCase(this.text));\n }\n\n /**\n * Converts the string to sentence case\n */\n public sentenceCase() {\n return new Str(changeCase.sentenceCase(this.text));\n }\n\n /**\n * Converts the string to snake case\n */\n public snakeCase() {\n return new Str(changeCase.snakeCase(this.text));\n }\n\n /**\n * Converts the string to train case\n */\n public trainCase() {\n return new Str(changeCase.trainCase(this.text));\n }\n\n /**\n * Shorthand for `.toString()`\n */\n public get str() {\n return this.toString();\n }\n}\n\nexport const str = (text: Stringable) => {\n return new Str(text.toString());\n};\n","/**\n * Remove empty lines at the start of the text but leave whitespace on the first line with content\n */\nexport const chopEmptyLinesStart = (text: string) => {\n return text.replace(/^(\\s*\\n)+/, \"\");\n};\n\n/**\n * Remove empty lines at the end of the text but leave whitespace on the last line with content\n */\nexport const chopEmptyLinesEnd = (text: string) => {\n return text.replace(/(\\n\\s*)+$/, \"\");\n};\n\n/**\n * Remove all space (\\s) characters in lines without content\n */\nexport const trimEmptyLines = (text: string) => {\n return text.replace(/(^|\\n)\\s+(\\n|$)/g, \"$1$2\");\n};\n\n/**\n * Remove all space (\\s) characters at the end of lines\n */\nexport const trimLinesTrailingSpaces = (text: string) => {\n return text.replace(/ +(\\n|$)/g, \"$1\");\n};\n\n/**\n * Removes the leading and trailing white space and line terminator characters\n */\nexport const trim = (text: string) => {\n return text.trim();\n};\n\n/**\n * Removes the leading white space and line terminator characters\n */\nexport const trimStart = (text: string) => {\n return text.trimStart();\n};\n\n/**\n * Removes the trailing white space and line terminator characters\n */\nexport const trimEnd = (text: string) => {\n return text.trimEnd();\n};\n\n/**\n * Split a string into substrings using the specified separator and return them as an array\n */\nexport const split = (\n text: string,\n separator: string | RegExp,\n limit?: number,\n) => {\n return text.split(separator, limit);\n};\n\n/**\n * Add line numbers to a string\n * @param text The string to add line numbers to\n * @param separator The separator to use between the line number and the line content.\n * Defaults to \":\"\n */\nexport const addLineNumbers = (text: string, separator: string = \":\") => {\n return text\n .split(\"\\n\")\n .map((line, index) => `${index}${separator}${line}`)\n .join(\"\\n\");\n};\n\n/**\n * Returns the indentation level of the string skipping empty lines in the process\n */\nexport const indentation = (text: string) => {\n return (\n text.split(\"\\n\").reduce((acc: number | null, line) => {\n if (line.trim() === \"\") return acc;\n const indentation = leadingSpacesCount(line);\n if (acc === null) return indentation;\n return Math.min(acc, indentation);\n }, null) ?? 0\n );\n};\n\n/**\n * Indent the string by the specified number of spaces\n * @param size The number of spaces to indent by\n * @param char The character to use for indentation. Defaults to \" \"\n */\nexport const indent = (text: string, size: number, char: string = \" \") => {\n if (size === 0) return text;\n\n const indentStr = char.repeat(size);\n return text\n .split(\"\\n\")\n .map((line) => indentStr + line)\n .join(\"\\n\");\n};\n\n/**\n * Dedent the string by the specified number of spaces\n * @param indentation The number of spaces to dedent by.\n * If not provided, it will be calculated automatically based on the maximum indentation in the string.\n */\nexport const dedent = (text: string, size?: number) => {\n const _size = size ?? indentation(text);\n if (_size === 0) return text;\n const regex = new RegExp(`^\\\\s{1,${_size}}`);\n return text\n .split(\"\\n\")\n .map((line) => line.replace(regex, \"\"))\n .join(\"\\n\");\n};\n\n/**\n * Chop the string at the end by the specified number of characters\n */\nexport const chopEnd = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(0, -count);\n};\n\n/**\n * Chop the string at the start by the specified number of characters\n */\nexport const chopStart = (text: string, count: number) => {\n if (count === 0) return text;\n return text.slice(count);\n};\n\n/**\n * Remove successive newlines of the specified repetition or more\n * @param maxRepeat the maximum number of newlines to allow\n */\nexport const chopRepeatNewlines = (text: string, maxRepeat: number) => {\n if (maxRepeat === 0) return text;\n return text.replace(\n new RegExp(`\\n{${maxRepeat + 1},}`, \"g\"),\n \"\\n\".repeat(maxRepeat),\n );\n};\n\n/**\n * Take the first n characters of the string\n */\nexport const takeStart = (text: string, count: number) => {\n return text.slice(0, count);\n};\n\n/**\n * Take the last n characters of the string\n */\nexport const takeEnd = (text: string, count: number) => {\n return text.slice(-count);\n};\n\n/**\n * Returns the last line of the string\n */\nexport const lastLine = (text: string) => {\n return text.split(\"\\n\").at(-1) ?? \"\";\n};\n\n/**\n * Returns the first line of the string\n */\nexport const firstLine = (text: string) => {\n return text.split(\"\\n\").at(0) ?? \"\";\n};\n\n/**\n * Returns the number of leading spaces in the string\n */\nexport const leadingSpacesCount = (text: string) => {\n return text.match(/^\\s+/)?.at(0)?.length ?? 0;\n};\n\n/**\n * Returns true if the string is empty or contains only whitespace\n */\nexport const isEmpty = (text: string) => {\n return text.trim() === \"\";\n};\n"],"mappings":";AAAA;AAAA,EACE,aAAAA;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,OACK;;;ACZP,SAAS,gBAAgB;AACzB,YAAY,gBAAgB;;;ACCrB,IAAM,sBAAsB,CAAC,SAAiB;AACnD,SAAO,KAAK,QAAQ,aAAa,EAAE;AACrC;AAKO,IAAM,oBAAoB,CAAC,SAAiB;AACjD,SAAO,KAAK,QAAQ,aAAa,EAAE;AACrC;AAKO,IAAM,iBAAiB,CAAC,SAAiB;AAC9C,SAAO,KAAK,QAAQ,oBAAoB,MAAM;AAChD;AAKO,IAAM,0BAA0B,CAAC,SAAiB;AACvD,SAAO,KAAK,QAAQ,aAAa,IAAI;AACvC;AAKO,IAAM,OAAO,CAAC,SAAiB;AACpC,SAAO,KAAK,KAAK;AACnB;AAKO,IAAM,YAAY,CAAC,SAAiB;AACzC,SAAO,KAAK,UAAU;AACxB;AAKO,IAAM,UAAU,CAAC,SAAiB;AACvC,SAAO,KAAK,QAAQ;AACtB;AAKO,IAAM,QAAQ,CACnB,MACA,WACA,UACG;AACH,SAA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UAAU;AACf,WAAO,IAAI,KAAe,mBAAQ,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKO,SAAS;AACd,WAAO,IAAI,KAAe,kBAAO,KAAK,IAAI,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA,EAKO,aAAa;AAClB,WAAO,IAAI,KAAe,sBAAW,KAAK,IAAI,CAAC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA,EAKO,kBAAkB;AACvB,WAAO,IAAI,KAAe,2BAAgB,KAAK,IAAI,CAAC;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKO,WAAW;AAChB,WAAO,IAAI,KAAe,oBAAS,KAAK,IAAI,CAAC;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKO,eAAe;AACpB,WAAO,IAAI,KAAe,wBAAa,KAAK,IAAI,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKO,YAAY;AACjB,WAAO,IAAI,KAAe,qBAAU,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,MAAM;AACf,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAEO,IAAM,MAAM,CAAC,SAAqB;AACvC,SAAO,IAAI,IAAI,KAAK,SAAS,CAAC;AAChC;","names":["camelCase","capitalCase","constantCase","dotCase","kebabCase","noCase","pascalCase","pascalSnakeCase","pathCase","sentenceCase","snakeCase","trainCase","indentation","indentation"]}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "access": "public"
6
6
  },
7
7
  "packageManager": "yarn@4.4.0",
8
- "version": "1.0.3",
8
+ "version": "1.0.5",
9
9
  "description": "Advanced chainable string manipulation",
10
10
  "keywords": [
11
11
  "string",
@@ -47,7 +47,7 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@synstack/pipe": "1.0.3",
50
+ "@synstack/pipe": "1.0.4",
51
51
  "change-case": "^5.4.4"
52
52
  },
53
53
  "devDependencies": {
@@ -61,5 +61,5 @@
61
61
  "!src/**/*.test.ts",
62
62
  "dist/**/*"
63
63
  ],
64
- "gitHead": "ed339f5b4ef3a70b7371313234250b1e7445ef69"
64
+ "gitHead": "56d10a76fc60a7b06a4e5d97700fb0d0e8049910"
65
65
  }
@@ -1,11 +1,8 @@
1
+ import { Stringable } from "@shared/ts.utils";
1
2
  import { Pipeable } from "@synstack/pipe";
2
3
  import * as changeCase from "change-case";
3
4
  import * as lib from "./str.lib";
4
5
 
5
- export type Stringable = {
6
- toString: () => string;
7
- };
8
-
9
6
  export class Str extends Pipeable<Str, string> {
10
7
  public constructor(private readonly text: string) {
11
8
  super();