es-toolkit 1.10.1-dev.248 → 1.10.1-dev.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,21 @@
1
1
  import "./chunk-NKLIE2OI.mjs";
2
2
  import "./chunk-ARZ5BDR6.mjs";
3
- import "./chunk-XT74R35S.mjs";
3
+ import "./chunk-YCTGSM4S.mjs";
4
+ import {
5
+ startCase
6
+ } from "./chunk-QXTNZR7B.mjs";
7
+ import {
8
+ startsWith
9
+ } from "./chunk-SR5RPVRM.mjs";
4
10
  import {
5
11
  camelCase
6
12
  } from "./chunk-Y5V7UAZZ.mjs";
7
13
  import {
8
14
  capitalize
9
15
  } from "./chunk-U56ZOM7L.mjs";
16
+ import {
17
+ endsWith
18
+ } from "./chunk-ZFRI6VS4.mjs";
10
19
  import {
11
20
  kebabCase
12
21
  } from "./chunk-EYYZQFOP.mjs";
@@ -16,9 +25,6 @@ import {
16
25
  import {
17
26
  snakeCase
18
27
  } from "./chunk-F3WCQQET.mjs";
19
- import {
20
- startCase
21
- } from "./chunk-QXTNZR7B.mjs";
22
28
  import "./chunk-WVQ7YVRK.mjs";
23
29
  import "./chunk-ASJF5D6C.mjs";
24
30
  import {
@@ -285,6 +291,7 @@ export {
285
291
  dropRight,
286
292
  dropRightWhile,
287
293
  dropWhile,
294
+ endsWith,
288
295
  fill,
289
296
  flatMap,
290
297
  flatten,
@@ -330,6 +337,7 @@ export {
330
337
  shuffle,
331
338
  snakeCase,
332
339
  startCase,
340
+ startsWith,
333
341
  sum,
334
342
  sumBy,
335
343
  tail,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Checks if a string contains another string at the end of the string.
3
+ *
4
+ * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
5
+ *
6
+ * @param {string} str - The string that might contain the target string.
7
+ * @param {string} target - The string to search for.
8
+ * @param {number} position - An optional position from the start to search up to this index
9
+ * @returns {boolean} - True if the str string ends with the target string.
10
+ *
11
+ * @example
12
+ * const isPrefix = endsWith('fooBar', 'foo') // returns true
13
+ * const isPrefix = endsWith('fooBar', 'bar') // returns false
14
+ * const isPrefix = endsWith('fooBar', 'abc') // returns false
15
+ * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
16
+ * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
17
+ */
18
+ declare const endsWith: (str: string, target: string, position?: number) => boolean;
19
+
20
+ export { endsWith };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Checks if a string contains another string at the end of the string.
3
+ *
4
+ * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
5
+ *
6
+ * @param {string} str - The string that might contain the target string.
7
+ * @param {string} target - The string to search for.
8
+ * @param {number} position - An optional position from the start to search up to this index
9
+ * @returns {boolean} - True if the str string ends with the target string.
10
+ *
11
+ * @example
12
+ * const isPrefix = endsWith('fooBar', 'foo') // returns true
13
+ * const isPrefix = endsWith('fooBar', 'bar') // returns false
14
+ * const isPrefix = endsWith('fooBar', 'abc') // returns false
15
+ * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
16
+ * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
17
+ */
18
+ declare const endsWith: (str: string, target: string, position?: number) => boolean;
19
+
20
+ export { endsWith };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/string/endsWith.ts
21
+ var endsWith_exports = {};
22
+ __export(endsWith_exports, {
23
+ endsWith: () => endsWith
24
+ });
25
+ module.exports = __toCommonJS(endsWith_exports);
26
+ var endsWith = (str, target, position = str.length) => {
27
+ return str.endsWith(target, position);
28
+ };
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ endsWith
32
+ });
33
+ //# sourceMappingURL=endsWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/string/endsWith.ts"],"sourcesContent":["/**\n * Checks if a string contains another string at the end of the string.\n *\n * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional position from the start to search up to this index\n * @returns {boolean} - True if the str string ends with the target string.\n *\n * @example\n * const isPrefix = endsWith('fooBar', 'foo') // returns true\n * const isPrefix = endsWith('fooBar', 'bar') // returns false\n * const isPrefix = endsWith('fooBar', 'abc') // returns false\n * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true\n * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false\n */\nexport const endsWith = (str: string, target: string, position: number = str.length): boolean => {\n return str.endsWith(target, position);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,IAAM,WAAW,CAAC,KAAa,QAAgB,WAAmB,IAAI,WAAoB;AAC/F,SAAO,IAAI,SAAS,QAAQ,QAAQ;AACtC;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ endsWith
3
+ } from "../chunk-ZFRI6VS4.mjs";
4
+ import "../chunk-2MM5EJJX.mjs";
5
+ export {
6
+ endsWith
7
+ };
8
+ //# sourceMappingURL=endsWith.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -3,4 +3,6 @@ export { snakeCase } from './snakeCase.mjs';
3
3
  export { kebabCase } from './kebabCase.mjs';
4
4
  export { lowerCase } from './lowerCase.mjs';
5
5
  export { startCase } from './startCase.mjs';
6
+ export { startsWith } from './startsWith.mjs';
7
+ export { endsWith } from './endsWith.mjs';
6
8
  export { capitalize } from './capitalize.mjs';
@@ -3,4 +3,6 @@ export { snakeCase } from './snakeCase.js';
3
3
  export { kebabCase } from './kebabCase.js';
4
4
  export { lowerCase } from './lowerCase.js';
5
5
  export { startCase } from './startCase.js';
6
+ export { startsWith } from './startsWith.js';
7
+ export { endsWith } from './endsWith.js';
6
8
  export { capitalize } from './capitalize.js';
@@ -22,10 +22,12 @@ var string_exports = {};
22
22
  __export(string_exports, {
23
23
  camelCase: () => camelCase,
24
24
  capitalize: () => capitalize,
25
+ endsWith: () => endsWith,
25
26
  kebabCase: () => kebabCase,
26
27
  lowerCase: () => lowerCase,
27
28
  snakeCase: () => snakeCase,
28
- startCase: () => startCase
29
+ startCase: () => startCase,
30
+ startsWith: () => startsWith
29
31
  });
30
32
  module.exports = __toCommonJS(string_exports);
31
33
 
@@ -85,13 +87,25 @@ function startCase(str) {
85
87
  }
86
88
  return result;
87
89
  }
90
+
91
+ // src/string/startsWith.ts
92
+ var startsWith = (str, target, position = 0) => {
93
+ return str.startsWith(target, position);
94
+ };
95
+
96
+ // src/string/endsWith.ts
97
+ var endsWith = (str, target, position = str.length) => {
98
+ return str.endsWith(target, position);
99
+ };
88
100
  // Annotate the CommonJS export names for ESM import in node:
89
101
  0 && (module.exports = {
90
102
  camelCase,
91
103
  capitalize,
104
+ endsWith,
92
105
  kebabCase,
93
106
  lowerCase,
94
107
  snakeCase,
95
- startCase
108
+ startCase,
109
+ startsWith
96
110
  });
97
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/string/index.ts","../../src/string/capitalize.ts","../../src/string/_internal/getWords.ts","../../src/string/camelCase.ts","../../src/string/snakeCase.ts","../../src/string/kebabCase.ts","../../src/string/lowerCase.ts","../../src/string/startCase.ts"],"sourcesContent":["export { camelCase } from './camelCase.ts';\nexport { snakeCase } from './snakeCase.ts';\nexport { kebabCase } from './kebabCase.ts';\nexport { lowerCase } from './lowerCase.ts';\nexport { startCase } from './startCase.ts';\nexport { capitalize } from './capitalize.ts';\n","/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n","import { capitalize } from \"./capitalize.ts\";\nimport { getWords } from \"./_internal/getWords.ts\";\n\n/**\n * Converts a string to camel case.\n *\n * camel case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n */\n\nexport function camelCase(str: string): string {\n const words = getWords(str);\n\n if (words.length === 0) {\n return \"\";\n }\n\n const [first, ...rest] = words;\n\n return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join(\"\")\n }`;\n}\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport const kebabCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport const lowerCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str: string): string {\n const words = getWords(str.trim());\n let result = '';\n for (const word of words) {\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;;;ACEA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ACFO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,GAAG;AAE1B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO,GAAG,MAAM,YAAY,CAAC,GAAG,KAAK,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,EAAE,KAAK,EAAE,CAC1E;AACJ;;;ACZO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACHO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,IAAI,KAAK,CAAC;AACjC,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,QAAQ;AACV,gBAAU;AAAA,IACZ;AACA,QAAI,SAAS,KAAK,YAAY,GAAG;AAC/B,gBAAU;AAAA,IACZ,OAAO;AACL,gBAAU,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/string/index.ts","../../src/string/capitalize.ts","../../src/string/_internal/getWords.ts","../../src/string/camelCase.ts","../../src/string/snakeCase.ts","../../src/string/kebabCase.ts","../../src/string/lowerCase.ts","../../src/string/startCase.ts","../../src/string/startsWith.ts","../../src/string/endsWith.ts"],"sourcesContent":["export { camelCase } from './camelCase.ts';\nexport { snakeCase } from './snakeCase.ts';\nexport { kebabCase } from './kebabCase.ts';\nexport { lowerCase } from './lowerCase.ts';\nexport { startCase } from './startCase.ts';\nexport { startsWith } from './startsWith.ts';\nexport { endsWith } from './endsWith.ts';\nexport { capitalize } from './capitalize.ts';\n","/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n","import { capitalize } from \"./capitalize.ts\";\nimport { getWords } from \"./_internal/getWords.ts\";\n\n/**\n * Converts a string to camel case.\n *\n * camel case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n */\n\nexport function camelCase(str: string): string {\n const words = getWords(str);\n\n if (words.length === 0) {\n return \"\";\n }\n\n const [first, ...rest] = words;\n\n return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join(\"\")\n }`;\n}\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport const kebabCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport const lowerCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str: string): string {\n const words = getWords(str.trim());\n let result = '';\n for (const word of words) {\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\n}\n","/**\n * Checks if a string contains another string at the beginning of the string.\n *\n * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional offset to start searching in the str string\n * @returns {boolean} - True if the str string starts with the target string.\n *\n * @example\n * const isPrefix = startsWith('fooBar', 'foo') // returns true\n * const isPrefix = startsWith('fooBar', 'bar') // returns false\n * const isPrefix = startsWith('fooBar', 'abc') // returns false\n * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true\n * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false\n */\nexport const startsWith = (str: string, target: string, position: number = 0): boolean => {\n return str.startsWith(target, position);\n};\n","/**\n * Checks if a string contains another string at the end of the string.\n *\n * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional position from the start to search up to this index\n * @returns {boolean} - True if the str string ends with the target string.\n *\n * @example\n * const isPrefix = endsWith('fooBar', 'foo') // returns true\n * const isPrefix = endsWith('fooBar', 'bar') // returns false\n * const isPrefix = endsWith('fooBar', 'abc') // returns false\n * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true\n * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false\n */\nexport const endsWith = (str: string, target: string, position: number = str.length): boolean => {\n return str.endsWith(target, position);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;;;ACEA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ACFO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,GAAG;AAE1B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO,GAAG,MAAM,YAAY,CAAC,GAAG,KAAK,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,EAAE,KAAK,EAAE,CAC1E;AACJ;;;ACZO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACHO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,IAAI,KAAK,CAAC;AACjC,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,QAAQ;AACV,gBAAU;AAAA,IACZ;AACA,QAAI,SAAS,KAAK,YAAY,GAAG;AAC/B,gBAAU;AAAA,IACZ,OAAO;AACL,gBAAU,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;;;ACZO,IAAM,aAAa,CAAC,KAAa,QAAgB,WAAmB,MAAe;AACxF,SAAO,IAAI,WAAW,QAAQ,QAAQ;AACxC;;;ACFO,IAAM,WAAW,CAAC,KAAa,QAAgB,WAAmB,IAAI,WAAoB;AAC/F,SAAO,IAAI,SAAS,QAAQ,QAAQ;AACtC;","names":[]}
@@ -1,10 +1,19 @@
1
- import "../chunk-XT74R35S.mjs";
1
+ import "../chunk-YCTGSM4S.mjs";
2
+ import {
3
+ startCase
4
+ } from "../chunk-QXTNZR7B.mjs";
5
+ import {
6
+ startsWith
7
+ } from "../chunk-SR5RPVRM.mjs";
2
8
  import {
3
9
  camelCase
4
10
  } from "../chunk-Y5V7UAZZ.mjs";
5
11
  import {
6
12
  capitalize
7
13
  } from "../chunk-U56ZOM7L.mjs";
14
+ import {
15
+ endsWith
16
+ } from "../chunk-ZFRI6VS4.mjs";
8
17
  import {
9
18
  kebabCase
10
19
  } from "../chunk-EYYZQFOP.mjs";
@@ -14,17 +23,16 @@ import {
14
23
  import {
15
24
  snakeCase
16
25
  } from "../chunk-F3WCQQET.mjs";
17
- import {
18
- startCase
19
- } from "../chunk-QXTNZR7B.mjs";
20
26
  import "../chunk-WVQ7YVRK.mjs";
21
27
  import "../chunk-2MM5EJJX.mjs";
22
28
  export {
23
29
  camelCase,
24
30
  capitalize,
31
+ endsWith,
25
32
  kebabCase,
26
33
  lowerCase,
27
34
  snakeCase,
28
- startCase
35
+ startCase,
36
+ startsWith
29
37
  };
30
38
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Checks if a string contains another string at the beginning of the string.
3
+ *
4
+ * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
5
+ *
6
+ * @param {string} str - The string that might contain the target string.
7
+ * @param {string} target - The string to search for.
8
+ * @param {number} position - An optional offset to start searching in the str string
9
+ * @returns {boolean} - True if the str string starts with the target string.
10
+ *
11
+ * @example
12
+ * const isPrefix = startsWith('fooBar', 'foo') // returns true
13
+ * const isPrefix = startsWith('fooBar', 'bar') // returns false
14
+ * const isPrefix = startsWith('fooBar', 'abc') // returns false
15
+ * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
16
+ * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
17
+ */
18
+ declare const startsWith: (str: string, target: string, position?: number) => boolean;
19
+
20
+ export { startsWith };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Checks if a string contains another string at the beginning of the string.
3
+ *
4
+ * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
5
+ *
6
+ * @param {string} str - The string that might contain the target string.
7
+ * @param {string} target - The string to search for.
8
+ * @param {number} position - An optional offset to start searching in the str string
9
+ * @returns {boolean} - True if the str string starts with the target string.
10
+ *
11
+ * @example
12
+ * const isPrefix = startsWith('fooBar', 'foo') // returns true
13
+ * const isPrefix = startsWith('fooBar', 'bar') // returns false
14
+ * const isPrefix = startsWith('fooBar', 'abc') // returns false
15
+ * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
16
+ * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
17
+ */
18
+ declare const startsWith: (str: string, target: string, position?: number) => boolean;
19
+
20
+ export { startsWith };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/string/startsWith.ts
21
+ var startsWith_exports = {};
22
+ __export(startsWith_exports, {
23
+ startsWith: () => startsWith
24
+ });
25
+ module.exports = __toCommonJS(startsWith_exports);
26
+ var startsWith = (str, target, position = 0) => {
27
+ return str.startsWith(target, position);
28
+ };
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ startsWith
32
+ });
33
+ //# sourceMappingURL=startsWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/string/startsWith.ts"],"sourcesContent":["/**\n * Checks if a string contains another string at the beginning of the string.\n *\n * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional offset to start searching in the str string\n * @returns {boolean} - True if the str string starts with the target string.\n *\n * @example\n * const isPrefix = startsWith('fooBar', 'foo') // returns true\n * const isPrefix = startsWith('fooBar', 'bar') // returns false\n * const isPrefix = startsWith('fooBar', 'abc') // returns false\n * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true\n * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false\n */\nexport const startsWith = (str: string, target: string, position: number = 0): boolean => {\n return str.startsWith(target, position);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,IAAM,aAAa,CAAC,KAAa,QAAgB,WAAmB,MAAe;AACxF,SAAO,IAAI,WAAW,QAAQ,QAAQ;AACxC;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ startsWith
3
+ } from "../chunk-SR5RPVRM.mjs";
4
+ import "../chunk-2MM5EJJX.mjs";
5
+ export {
6
+ startsWith
7
+ };
8
+ //# sourceMappingURL=startsWith.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.10.1-dev.248+a186e5d4",
4
+ "version": "1.10.1-dev.250+b9b409db",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-XT74R35S.mjs.map