moderndash
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -1239,2 +1239,47 @@ /** | ||
/** | ||
* Trim the string from the left and right by the given characters | ||
* | ||
* *Use the native [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) method if you want to trim whitespace.* | ||
* @example | ||
* ```ts | ||
* trim('$$abc$', '$') // => 'abc' | ||
* trim('!!abc_!', '_!') // => 'abc' | ||
* ``` | ||
* @param str The string to trim | ||
* @param chars The characters to trim | ||
* @returns The trimmed string | ||
*/ | ||
declare function trim(str: string, chars: string): string; | ||
/** | ||
* Trims the specified characters from the end of the string. | ||
* | ||
* *Use the native [trimEnd](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd) method if you want to trim whitespace.* | ||
* @example | ||
* ```ts | ||
* trimEnd('abc$$$', '$') // => 'abc' | ||
* trimEnd('abc_!!_', '_!') // => 'abc' | ||
* ``` | ||
* @param str The string to trim | ||
* @param chars The characters to trim | ||
* @returns The trimmed string | ||
*/ | ||
declare function trimEnd(str: string, chars: string): string; | ||
/** | ||
* Trims specified characters from the start of the string. | ||
* | ||
* *Use the native [trimStart](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart) method if you want to trim whitespace.* | ||
* @example | ||
* ```ts | ||
* trimStart('$$$abc', '$') // => 'abc' | ||
* trimStart('_!!_abc', '_!') // => 'abc' | ||
* ``` | ||
* @param str The string to trim | ||
* @param chars The characters to trim | ||
* @returns The trimmed string | ||
*/ | ||
declare function trimStart(str: string, chars: string): string; | ||
/** | ||
* Converts the HTML entities `&`, `<`, `>`, `"` and `'` | ||
@@ -1325,2 +1370,2 @@ * in a string to their corresponding characters. | ||
export { ArrayMinLength, GenericFunction, Jsonifiable, PlainObject, Queue, average, camelCase, capitalize, chunk, count, debounce, deburr, decDebounce, decMaxCalls, decMemoize, decMinCalls, decThrottle, difference, dropRightWhile, dropWhile, escapeHtml, escapeRegExp, flatKeys, group, hash, intersection, isEmpty, isEqual, isPlainObject, isUrl, kebabCase, maxCalls, median, memoize, merge, minCalls, omit, pascalCase, pick, races, randomElem, randomFloat, randomInt, randomString, range, retry, round, set, shuffle, sleep, snakeCase, sort, splitWords, sum, takeRightWhile, takeWhile, throttle, timeout, times, titleCase, toDecorator, tryCatch, unescapeHtml, unique }; | ||
export { ArrayMinLength, GenericFunction, Jsonifiable, PlainObject, Queue, average, camelCase, capitalize, chunk, count, debounce, deburr, decDebounce, decMaxCalls, decMemoize, decMinCalls, decThrottle, difference, dropRightWhile, dropWhile, escapeHtml, escapeRegExp, flatKeys, group, hash, intersection, isEmpty, isEqual, isPlainObject, isUrl, kebabCase, maxCalls, median, memoize, merge, minCalls, omit, pascalCase, pick, races, randomElem, randomFloat, randomInt, randomString, range, retry, round, set, shuffle, sleep, snakeCase, sort, splitWords, sum, takeRightWhile, takeWhile, throttle, timeout, times, titleCase, toDecorator, trim, trimEnd, trimStart, tryCatch, unescapeHtml, unique }; |
@@ -745,2 +745,33 @@ // src/array/chunk.ts | ||
// src/string/trim.ts | ||
function trim(str, chars) { | ||
let startIndex = 0; | ||
while (startIndex < str.length && chars.includes(str[startIndex])) { | ||
startIndex++; | ||
} | ||
let endIndex = str.length - 1; | ||
while (endIndex >= startIndex && chars.includes(str[endIndex])) { | ||
endIndex--; | ||
} | ||
return str.slice(startIndex, endIndex + 1); | ||
} | ||
// src/string/trimEnd.ts | ||
function trimEnd(str, chars) { | ||
let lastIndex = str.length - 1; | ||
while (lastIndex >= 0 && chars.includes(str[lastIndex])) { | ||
lastIndex--; | ||
} | ||
return str.slice(0, lastIndex + 1); | ||
} | ||
// src/string/trimStart.ts | ||
function trimStart(str, chars) { | ||
let startIndex = 0; | ||
while (startIndex < str.length && chars.includes(str[startIndex])) { | ||
startIndex++; | ||
} | ||
return str.slice(startIndex); | ||
} | ||
// src/string/unescapeHtml.ts | ||
@@ -884,2 +915,5 @@ var htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g; | ||
toDecorator, | ||
trim, | ||
trimEnd, | ||
trimStart, | ||
tryCatch, | ||
@@ -886,0 +920,0 @@ unescapeHtml, |
{ | ||
"name": "moderndash", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A Typescript-First utility library inspired by Lodash. Optimized for modern browsers.", |
@@ -88,2 +88,2 @@ ![ModernDash Logo](https://raw.githubusercontent.com/Maggi64/moderndash/main/website/src/assets/moderndashLogo.svg) | ||
Check the [contribute](https://github.com/Maggi64/moderndash/blob/main/CONTRIBUTE.md) section! | ||
Check the [contributing](https://github.com/Maggi64/moderndash/blob/main/CONTRIBUTING.md) section! |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
280565
3104