Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -0,0 +1,19 @@
//#region src/compat/string/camelCase.d.ts
/**
* Converts a string to camel case.
*
* Camel case is the naming convention in which the first word is written in lowercase and
* each subsequent word begins with a capital letter, concatenated without any separator characters.
*
* @param str - The string that is to be changed to camel case.
* @returns The converted string to camel case.
*
* @example
* const convertedStr1 = camelCase('camelCase') // returns 'camelCase'
* const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'
* const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'
* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
*/
declare function camelCase(str?: string): string;
//#endregion
export { camelCase };

View file

@ -0,0 +1,19 @@
//#region src/compat/string/camelCase.d.ts
/**
* Converts a string to camel case.
*
* Camel case is the naming convention in which the first word is written in lowercase and
* each subsequent word begins with a capital letter, concatenated without any separator characters.
*
* @param str - The string that is to be changed to camel case.
* @returns The converted string to camel case.
*
* @example
* const convertedStr1 = camelCase('camelCase') // returns 'camelCase'
* const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'
* const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'
* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
*/
declare function camelCase(str?: string): string;
//#endregion
export { camelCase };

View file

@ -0,0 +1,24 @@
const require_camelCase = require("../../string/camelCase.js");
const require_deburr = require("./deburr.js");
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
//#region src/compat/string/camelCase.ts
/**
* Converts a string to camel case.
*
* Camel case is the naming convention in which the first word is written in lowercase and
* each subsequent word begins with a capital letter, concatenated without any separator characters.
*
* @param str - The string that is to be changed to camel case.
* @returns The converted string to camel case.
*
* @example
* const convertedStr1 = camelCase('camelCase') // returns 'camelCase'
* const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'
* const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'
* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
*/
function camelCase(str) {
return require_camelCase.camelCase(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)));
}
//#endregion
exports.camelCase = camelCase;

View file

@ -0,0 +1,24 @@
import { camelCase as camelCase$1 } from "../../string/camelCase.mjs";
import { deburr } from "./deburr.mjs";
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
//#region src/compat/string/camelCase.ts
/**
* Converts a string to camel case.
*
* Camel case is the naming convention in which the first word is written in lowercase and
* each subsequent word begins with a capital letter, concatenated without any separator characters.
*
* @param str - The string that is to be changed to camel case.
* @returns The converted string to camel case.
*
* @example
* const convertedStr1 = camelCase('camelCase') // returns 'camelCase'
* const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'
* const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'
* const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
*/
function camelCase(str) {
return camelCase$1(normalizeForCase(deburr(str)));
}
//#endregion
export { camelCase };

View file

@ -0,0 +1,15 @@
//#region src/compat/string/capitalize.d.ts
/**
* Converts the first character of string to upper case and the remaining to lower case.
*
* @param string - The string to capitalize.
* @returns The capitalized string.
*
* @example
* const convertedStr1 = capitalize('fred') // returns 'Fred'
* const convertedStr2 = capitalize('FRED') // returns 'Fred'
* const convertedStr3 = capitalize('') // returns ''
*/
declare function capitalize<T extends string>(str?: T): string extends T ? string : Capitalize<Lowercase<T>>;
//#endregion
export { capitalize };

View file

@ -0,0 +1,15 @@
//#region src/compat/string/capitalize.d.ts
/**
* Converts the first character of string to upper case and the remaining to lower case.
*
* @param string - The string to capitalize.
* @returns The capitalized string.
*
* @example
* const convertedStr1 = capitalize('fred') // returns 'Fred'
* const convertedStr2 = capitalize('FRED') // returns 'Fred'
* const convertedStr3 = capitalize('') // returns ''
*/
declare function capitalize<T extends string>(str?: T): string extends T ? string : Capitalize<Lowercase<T>>;
//#endregion
export { capitalize };

View file

@ -0,0 +1,19 @@
const require_capitalize = require("../../string/capitalize.js");
const require_toString = require("../util/toString.js");
//#region src/compat/string/capitalize.ts
/**
* Converts the first character of string to upper case and the remaining to lower case.
*
* @param string - The string to capitalize.
* @returns The capitalized string.
*
* @example
* const convertedStr1 = capitalize('fred') // returns 'Fred'
* const convertedStr2 = capitalize('FRED') // returns 'Fred'
* const convertedStr3 = capitalize('') // returns ''
*/
function capitalize(str) {
return require_capitalize.capitalize(require_toString.toString(str));
}
//#endregion
exports.capitalize = capitalize;

View file

@ -0,0 +1,19 @@
import { capitalize as capitalize$1 } from "../../string/capitalize.mjs";
import { toString } from "../util/toString.mjs";
//#region src/compat/string/capitalize.ts
/**
* Converts the first character of string to upper case and the remaining to lower case.
*
* @param string - The string to capitalize.
* @returns The capitalized string.
*
* @example
* const convertedStr1 = capitalize('fred') // returns 'Fred'
* const convertedStr2 = capitalize('FRED') // returns 'Fred'
* const convertedStr3 = capitalize('') // returns ''
*/
function capitalize(str) {
return capitalize$1(toString(str));
}
//#endregion
export { capitalize };

View file

@ -0,0 +1,23 @@
//#region src/compat/string/deburr.d.ts
/**
* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
* For example, "Crème brûlée" becomes "Creme brulee".
*
* @param str - The input string to be deburred.
* @returns The deburred string with special characters replaced by their ASCII equivalents.
*
* @example
* // Basic usage:
* deburr('Æthelred') // returns 'Aethelred'
*
* @example
* // Handling diacritical marks:
* deburr('München') // returns 'Munchen'
*
* @example
* // Special characters:
* deburr('Crème brûlée') // returns 'Creme brulee'
*/
declare function deburr(str?: string): string;
//#endregion
export { deburr };

View file

@ -0,0 +1,23 @@
//#region src/compat/string/deburr.d.ts
/**
* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
* For example, "Crème brûlée" becomes "Creme brulee".
*
* @param str - The input string to be deburred.
* @returns The deburred string with special characters replaced by their ASCII equivalents.
*
* @example
* // Basic usage:
* deburr('Æthelred') // returns 'Aethelred'
*
* @example
* // Handling diacritical marks:
* deburr('München') // returns 'Munchen'
*
* @example
* // Special characters:
* deburr('Crème brûlée') // returns 'Creme brulee'
*/
declare function deburr(str?: string): string;
//#endregion
export { deburr };

View file

@ -0,0 +1,27 @@
const require_deburr = require("../../string/deburr.js");
const require_toString = require("../util/toString.js");
//#region src/compat/string/deburr.ts
/**
* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
* For example, "Crème brûlée" becomes "Creme brulee".
*
* @param str - The input string to be deburred.
* @returns The deburred string with special characters replaced by their ASCII equivalents.
*
* @example
* // Basic usage:
* deburr('Æthelred') // returns 'Aethelred'
*
* @example
* // Handling diacritical marks:
* deburr('München') // returns 'Munchen'
*
* @example
* // Special characters:
* deburr('Crème brûlée') // returns 'Creme brulee'
*/
function deburr(str) {
return require_deburr.deburr(require_toString.toString(str));
}
//#endregion
exports.deburr = deburr;

View file

@ -0,0 +1,27 @@
import { deburr as deburr$1 } from "../../string/deburr.mjs";
import { toString } from "../util/toString.mjs";
//#region src/compat/string/deburr.ts
/**
* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
* For example, "Crème brûlée" becomes "Creme brulee".
*
* @param str - The input string to be deburred.
* @returns The deburred string with special characters replaced by their ASCII equivalents.
*
* @example
* // Basic usage:
* deburr('Æthelred') // returns 'Aethelred'
*
* @example
* // Handling diacritical marks:
* deburr('München') // returns 'Munchen'
*
* @example
* // Special characters:
* deburr('Crème brûlée') // returns 'Creme brulee'
*/
function deburr(str) {
return deburr$1(toString(str));
}
//#endregion
export { deburr };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/endsWith.d.ts
/**
* Checks if a string contains another string at the end of the string.
*
* Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional position from the start to search up to this index
* @returns True if the str string ends with the target string.
*
* @example
* const isPrefix = endsWith('fooBar', 'foo') // returns true
* const isPrefix = endsWith('fooBar', 'bar') // returns false
* const isPrefix = endsWith('fooBar', 'abc') // returns false
* const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
* const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
*/
declare function endsWith(str?: string, target?: string, position?: number): boolean;
//#endregion
export { endsWith };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/endsWith.d.ts
/**
* Checks if a string contains another string at the end of the string.
*
* Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional position from the start to search up to this index
* @returns True if the str string ends with the target string.
*
* @example
* const isPrefix = endsWith('fooBar', 'foo') // returns true
* const isPrefix = endsWith('fooBar', 'bar') // returns false
* const isPrefix = endsWith('fooBar', 'abc') // returns false
* const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
* const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
*/
declare function endsWith(str?: string, target?: string, position?: number): boolean;
//#endregion
export { endsWith };

View file

@ -0,0 +1,25 @@
//#region src/compat/string/endsWith.ts
/**
* Checks if a string contains another string at the end of the string.
*
* Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional position from the start to search up to this index
* @returns True if the str string ends with the target string.
*
* @example
* const isPrefix = endsWith('fooBar', 'foo') // returns true
* const isPrefix = endsWith('fooBar', 'bar') // returns false
* const isPrefix = endsWith('fooBar', 'abc') // returns false
* const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
* const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
*/
function endsWith(str, target, position) {
if (str == null || target == null) return false;
if (position == null) position = str.length;
return str.endsWith(target, position);
}
//#endregion
exports.endsWith = endsWith;

View file

@ -0,0 +1,25 @@
//#region src/compat/string/endsWith.ts
/**
* Checks if a string contains another string at the end of the string.
*
* Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional position from the start to search up to this index
* @returns True if the str string ends with the target string.
*
* @example
* const isPrefix = endsWith('fooBar', 'foo') // returns true
* const isPrefix = endsWith('fooBar', 'bar') // returns false
* const isPrefix = endsWith('fooBar', 'abc') // returns false
* const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
* const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
*/
function endsWith(str, target, position) {
if (str == null || target == null) return false;
if (position == null) position = str.length;
return str.endsWith(target, position);
}
//#endregion
export { endsWith };

View file

@ -0,0 +1,17 @@
//#region src/compat/string/escape.d.ts
/**
* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
* For example, "<" becomes "&lt;".
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* escape('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'
* escape('This is a "quote"'); // returns 'This is a &quot;quote&quot;'
* escape("This is a 'quote'"); // returns 'This is a &#39;quote&#39;'
* escape('This is a & symbol'); // returns 'This is a &amp; symbol'
*/
declare function escape(string?: string): string;
//#endregion
export { escape };

View file

@ -0,0 +1,17 @@
//#region src/compat/string/escape.d.ts
/**
* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
* For example, "<" becomes "&lt;".
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* escape('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'
* escape('This is a "quote"'); // returns 'This is a &quot;quote&quot;'
* escape("This is a 'quote'"); // returns 'This is a &#39;quote&#39;'
* escape('This is a & symbol'); // returns 'This is a &amp; symbol'
*/
declare function escape(string?: string): string;
//#endregion
export { escape };

View file

@ -0,0 +1,21 @@
const require_escape = require("../../string/escape.js");
const require_toString = require("../util/toString.js");
//#region src/compat/string/escape.ts
/**
* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
* For example, "<" becomes "&lt;".
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* escape('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'
* escape('This is a "quote"'); // returns 'This is a &quot;quote&quot;'
* escape("This is a 'quote'"); // returns 'This is a &#39;quote&#39;'
* escape('This is a & symbol'); // returns 'This is a &amp; symbol'
*/
function escape(string) {
return require_escape.escape(require_toString.toString(string));
}
//#endregion
exports.escape = escape;

View file

@ -0,0 +1,21 @@
import { escape as escape$1 } from "../../string/escape.mjs";
import { toString } from "../util/toString.mjs";
//#region src/compat/string/escape.ts
/**
* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
* For example, "<" becomes "&lt;".
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* escape('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'
* escape('This is a "quote"'); // returns 'This is a &quot;quote&quot;'
* escape("This is a 'quote'"); // returns 'This is a &#39;quote&#39;'
* escape('This is a & symbol'); // returns 'This is a &amp; symbol'
*/
function escape(string) {
return escape$1(toString(string));
}
//#endregion
export { escape };

View file

@ -0,0 +1,15 @@
//#region src/compat/string/escapeRegExp.d.ts
/**
* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* import { escapeRegExp } from 'es-toolkit/string';
*
* escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)'
*/
declare function escapeRegExp(str?: string): string;
//#endregion
export { escapeRegExp };

View file

@ -0,0 +1,15 @@
//#region src/compat/string/escapeRegExp.d.ts
/**
* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* import { escapeRegExp } from 'es-toolkit/string';
*
* escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)'
*/
declare function escapeRegExp(str?: string): string;
//#endregion
export { escapeRegExp };

View file

@ -0,0 +1,19 @@
const require_escapeRegExp = require("../../string/escapeRegExp.js");
const require_toString = require("../util/toString.js");
//#region src/compat/string/escapeRegExp.ts
/**
* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* import { escapeRegExp } from 'es-toolkit/string';
*
* escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)'
*/
function escapeRegExp(str) {
return require_escapeRegExp.escapeRegExp(require_toString.toString(str));
}
//#endregion
exports.escapeRegExp = escapeRegExp;

View file

@ -0,0 +1,19 @@
import { escapeRegExp as escapeRegExp$1 } from "../../string/escapeRegExp.mjs";
import { toString } from "../util/toString.mjs";
//#region src/compat/string/escapeRegExp.ts
/**
* Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
*
* @param str The string to escape.
* @returns Returns the escaped string.
*
* @example
* import { escapeRegExp } from 'es-toolkit/string';
*
* escapeRegExp('[es-toolkit](https://es-toolkit.dev/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.dev/\)'
*/
function escapeRegExp(str) {
return escapeRegExp$1(toString(str));
}
//#endregion
export { escapeRegExp };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/kebabCase.d.ts
/**
* Converts a string to kebab case.
*
* Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.
*
* @param str - The string that is to be changed to kebab case.
* @returns The converted string to kebab case.
*
* @example
* const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'
* const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'
* const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
*/
declare function kebabCase(str?: string): string;
//#endregion
export { kebabCase };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/kebabCase.d.ts
/**
* Converts a string to kebab case.
*
* Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.
*
* @param str - The string that is to be changed to kebab case.
* @returns The converted string to kebab case.
*
* @example
* const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'
* const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'
* const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
*/
declare function kebabCase(str?: string): string;
//#endregion
export { kebabCase };

View file

@ -0,0 +1,23 @@
const require_kebabCase = require("../../string/kebabCase.js");
const require_deburr = require("./deburr.js");
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
//#region src/compat/string/kebabCase.ts
/**
* Converts a string to kebab case.
*
* Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.
*
* @param str - The string that is to be changed to kebab case.
* @returns The converted string to kebab case.
*
* @example
* const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'
* const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'
* const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
*/
function kebabCase(str) {
return require_kebabCase.kebabCase(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)));
}
//#endregion
exports.kebabCase = kebabCase;

View file

@ -0,0 +1,23 @@
import { kebabCase as kebabCase$1 } from "../../string/kebabCase.mjs";
import { deburr } from "./deburr.mjs";
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
//#region src/compat/string/kebabCase.ts
/**
* Converts a string to kebab case.
*
* Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.
*
* @param str - The string that is to be changed to kebab case.
* @returns The converted string to kebab case.
*
* @example
* const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'
* const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'
* const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
*/
function kebabCase(str) {
return kebabCase$1(normalizeForCase(deburr(str)));
}
//#endregion
export { kebabCase };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/lowerCase.d.ts
/**
* Converts a string to lower case.
*
* Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.
*
* @param str - The string that is to be changed to lower case.
* @returns The converted string to lower case.
*
* @example
* const convertedStr1 = lowerCase('camelCase') // returns 'camel case'
* const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'
* const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
*/
declare function lowerCase(str?: string): string;
//#endregion
export { lowerCase };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/lowerCase.d.ts
/**
* Converts a string to lower case.
*
* Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.
*
* @param str - The string that is to be changed to lower case.
* @returns The converted string to lower case.
*
* @example
* const convertedStr1 = lowerCase('camelCase') // returns 'camel case'
* const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'
* const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
*/
declare function lowerCase(str?: string): string;
//#endregion
export { lowerCase };

View file

@ -0,0 +1,23 @@
const require_lowerCase = require("../../string/lowerCase.js");
const require_deburr = require("./deburr.js");
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
//#region src/compat/string/lowerCase.ts
/**
* Converts a string to lower case.
*
* Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.
*
* @param str - The string that is to be changed to lower case.
* @returns The converted string to lower case.
*
* @example
* const convertedStr1 = lowerCase('camelCase') // returns 'camel case'
* const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'
* const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
*/
function lowerCase(str) {
return require_lowerCase.lowerCase(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)));
}
//#endregion
exports.lowerCase = lowerCase;

View file

@ -0,0 +1,23 @@
import { lowerCase as lowerCase$1 } from "../../string/lowerCase.mjs";
import { deburr } from "./deburr.mjs";
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
//#region src/compat/string/lowerCase.ts
/**
* Converts a string to lower case.
*
* Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.
*
* @param str - The string that is to be changed to lower case.
* @returns The converted string to lower case.
*
* @example
* const convertedStr1 = lowerCase('camelCase') // returns 'camel case'
* const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'
* const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
*/
function lowerCase(str) {
return lowerCase$1(normalizeForCase(deburr(str)));
}
//#endregion
export { lowerCase };

View file

@ -0,0 +1,15 @@
//#region src/compat/string/lowerFirst.d.ts
/**
* Converts the first character of string to lower case.
*
* @param str - The string that is to be changed
* @returns The converted string.
*
* @example
* const convertedStr1 = lowerCase('fred') // returns 'fred'
* const convertedStr2 = lowerCase('Fred') // returns 'fred'
* const convertedStr3 = lowerCase('FRED') // returns 'fRED'
*/
declare function lowerFirst<T extends string = string>(str?: T): Uncapitalize<T>;
//#endregion
export { lowerFirst };

View file

@ -0,0 +1,15 @@
//#region src/compat/string/lowerFirst.d.ts
/**
* Converts the first character of string to lower case.
*
* @param str - The string that is to be changed
* @returns The converted string.
*
* @example
* const convertedStr1 = lowerCase('fred') // returns 'fred'
* const convertedStr2 = lowerCase('Fred') // returns 'fred'
* const convertedStr3 = lowerCase('FRED') // returns 'fRED'
*/
declare function lowerFirst<T extends string = string>(str?: T): Uncapitalize<T>;
//#endregion
export { lowerFirst };

View file

@ -0,0 +1,19 @@
const require_lowerFirst = require("../../string/lowerFirst.js");
const require_toString = require("../util/toString.js");
//#region src/compat/string/lowerFirst.ts
/**
* Converts the first character of string to lower case.
*
* @param str - The string that is to be changed
* @returns The converted string.
*
* @example
* const convertedStr1 = lowerCase('fred') // returns 'fred'
* const convertedStr2 = lowerCase('Fred') // returns 'fred'
* const convertedStr3 = lowerCase('FRED') // returns 'fRED'
*/
function lowerFirst(str) {
return require_lowerFirst.lowerFirst(require_toString.toString(str));
}
//#endregion
exports.lowerFirst = lowerFirst;

View file

@ -0,0 +1,19 @@
import { lowerFirst as lowerFirst$1 } from "../../string/lowerFirst.mjs";
import { toString } from "../util/toString.mjs";
//#region src/compat/string/lowerFirst.ts
/**
* Converts the first character of string to lower case.
*
* @param str - The string that is to be changed
* @returns The converted string.
*
* @example
* const convertedStr1 = lowerCase('fred') // returns 'fred'
* const convertedStr2 = lowerCase('Fred') // returns 'fred'
* const convertedStr3 = lowerCase('FRED') // returns 'fRED'
*/
function lowerFirst(str) {
return lowerFirst$1(toString(str));
}
//#endregion
export { lowerFirst };

View file

@ -0,0 +1,20 @@
//#region src/compat/string/pad.d.ts
/**
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
* If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = pad('abc', 8); // result will be ' abc '
* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
* const result3 = pad('abc', 3); // result will be 'abc'
* const result4 = pad('abc', 2); // result will be 'abc'
*
*/
declare function pad(str?: string, length?: number, chars?: string): string;
//#endregion
export { pad };

View file

@ -0,0 +1,20 @@
//#region src/compat/string/pad.d.ts
/**
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
* If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = pad('abc', 8); // result will be ' abc '
* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
* const result3 = pad('abc', 3); // result will be 'abc'
* const result4 = pad('abc', 2); // result will be 'abc'
*
*/
declare function pad(str?: string, length?: number, chars?: string): string;
//#endregion
export { pad };

View file

@ -0,0 +1,24 @@
const require_pad = require("../../string/pad.js");
const require_toString = require("../util/toString.js");
//#region src/compat/string/pad.ts
/**
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
* If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = pad('abc', 8); // result will be ' abc '
* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
* const result3 = pad('abc', 3); // result will be 'abc'
* const result4 = pad('abc', 2); // result will be 'abc'
*
*/
function pad(str, length, chars) {
return require_pad.pad(require_toString.toString(str), length, chars);
}
//#endregion
exports.pad = pad;

View file

@ -0,0 +1,24 @@
import { pad as pad$1 } from "../../string/pad.mjs";
import { toString } from "../util/toString.mjs";
//#region src/compat/string/pad.ts
/**
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
* If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = pad('abc', 8); // result will be ' abc '
* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
* const result3 = pad('abc', 3); // result will be 'abc'
* const result4 = pad('abc', 2); // result will be 'abc'
*
*/
function pad(str, length, chars) {
return pad$1(toString(str), length, chars);
}
//#endregion
export { pad };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/padEnd.d.ts
/**
* Pads the end of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padEnd('abc', 6); // result will be 'abc '
* const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_'
* const result3 = padEnd('abc', 3); // result will be 'abc'
* const result4 = padEnd('abc', 2); // result will be 'abc'
*/
declare function padEnd(str?: string, length?: number, chars?: string): string;
//#endregion
export { padEnd };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/padEnd.d.ts
/**
* Pads the end of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padEnd('abc', 6); // result will be 'abc '
* const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_'
* const result3 = padEnd('abc', 3); // result will be 'abc'
* const result4 = padEnd('abc', 2); // result will be 'abc'
*/
declare function padEnd(str?: string, length?: number, chars?: string): string;
//#endregion
export { padEnd };

View file

@ -0,0 +1,24 @@
const require_toString = require("../util/toString.js");
//#region src/compat/string/padEnd.ts
/**
* Pads the end of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padEnd('abc', 6); // result will be 'abc '
* const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_'
* const result3 = padEnd('abc', 3); // result will be 'abc'
* const result4 = padEnd('abc', 2); // result will be 'abc'
*/
function padEnd(str, length = 0, chars = " ") {
return require_toString.toString(str).padEnd(length, chars);
}
//#endregion
exports.padEnd = padEnd;

View file

@ -0,0 +1,24 @@
import { toString } from "../util/toString.mjs";
//#region src/compat/string/padEnd.ts
/**
* Pads the end of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padEnd('abc', 6); // result will be 'abc '
* const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_'
* const result3 = padEnd('abc', 3); // result will be 'abc'
* const result4 = padEnd('abc', 2); // result will be 'abc'
*/
function padEnd(str, length = 0, chars = " ") {
return toString(str).padEnd(length, chars);
}
//#endregion
export { padEnd };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/padStart.d.ts
/**
* Pads the start of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padStart('abc', 6); // result will be ' abc'
* const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
* const result3 = padStart('abc', 3); // result will be 'abc'
* const result4 = padStart('abc', 2); // result will be 'abc'
*/
declare function padStart(str?: string, length?: number, chars?: string): string;
//#endregion
export { padStart };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/padStart.d.ts
/**
* Pads the start of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padStart('abc', 6); // result will be ' abc'
* const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
* const result3 = padStart('abc', 3); // result will be 'abc'
* const result4 = padStart('abc', 2); // result will be 'abc'
*/
declare function padStart(str?: string, length?: number, chars?: string): string;
//#endregion
export { padStart };

View file

@ -0,0 +1,24 @@
const require_toString = require("../util/toString.js");
//#region src/compat/string/padStart.ts
/**
* Pads the start of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padStart('abc', 6); // result will be ' abc'
* const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
* const result3 = padStart('abc', 3); // result will be 'abc'
* const result4 = padStart('abc', 2); // result will be 'abc'
*/
function padStart(str, length = 0, chars = " ") {
return require_toString.toString(str).padStart(length, chars);
}
//#endregion
exports.padStart = padStart;

View file

@ -0,0 +1,24 @@
import { toString } from "../util/toString.mjs";
//#region src/compat/string/padStart.ts
/**
* Pads the start of a string with a given character until it reaches the specified length.
*
* If the length is less than or equal to the original string's length, or if the padding character is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to pad.
* @param [length] - The length of the resulting string once padded.
* @param [chars] - The character(s) to use for padding.
* @returns The padded string, or the original string if padding is not required.
*
* @example
* const result1 = padStart('abc', 6); // result will be ' abc'
* const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
* const result3 = padStart('abc', 3); // result will be 'abc'
* const result4 = padStart('abc', 2); // result will be 'abc'
*/
function padStart(str, length = 0, chars = " ") {
return toString(str).padStart(length, chars);
}
//#endregion
export { padStart };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/repeat.d.ts
/**
* Repeats the given string n times.
*
* If n is less than 1, an empty string is returned, or if the string is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to repeat.
* @param n - The number of times to repeat the string.
* @returns The repeated string, or an empty string if n is less than 1.
*
* @example
* repeat('abc', 0); // ''
* repeat('abc', 2); // 'abcabc'
*/
declare function repeat(str?: string, n?: number): string;
//#endregion
export { repeat };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/repeat.d.ts
/**
* Repeats the given string n times.
*
* If n is less than 1, an empty string is returned, or if the string is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to repeat.
* @param n - The number of times to repeat the string.
* @returns The repeated string, or an empty string if n is less than 1.
*
* @example
* repeat('abc', 0); // ''
* repeat('abc', 2); // 'abcabc'
*/
declare function repeat(str?: string, n?: number): string;
//#endregion
export { repeat };

View file

@ -0,0 +1,27 @@
const require_toString = require("../util/toString.js");
const require_toInteger = require("../util/toInteger.js");
const require_isIterateeCall = require("../_internal/isIterateeCall.js");
const require_MAX_SAFE_INTEGER = require("../_internal/MAX_SAFE_INTEGER.js");
//#region src/compat/string/repeat.ts
/**
* Repeats the given string n times.
*
* If n is less than 1, an empty string is returned, or if the string is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to repeat.
* @param n - The number of times to repeat the string.
* @returns The repeated string, or an empty string if n is less than 1.
*
* @example
* repeat('abc', 0); // ''
* repeat('abc', 2); // 'abcabc'
*/
function repeat(str, n, guard) {
if (guard ? require_isIterateeCall.isIterateeCall(str, n, guard) : n === void 0) n = 1;
else n = require_toInteger.toInteger(n);
if (n < 1 || n > require_MAX_SAFE_INTEGER.MAX_SAFE_INTEGER) return "";
return require_toString.toString(str).repeat(n);
}
//#endregion
exports.repeat = repeat;

View file

@ -0,0 +1,27 @@
import { toString } from "../util/toString.mjs";
import { toInteger } from "../util/toInteger.mjs";
import { isIterateeCall } from "../_internal/isIterateeCall.mjs";
import { MAX_SAFE_INTEGER } from "../_internal/MAX_SAFE_INTEGER.mjs";
//#region src/compat/string/repeat.ts
/**
* Repeats the given string n times.
*
* If n is less than 1, an empty string is returned, or if the string is an empty string,
* the original string is returned unchanged.
*
* @param str - The string to repeat.
* @param n - The number of times to repeat the string.
* @returns The repeated string, or an empty string if n is less than 1.
*
* @example
* repeat('abc', 0); // ''
* repeat('abc', 2); // 'abcabc'
*/
function repeat(str, n, guard) {
if (guard ? isIterateeCall(str, n, guard) : n === void 0) n = 1;
else n = toInteger(n);
if (n < 1 || n > MAX_SAFE_INTEGER) return "";
return toString(str).repeat(n);
}
//#endregion
export { repeat };

View file

@ -0,0 +1,6 @@
//#region src/compat/string/replace.d.ts
type ReplaceFunction = (match: string, ...args: any[]) => string;
declare function replace(string: string, pattern: RegExp | string, replacement: ReplaceFunction | string): string;
declare function replace(pattern: RegExp | string, replacement: ReplaceFunction | string): string;
//#endregion
export { replace };

View file

@ -0,0 +1,6 @@
//#region src/compat/string/replace.d.ts
type ReplaceFunction = (match: string, ...args: any[]) => string;
declare function replace(string: string, pattern: RegExp | string, replacement: ReplaceFunction | string): string;
declare function replace(pattern: RegExp | string, replacement: ReplaceFunction | string): string;
//#endregion
export { replace };

View file

@ -0,0 +1,22 @@
const require_toString = require("../util/toString.js");
//#region src/compat/string/replace.ts
/**
* Replaces the matched pattern with the replacement string.
*
* @param {} target - The target string.
* @param {} pattern - The pattern to match.
* @param {} replacement - The replacement string or a function that returns the replacement string.
* @returns The new string with the matched pattern replaced.
*
* @example
* replace('abcde', 'de', '123'); // 'abc123'
* replace('abcde', /[bd]/g, '-'); // 'a-c-e'
* replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE'
* replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe'
*/
function replace(target, pattern, replacement) {
if (arguments.length < 3) return require_toString.toString(target);
return require_toString.toString(target).replace(pattern, replacement);
}
//#endregion
exports.replace = replace;

View file

@ -0,0 +1,22 @@
import { toString } from "../util/toString.mjs";
//#region src/compat/string/replace.ts
/**
* Replaces the matched pattern with the replacement string.
*
* @param {} target - The target string.
* @param {} pattern - The pattern to match.
* @param {} replacement - The replacement string or a function that returns the replacement string.
* @returns The new string with the matched pattern replaced.
*
* @example
* replace('abcde', 'de', '123'); // 'abc123'
* replace('abcde', /[bd]/g, '-'); // 'a-c-e'
* replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE'
* replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe'
*/
function replace(target, pattern, replacement) {
if (arguments.length < 3) return toString(target);
return toString(target).replace(pattern, replacement);
}
//#endregion
export { replace };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/snakeCase.d.ts
/**
* Converts a string to snake case.
*
* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
*
* @param str - The string that is to be changed to snake case.
* @returns The converted string to snake case.
*
* @example
* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
*/
declare function snakeCase(str?: string): string;
//#endregion
export { snakeCase };

View file

@ -0,0 +1,18 @@
//#region src/compat/string/snakeCase.d.ts
/**
* Converts a string to snake case.
*
* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
*
* @param str - The string that is to be changed to snake case.
* @returns The converted string to snake case.
*
* @example
* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
*/
declare function snakeCase(str?: string): string;
//#endregion
export { snakeCase };

View file

@ -0,0 +1,23 @@
const require_snakeCase = require("../../string/snakeCase.js");
const require_deburr = require("./deburr.js");
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
//#region src/compat/string/snakeCase.ts
/**
* Converts a string to snake case.
*
* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
*
* @param str - The string that is to be changed to snake case.
* @returns The converted string to snake case.
*
* @example
* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
*/
function snakeCase(str) {
return require_snakeCase.snakeCase(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)));
}
//#endregion
exports.snakeCase = snakeCase;

View file

@ -0,0 +1,23 @@
import { snakeCase as snakeCase$1 } from "../../string/snakeCase.mjs";
import { deburr } from "./deburr.mjs";
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
//#region src/compat/string/snakeCase.ts
/**
* Converts a string to snake case.
*
* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
*
* @param str - The string that is to be changed to snake case.
* @returns The converted string to snake case.
*
* @example
* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
*/
function snakeCase(str) {
return snakeCase$1(normalizeForCase(deburr(str)));
}
//#endregion
export { snakeCase };

View file

@ -0,0 +1,37 @@
//#region src/compat/string/split.d.ts
/**
* Splits the input string by the specified `separator`
* and returns a new array containing the split segments.
*
* @param [string=''] The string to split.
* @param [separator] The separator pattern to split by.
* @param [limit] The length to truncate results to.
* @returns Returns the string segments.
*
* @example
* split('a-b-c', '-');
* // => ['a', 'b', 'c']
*
* split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
declare function split(string: string | null | undefined, separator?: RegExp | string, limit?: number): string[];
/**
* Splits the input string by the specified `separator`
* and returns a new array containing the split segments.
*
* @param [string=''] The string to split.
* @param [separator] The separator pattern to split by.
* @param [limit] The length to truncate results to.
* @returns Returns the string segments.
*
* @example
* split('a-b-c', '-');
* // => ['a', 'b', 'c']
*
* split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
declare function split(string: string | null | undefined, index: string | number, guard: object): string[];
//#endregion
export { split };

View file

@ -0,0 +1,37 @@
//#region src/compat/string/split.d.ts
/**
* Splits the input string by the specified `separator`
* and returns a new array containing the split segments.
*
* @param [string=''] The string to split.
* @param [separator] The separator pattern to split by.
* @param [limit] The length to truncate results to.
* @returns Returns the string segments.
*
* @example
* split('a-b-c', '-');
* // => ['a', 'b', 'c']
*
* split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
declare function split(string: string | null | undefined, separator?: RegExp | string, limit?: number): string[];
/**
* Splits the input string by the specified `separator`
* and returns a new array containing the split segments.
*
* @param [string=''] The string to split.
* @param [separator] The separator pattern to split by.
* @param [limit] The length to truncate results to.
* @returns Returns the string segments.
*
* @example
* split('a-b-c', '-');
* // => ['a', 'b', 'c']
*
* split('a-b-c', '-', 2);
* // => ['a', 'b']
*/
declare function split(string: string | null | undefined, index: string | number, guard: object): string[];
//#endregion
export { split };

View file

@ -0,0 +1,7 @@
const require_toString = require("../util/toString.js");
//#region src/compat/string/split.ts
function split(string, separator, limit) {
return require_toString.toString(string).split(separator, limit);
}
//#endregion
exports.split = split;

View file

@ -0,0 +1,7 @@
import { toString } from "../util/toString.mjs";
//#region src/compat/string/split.ts
function split(string, separator, limit) {
return toString(string).split(separator, limit);
}
//#endregion
export { split };

View file

@ -0,0 +1,17 @@
//#region src/compat/string/startCase.d.ts
/**
* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
*
* Start case is the naming convention in which each word is written with an initial capital letter.
* @param str - The string to convert.
* @returns The converted string.
*
* @example
* const result1 = startCase('hello world'); // result will be 'Hello World'
* const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'
* const result3 = startCase('hello-world'); // result will be 'Hello World'
* const result4 = startCase('hello_world'); // result will be 'Hello World'
*/
declare function startCase(str?: string): string;
//#endregion
export { startCase };

View file

@ -0,0 +1,17 @@
//#region src/compat/string/startCase.d.ts
/**
* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
*
* Start case is the naming convention in which each word is written with an initial capital letter.
* @param str - The string to convert.
* @returns The converted string.
*
* @example
* const result1 = startCase('hello world'); // result will be 'Hello World'
* const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'
* const result3 = startCase('hello-world'); // result will be 'Hello World'
* const result4 = startCase('hello_world'); // result will be 'Hello World'
*/
declare function startCase(str?: string): string;
//#endregion
export { startCase };

View file

@ -0,0 +1,30 @@
const require_words = require("../../string/words.js");
const require_deburr = require("./deburr.js");
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
//#region src/compat/string/startCase.ts
/**
* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
*
* Start case is the naming convention in which each word is written with an initial capital letter.
* @param str - The string to convert.
* @returns The converted string.
*
* @example
* const result1 = startCase('hello world'); // result will be 'Hello World'
* const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'
* const result3 = startCase('hello-world'); // result will be 'Hello World'
* const result4 = startCase('hello_world'); // result will be 'Hello World'
*/
function startCase(str) {
const words$1 = require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str)).trim());
let result = "";
for (let i = 0; i < words$1.length; i++) {
const word = words$1[i];
if (result) result += " ";
if (word === word.toUpperCase()) result += word;
else result += word[0].toUpperCase() + word.slice(1).toLowerCase();
}
return result;
}
//#endregion
exports.startCase = startCase;

View file

@ -0,0 +1,30 @@
import { words } from "../../string/words.mjs";
import { deburr } from "./deburr.mjs";
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
//#region src/compat/string/startCase.ts
/**
* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
*
* Start case is the naming convention in which each word is written with an initial capital letter.
* @param str - The string to convert.
* @returns The converted string.
*
* @example
* const result1 = startCase('hello world'); // result will be 'Hello World'
* const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'
* const result3 = startCase('hello-world'); // result will be 'Hello World'
* const result4 = startCase('hello_world'); // result will be 'Hello World'
*/
function startCase(str) {
const words$1 = words(normalizeForCase(deburr(str)).trim());
let result = "";
for (let i = 0; i < words$1.length; i++) {
const word = words$1[i];
if (result) result += " ";
if (word === word.toUpperCase()) result += word;
else result += word[0].toUpperCase() + word.slice(1).toLowerCase();
}
return result;
}
//#endregion
export { startCase };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/startsWith.d.ts
/**
* Checks if a string contains another string at the beginning of the string.
*
* Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional offset to start searching in the str string
* @returns True if the str string starts with the target string.
*
* @example
* const isPrefix = startsWith('fooBar', 'foo') // returns true
* const isPrefix = startsWith('fooBar', 'bar') // returns false
* const isPrefix = startsWith('fooBar', 'abc') // returns false
* const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
* const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
*/
declare function startsWith(str?: string, target?: string, position?: number): boolean;
//#endregion
export { startsWith };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/startsWith.d.ts
/**
* Checks if a string contains another string at the beginning of the string.
*
* Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional offset to start searching in the str string
* @returns True if the str string starts with the target string.
*
* @example
* const isPrefix = startsWith('fooBar', 'foo') // returns true
* const isPrefix = startsWith('fooBar', 'bar') // returns false
* const isPrefix = startsWith('fooBar', 'abc') // returns false
* const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
* const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
*/
declare function startsWith(str?: string, target?: string, position?: number): boolean;
//#endregion
export { startsWith };

View file

@ -0,0 +1,25 @@
//#region src/compat/string/startsWith.ts
/**
* Checks if a string contains another string at the beginning of the string.
*
* Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional offset to start searching in the str string
* @returns True if the str string starts with the target string.
*
* @example
* const isPrefix = startsWith('fooBar', 'foo') // returns true
* const isPrefix = startsWith('fooBar', 'bar') // returns false
* const isPrefix = startsWith('fooBar', 'abc') // returns false
* const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
* const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
*/
function startsWith(str, target, position) {
if (str == null || target == null) return false;
if (position == null) position = 0;
return str.startsWith(target, position);
}
//#endregion
exports.startsWith = startsWith;

View file

@ -0,0 +1,25 @@
//#region src/compat/string/startsWith.ts
/**
* Checks if a string contains another string at the beginning of the string.
*
* Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
*
* @param str - The string that might contain the target string.
* @param target - The string to search for.
* @param position - An optional offset to start searching in the str string
* @returns True if the str string starts with the target string.
*
* @example
* const isPrefix = startsWith('fooBar', 'foo') // returns true
* const isPrefix = startsWith('fooBar', 'bar') // returns false
* const isPrefix = startsWith('fooBar', 'abc') // returns false
* const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
* const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
*/
function startsWith(str, target, position) {
if (str == null || target == null) return false;
if (position == null) position = 0;
return str.startsWith(target, position);
}
//#endregion
export { startsWith };

View file

@ -0,0 +1,30 @@
import { escape } from "./escape.mjs";
//#region src/compat/string/template.d.ts
declare const templateSettings: {
escape: RegExp;
evaluate: RegExp;
interpolate: RegExp;
variable: string;
imports: {
_: {
escape: typeof escape;
template: typeof template;
};
};
};
interface TemplateOptions {
escape?: RegExp | null | undefined;
evaluate?: RegExp | null | undefined;
interpolate?: RegExp | null | undefined;
variable?: string | undefined;
imports?: Record<string, any> | undefined;
sourceURL?: string;
}
interface TemplateExecutor {
(data?: object): string;
source: string;
}
declare function template(string?: string, options?: TemplateOptions): TemplateExecutor;
//#endregion
export { template, templateSettings };

View file

@ -0,0 +1,30 @@
import { escape } from "./escape.js";
//#region src/compat/string/template.d.ts
declare const templateSettings: {
escape: RegExp;
evaluate: RegExp;
interpolate: RegExp;
variable: string;
imports: {
_: {
escape: typeof escape;
template: typeof template;
};
};
};
interface TemplateOptions {
escape?: RegExp | null | undefined;
evaluate?: RegExp | null | undefined;
interpolate?: RegExp | null | undefined;
variable?: string | undefined;
imports?: Record<string, any> | undefined;
sourceURL?: string;
}
interface TemplateExecutor {
(data?: object): string;
source: string;
}
declare function template(string?: string, options?: TemplateOptions): TemplateExecutor;
//#endregion
export { template, templateSettings };

View file

@ -0,0 +1,138 @@
const require_toString = require("../util/toString.js");
const require_attempt = require("../function/attempt.js");
const require_defaults = require("../object/defaults.js");
const require_escape = require("./escape.js");
//#region src/compat/string/template.ts
const esTemplateRegExp = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
const unEscapedRegExp = /['\n\r\u2028\u2029\\]/g;
const noMatchExp = /($^)/;
const escapeMap = new Map([
["\\", "\\"],
["'", "'"],
["\n", "n"],
["\r", "r"],
["\u2028", "u2028"],
["\u2029", "u2029"]
]);
function escapeString(match) {
return `\\${escapeMap.get(match)}`;
}
const defaultInterpolateRegExp = /<%=([\s\S]+?)%>/g;
const templateSettings = {
escape: /<%-([\s\S]+?)%>/g,
evaluate: /<%([\s\S]+?)%>/g,
interpolate: defaultInterpolateRegExp,
variable: "",
imports: { _: {
escape: require_escape.escape,
template
} }
};
/**
* Compiles a template string into a function that can interpolate data properties.
*
* This function allows you to create a template with custom delimiters for escaping,
* evaluating, and interpolating values. It can also handle custom variable names and
* imported functions.
*
* @param string - The template string.
* @param [options] - The options object.
* @param [options.escape] - The regular expression for "escape" delimiter.
* @param [options.evaluate] - The regular expression for "evaluate" delimiter.
* @param [options.interpolate] - The regular expression for "interpolate" delimiter.
* @param [options.variable] - The data object variable name.
* @param [options.imports] - The object of imported functions.
* @param [options.sourceURL] - The source URL of the template.
* @param [guard] - The guard to detect if the function is called with `options`.
* @returns Returns the compiled template function.
*
* @example
* // Use the "escape" delimiter to escape data properties.
* const compiled = template('<%- value %>');
* compiled({ value: '<div>' }); // returns '&lt;div&gt;'
*
* @example
* // Use the "interpolate" delimiter to interpolate data properties.
* const compiled = template('<%= value %>');
* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'
*
* @example
* // Use the "evaluate" delimiter to evaluate JavaScript code.
* const compiled = template('<% if (value) { %>Yes<% } else { %>No<% } %>');
* compiled({ value: true }); // returns 'Yes'
*
* @example
* // Use the "variable" option to specify the data object variable name.
* const compiled = template('<%= data.value %>', { variable: 'data' });
* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'
*
* @example
* // Use the "imports" option to import functions.
* const compiled = template('<%= _.toUpper(value) %>', { imports: { _: { toUpper } } });
* compiled({ value: 'hello, world!' }); // returns 'HELLO, WORLD!'
*
* @example
* // Use the custom "escape" delimiter.
* const compiled = template('<@ value @>', { escape: /<@([\s\S]+?)@>/g });
* compiled({ value: '<div>' }); // returns '&lt;div&gt;'
*
* @example
* // Use the custom "evaluate" delimiter.
* const compiled = template('<# if (value) { #>Yes<# } else { #>No<# } #>', { evaluate: /<#([\s\S]+?)#>/g });
* compiled({ value: true }); // returns 'Yes'
*
* @example
* // Use the custom "interpolate" delimiter.
* const compiled = template('<$ value $>', { interpolate: /<\$([\s\S]+?)\$>/g });
* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'
*
* @example
* // Use the "sourceURL" option to specify the source URL of the template.
* const compiled = template('hello <%= user %>!', { sourceURL: 'template.js' });
*/
function template(string, options, guard) {
string = require_toString.toString(string);
if (guard) options = templateSettings;
options = require_defaults.defaults({ ...options }, templateSettings);
const delimitersRegExp = new RegExp([
options.escape?.source ?? noMatchExp.source,
options.interpolate?.source ?? noMatchExp.source,
options.interpolate === defaultInterpolateRegExp ? esTemplateRegExp.source : noMatchExp.source,
options.evaluate?.source ?? noMatchExp.source,
"$"
].join("|"), "g");
let lastIndex = 0;
let isEvaluated = false;
let source = `__p += ''`;
for (const match of string.matchAll(delimitersRegExp)) {
const [fullMatch, escapeValue, interpolateValue, esTemplateValue, evaluateValue] = match;
const { index } = match;
source += ` + '${string.slice(lastIndex, index).replace(unEscapedRegExp, escapeString)}'`;
if (escapeValue) source += ` + _.escape(${escapeValue})`;
if (interpolateValue) source += ` + ((${interpolateValue}) == null ? '' : ${interpolateValue})`;
else if (esTemplateValue) source += ` + ((${esTemplateValue}) == null ? '' : ${esTemplateValue})`;
if (evaluateValue) {
source += `;\n${evaluateValue};\n __p += ''`;
isEvaluated = true;
}
lastIndex = index + fullMatch.length;
}
const imports = require_defaults.defaults({ ...options.imports }, templateSettings.imports);
const importsKeys = Object.keys(imports);
const importValues = Object.values(imports);
const sourceURL = `//# sourceURL=${options.sourceURL ? String(options.sourceURL).replace(/[\r\n]/g, " ") : `es-toolkit.templateSource[${Date.now()}]`}\n`;
const compiledFunction = `function(${options.variable || "obj"}) {
let __p = '';
${options.variable ? "" : "if (obj == null) { obj = {}; }"}
${isEvaluated ? `function print() { __p += Array.prototype.join.call(arguments, ''); }` : ""}
${options.variable ? source : `with(obj) {\n${source}\n}`}
return __p;
}`;
const result = require_attempt.attempt(() => new Function(...importsKeys, `${sourceURL}return ${compiledFunction}`)(...importValues));
result.source = compiledFunction;
if (result instanceof Error) throw result;
return result;
}
//#endregion
exports.template = template;
exports.templateSettings = templateSettings;

View file

@ -0,0 +1,137 @@
import { toString } from "../util/toString.mjs";
import { attempt } from "../function/attempt.mjs";
import { defaults } from "../object/defaults.mjs";
import { escape } from "./escape.mjs";
//#region src/compat/string/template.ts
const esTemplateRegExp = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
const unEscapedRegExp = /['\n\r\u2028\u2029\\]/g;
const noMatchExp = /($^)/;
const escapeMap = new Map([
["\\", "\\"],
["'", "'"],
["\n", "n"],
["\r", "r"],
["\u2028", "u2028"],
["\u2029", "u2029"]
]);
function escapeString(match) {
return `\\${escapeMap.get(match)}`;
}
const defaultInterpolateRegExp = /<%=([\s\S]+?)%>/g;
const templateSettings = {
escape: /<%-([\s\S]+?)%>/g,
evaluate: /<%([\s\S]+?)%>/g,
interpolate: defaultInterpolateRegExp,
variable: "",
imports: { _: {
escape,
template
} }
};
/**
* Compiles a template string into a function that can interpolate data properties.
*
* This function allows you to create a template with custom delimiters for escaping,
* evaluating, and interpolating values. It can also handle custom variable names and
* imported functions.
*
* @param string - The template string.
* @param [options] - The options object.
* @param [options.escape] - The regular expression for "escape" delimiter.
* @param [options.evaluate] - The regular expression for "evaluate" delimiter.
* @param [options.interpolate] - The regular expression for "interpolate" delimiter.
* @param [options.variable] - The data object variable name.
* @param [options.imports] - The object of imported functions.
* @param [options.sourceURL] - The source URL of the template.
* @param [guard] - The guard to detect if the function is called with `options`.
* @returns Returns the compiled template function.
*
* @example
* // Use the "escape" delimiter to escape data properties.
* const compiled = template('<%- value %>');
* compiled({ value: '<div>' }); // returns '&lt;div&gt;'
*
* @example
* // Use the "interpolate" delimiter to interpolate data properties.
* const compiled = template('<%= value %>');
* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'
*
* @example
* // Use the "evaluate" delimiter to evaluate JavaScript code.
* const compiled = template('<% if (value) { %>Yes<% } else { %>No<% } %>');
* compiled({ value: true }); // returns 'Yes'
*
* @example
* // Use the "variable" option to specify the data object variable name.
* const compiled = template('<%= data.value %>', { variable: 'data' });
* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'
*
* @example
* // Use the "imports" option to import functions.
* const compiled = template('<%= _.toUpper(value) %>', { imports: { _: { toUpper } } });
* compiled({ value: 'hello, world!' }); // returns 'HELLO, WORLD!'
*
* @example
* // Use the custom "escape" delimiter.
* const compiled = template('<@ value @>', { escape: /<@([\s\S]+?)@>/g });
* compiled({ value: '<div>' }); // returns '&lt;div&gt;'
*
* @example
* // Use the custom "evaluate" delimiter.
* const compiled = template('<# if (value) { #>Yes<# } else { #>No<# } #>', { evaluate: /<#([\s\S]+?)#>/g });
* compiled({ value: true }); // returns 'Yes'
*
* @example
* // Use the custom "interpolate" delimiter.
* const compiled = template('<$ value $>', { interpolate: /<\$([\s\S]+?)\$>/g });
* compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'
*
* @example
* // Use the "sourceURL" option to specify the source URL of the template.
* const compiled = template('hello <%= user %>!', { sourceURL: 'template.js' });
*/
function template(string, options, guard) {
string = toString(string);
if (guard) options = templateSettings;
options = defaults({ ...options }, templateSettings);
const delimitersRegExp = new RegExp([
options.escape?.source ?? noMatchExp.source,
options.interpolate?.source ?? noMatchExp.source,
options.interpolate === defaultInterpolateRegExp ? esTemplateRegExp.source : noMatchExp.source,
options.evaluate?.source ?? noMatchExp.source,
"$"
].join("|"), "g");
let lastIndex = 0;
let isEvaluated = false;
let source = `__p += ''`;
for (const match of string.matchAll(delimitersRegExp)) {
const [fullMatch, escapeValue, interpolateValue, esTemplateValue, evaluateValue] = match;
const { index } = match;
source += ` + '${string.slice(lastIndex, index).replace(unEscapedRegExp, escapeString)}'`;
if (escapeValue) source += ` + _.escape(${escapeValue})`;
if (interpolateValue) source += ` + ((${interpolateValue}) == null ? '' : ${interpolateValue})`;
else if (esTemplateValue) source += ` + ((${esTemplateValue}) == null ? '' : ${esTemplateValue})`;
if (evaluateValue) {
source += `;\n${evaluateValue};\n __p += ''`;
isEvaluated = true;
}
lastIndex = index + fullMatch.length;
}
const imports = defaults({ ...options.imports }, templateSettings.imports);
const importsKeys = Object.keys(imports);
const importValues = Object.values(imports);
const sourceURL = `//# sourceURL=${options.sourceURL ? String(options.sourceURL).replace(/[\r\n]/g, " ") : `es-toolkit.templateSource[${Date.now()}]`}\n`;
const compiledFunction = `function(${options.variable || "obj"}) {
let __p = '';
${options.variable ? "" : "if (obj == null) { obj = {}; }"}
${isEvaluated ? `function print() { __p += Array.prototype.join.call(arguments, ''); }` : ""}
${options.variable ? source : `with(obj) {\n${source}\n}`}
return __p;
}`;
const result = attempt(() => new Function(...importsKeys, `${sourceURL}return ${compiledFunction}`)(...importValues));
result.source = compiledFunction;
if (result instanceof Error) throw result;
return result;
}
//#endregion
export { template, templateSettings };

View file

@ -0,0 +1 @@
import { templateSettings } from "./template.mjs";

View file

@ -0,0 +1 @@
import { templateSettings } from "./template.js";

View file

@ -0,0 +1 @@
require("./template.js");

View file

@ -0,0 +1 @@
import "./template.mjs";

View file

@ -0,0 +1,21 @@
//#region src/compat/string/toLower.d.ts
/**
* Converts the given value to a string and transforms it to lower case.
* The function can handle various input types by first converting them to strings.
*
* @param [value=''] The value to convert.
* @returns Returns the lower cased string.
* @example
*
* toLower('--FOO-BAR--');
* // => '--foo-bar--'
*
* toLower(null);
* // => ''
*
* toLower([1, 2, 3]);
* // => '1,2,3'
*/
declare function toLower<T extends string = string>(value?: T): Lowercase<T>;
//#endregion
export { toLower };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/toLower.d.ts
/**
* Converts the given value to a string and transforms it to lower case.
* The function can handle various input types by first converting them to strings.
*
* @param [value=''] The value to convert.
* @returns Returns the lower cased string.
* @example
*
* toLower('--FOO-BAR--');
* // => '--foo-bar--'
*
* toLower(null);
* // => ''
*
* toLower([1, 2, 3]);
* // => '1,2,3'
*/
declare function toLower<T extends string = string>(value?: T): Lowercase<T>;
//#endregion
export { toLower };

View file

@ -0,0 +1,24 @@
const require_toString = require("../util/toString.js");
//#region src/compat/string/toLower.ts
/**
* Converts the given value to a string and transforms it to lower case.
* The function can handle various input types by first converting them to strings.
*
* @param [value=''] The value to convert.
* @returns Returns the lower cased string.
* @example
*
* toLower('--FOO-BAR--');
* // => '--foo-bar--'
*
* toLower(null);
* // => ''
*
* toLower([1, 2, 3]);
* // => '1,2,3'
*/
function toLower(value) {
return require_toString.toString(value).toLowerCase();
}
//#endregion
exports.toLower = toLower;

View file

@ -0,0 +1,24 @@
import { toString } from "../util/toString.mjs";
//#region src/compat/string/toLower.ts
/**
* Converts the given value to a string and transforms it to lower case.
* The function can handle various input types by first converting them to strings.
*
* @param [value=''] The value to convert.
* @returns Returns the lower cased string.
* @example
*
* toLower('--FOO-BAR--');
* // => '--foo-bar--'
*
* toLower(null);
* // => ''
*
* toLower([1, 2, 3]);
* // => '1,2,3'
*/
function toLower(value) {
return toString(value).toLowerCase();
}
//#endregion
export { toLower };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/toUpper.d.ts
/**
* Converts `string`, as a whole, to upper case just like
* [String#toUpperCase](https://mdn.io/toUpperCase).
*
* @param [value=''] The value to convert.
* @returns Returns the upper cased string.
* @example
*
* toUpper('--foo-bar--');
* // => '--FOO-BAR--'
*
* toUpper(null);
* // => ''
*
* toUpper([1, 2, 3]);
* // => '1,2,3'
*/
declare function toUpper<T extends string = string>(value?: T): Uppercase<T>;
//#endregion
export { toUpper };

View file

@ -0,0 +1,21 @@
//#region src/compat/string/toUpper.d.ts
/**
* Converts `string`, as a whole, to upper case just like
* [String#toUpperCase](https://mdn.io/toUpperCase).
*
* @param [value=''] The value to convert.
* @returns Returns the upper cased string.
* @example
*
* toUpper('--foo-bar--');
* // => '--FOO-BAR--'
*
* toUpper(null);
* // => ''
*
* toUpper([1, 2, 3]);
* // => '1,2,3'
*/
declare function toUpper<T extends string = string>(value?: T): Uppercase<T>;
//#endregion
export { toUpper };

View file

@ -0,0 +1,24 @@
const require_toString = require("../util/toString.js");
//#region src/compat/string/toUpper.ts
/**
* Converts `string`, as a whole, to upper case just like
* [String#toUpperCase](https://mdn.io/toUpperCase).
*
* @param [value=''] The value to convert.
* @returns Returns the upper cased string.
* @example
*
* toUpper('--foo-bar--');
* // => '--FOO-BAR--'
*
* toUpper(null);
* // => ''
*
* toUpper([1, 2, 3]);
* // => '1,2,3'
*/
function toUpper(value) {
return require_toString.toString(value).toUpperCase();
}
//#endregion
exports.toUpper = toUpper;

View file

@ -0,0 +1,24 @@
import { toString } from "../util/toString.mjs";
//#region src/compat/string/toUpper.ts
/**
* Converts `string`, as a whole, to upper case just like
* [String#toUpperCase](https://mdn.io/toUpperCase).
*
* @param [value=''] The value to convert.
* @returns Returns the upper cased string.
* @example
*
* toUpper('--foo-bar--');
* // => '--FOO-BAR--'
*
* toUpper(null);
* // => ''
*
* toUpper([1, 2, 3]);
* // => '1,2,3'
*/
function toUpper(value) {
return toString(value).toUpperCase();
}
//#endregion
export { toUpper };

View file

@ -0,0 +1,29 @@
//#region src/compat/string/trim.d.ts
/**
* Removes leading and trailing whitespace or specified characters from a string.
*
* @param str - The string from which leading and trailing characters will be trimmed.
* @param chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @returns The resulting string after the specified leading and trailing characters have been removed.
*
* @example
* trim(" hello "); // "hello"
* trim("--hello--", "-"); // "hello"
* trim("##hello##", ["#", "o"]); // "hell"
*/
declare function trim(string?: string, chars?: string): string;
/**
* Removes leading and trailing whitespace or specified characters from a string.
*
* @param str - The string from which leading and trailing characters will be trimmed.
* @param chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @returns The resulting string after the specified leading and trailing characters have been removed.
*
* @example
* trim(" hello "); // "hello"
* trim("--hello--", "-"); // "hello"
* trim("##hello##", ["#", "o"]); // "hell"
*/
declare function trim(string: string, index: string | number, guard: object): string;
//#endregion
export { trim };

View file

@ -0,0 +1,29 @@
//#region src/compat/string/trim.d.ts
/**
* Removes leading and trailing whitespace or specified characters from a string.
*
* @param str - The string from which leading and trailing characters will be trimmed.
* @param chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @returns The resulting string after the specified leading and trailing characters have been removed.
*
* @example
* trim(" hello "); // "hello"
* trim("--hello--", "-"); // "hello"
* trim("##hello##", ["#", "o"]); // "hell"
*/
declare function trim(string?: string, chars?: string): string;
/**
* Removes leading and trailing whitespace or specified characters from a string.
*
* @param str - The string from which leading and trailing characters will be trimmed.
* @param chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @returns The resulting string after the specified leading and trailing characters have been removed.
*
* @example
* trim(" hello "); // "hello"
* trim("--hello--", "-"); // "hello"
* trim("##hello##", ["#", "o"]); // "hell"
*/
declare function trim(string: string, index: string | number, guard: object): string;
//#endregion
export { trim };

View file

@ -0,0 +1,13 @@
const require_trim = require("../../string/trim.js");
//#region src/compat/string/trim.ts
function trim(str, chars, guard) {
if (str == null) return "";
if (guard != null || chars == null) return str.toString().trim();
switch (typeof chars) {
case "object": if (Array.isArray(chars)) return require_trim.trim(str, chars.flatMap((x) => x.toString().split("")));
else return require_trim.trim(str, chars.toString().split(""));
default: return require_trim.trim(str, chars.toString().split(""));
}
}
//#endregion
exports.trim = trim;

View file

@ -0,0 +1,13 @@
import { trim as trim$1 } from "../../string/trim.mjs";
//#region src/compat/string/trim.ts
function trim(str, chars, guard) {
if (str == null) return "";
if (guard != null || chars == null) return str.toString().trim();
switch (typeof chars) {
case "object": if (Array.isArray(chars)) return trim$1(str, chars.flatMap((x) => x.toString().split("")));
else return trim$1(str, chars.toString().split(""));
default: return trim$1(str, chars.toString().split(""));
}
}
//#endregion
export { trim };

View file

@ -0,0 +1,31 @@
//#region src/compat/string/trimEnd.d.ts
/**
* Removes trailing whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param chars - The characters to trim from the end of the string.
* @returns Returns the trimmed string.
*
* @example
* trimEnd(' abc ');
* // => ' abc'
*
* trimEnd('-_-abc-_-', '_-');
* // => '-_-abc'
*/
declare function trimEnd(string?: string, chars?: string): string;
/**
* Removes trailing whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param index - The index parameter (used with guard).
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimEnd(' abc ', 0, {});
* // => ' abc'
*/
declare function trimEnd(string: string, index: string | number, guard: object): string;
//#endregion
export { trimEnd };

View file

@ -0,0 +1,31 @@
//#region src/compat/string/trimEnd.d.ts
/**
* Removes trailing whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param chars - The characters to trim from the end of the string.
* @returns Returns the trimmed string.
*
* @example
* trimEnd(' abc ');
* // => ' abc'
*
* trimEnd('-_-abc-_-', '_-');
* // => '-_-abc'
*/
declare function trimEnd(string?: string, chars?: string): string;
/**
* Removes trailing whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param index - The index parameter (used with guard).
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimEnd(' abc ', 0, {});
* // => ' abc'
*/
declare function trimEnd(string: string, index: string | number, guard: object): string;
//#endregion
export { trimEnd };

View file

@ -0,0 +1,24 @@
const require_trimEnd = require("../../string/trimEnd.js");
//#region src/compat/string/trimEnd.ts
/**
* Removes trailing whitespace or specified characters from a string.
*
* @param str - The string from which trailing characters will be trimmed.
* @param chars - The character(s) to remove from the end of the string.
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimEnd(' abc ');
* // => ' abc'
*
* trimEnd('-_-abc-_-', '_-');
* // => '-_-abc'
*/
function trimEnd(str, chars, guard) {
if (str == null) return "";
if (guard != null || chars == null) return str.toString().trimEnd();
return require_trimEnd.trimEnd(str, chars.toString().split(""));
}
//#endregion
exports.trimEnd = trimEnd;

View file

@ -0,0 +1,24 @@
import { trimEnd as trimEnd$1 } from "../../string/trimEnd.mjs";
//#region src/compat/string/trimEnd.ts
/**
* Removes trailing whitespace or specified characters from a string.
*
* @param str - The string from which trailing characters will be trimmed.
* @param chars - The character(s) to remove from the end of the string.
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimEnd(' abc ');
* // => ' abc'
*
* trimEnd('-_-abc-_-', '_-');
* // => '-_-abc'
*/
function trimEnd(str, chars, guard) {
if (str == null) return "";
if (guard != null || chars == null) return str.toString().trimEnd();
return trimEnd$1(str, chars.toString().split(""));
}
//#endregion
export { trimEnd };

View file

@ -0,0 +1,31 @@
//#region src/compat/string/trimStart.d.ts
/**
* Removes leading whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param chars - The characters to trim from the start of the string.
* @returns Returns the trimmed string.
*
* @example
* trimStart(' abc ');
* // => 'abc '
*
* trimStart('-_-abc-_-', '_-');
* // => 'abc-_-'
*/
declare function trimStart(string?: string, chars?: string): string;
/**
* Removes leading whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param index - The index parameter (used with guard).
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimStart(' abc ', 0, {});
* // => 'abc '
*/
declare function trimStart(string: string, index: string | number, guard: object): string;
//#endregion
export { trimStart };

View file

@ -0,0 +1,31 @@
//#region src/compat/string/trimStart.d.ts
/**
* Removes leading whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param chars - The characters to trim from the start of the string.
* @returns Returns the trimmed string.
*
* @example
* trimStart(' abc ');
* // => 'abc '
*
* trimStart('-_-abc-_-', '_-');
* // => 'abc-_-'
*/
declare function trimStart(string?: string, chars?: string): string;
/**
* Removes leading whitespace or specified characters from a string.
*
* @param string - The string to trim.
* @param index - The index parameter (used with guard).
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimStart(' abc ', 0, {});
* // => 'abc '
*/
declare function trimStart(string: string, index: string | number, guard: object): string;
//#endregion
export { trimStart };

View file

@ -0,0 +1,24 @@
const require_trimStart = require("../../string/trimStart.js");
//#region src/compat/string/trimStart.ts
/**
* Removes leading whitespace or specified characters from a string.
*
* @param str - The string from which leading characters will be trimmed.
* @param chars - The character(s) to remove from the start of the string.
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimStart(' abc ');
* // => 'abc '
*
* trimStart('-_-abc-_-', '_-');
* // => 'abc-_-'
*/
function trimStart(str, chars, guard) {
if (str == null) return "";
if (guard != null || chars == null) return str.toString().trimStart();
return require_trimStart.trimStart(str, chars.toString().split(""));
}
//#endregion
exports.trimStart = trimStart;

View file

@ -0,0 +1,24 @@
import { trimStart as trimStart$1 } from "../../string/trimStart.mjs";
//#region src/compat/string/trimStart.ts
/**
* Removes leading whitespace or specified characters from a string.
*
* @param str - The string from which leading characters will be trimmed.
* @param chars - The character(s) to remove from the start of the string.
* @param guard - Enables use as an iteratee for methods like `map`.
* @returns Returns the trimmed string.
*
* @example
* trimStart(' abc ');
* // => 'abc '
*
* trimStart('-_-abc-_-', '_-');
* // => 'abc-_-'
*/
function trimStart(str, chars, guard) {
if (str == null) return "";
if (guard != null || chars == null) return str.toString().trimStart();
return trimStart$1(str, chars.toString().split(""));
}
//#endregion
export { trimStart };

Some files were not shown because too many files have changed in this diff Show more