moderndash
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "moderndash", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"type": "module", | ||
@@ -43,3 +43,3 @@ "description": "A lodash inspired utility framework for ESM/Typescript/ES2020", | ||
], | ||
"homepage": "https://github.com/Maggi64/moderndash#readme", | ||
"homepage": "https://moderndash.io", | ||
"devDependencies": { | ||
@@ -46,0 +46,0 @@ "@vitest/coverage-c8": "0.27.1", |
@@ -8,3 +8,3 @@ /** | ||
* @param array - The array or object to shuffle. | ||
* @returns {Array} Returns the new shuffled array. | ||
* @returns Returns the new shuffled array. | ||
* @example | ||
@@ -11,0 +11,0 @@ * shuffle([1, 2, 3, 4]) |
@@ -8,3 +8,3 @@ /** | ||
* @param comparator - The comparator invoked per element. | ||
* @returns {Array} Returns the new duplicate free array. | ||
* @returns Returns the new duplicate free array. | ||
* @example | ||
@@ -11,0 +11,0 @@ * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }] |
@@ -10,6 +10,2 @@ import type { ArrayOrRecord, RecordKey } from '../types'; | ||
* | ||
* @category Collection | ||
* @param iteratee - The iteratee to transform keys. | ||
* @param collection - The array or record to iterate over. | ||
* @returns Returns the composed aggregate object. | ||
* @example | ||
@@ -24,2 +20,6 @@ * const users = [ | ||
* // => { 'true': 2, 'false': 1 } | ||
* @category Collection | ||
* @param iteratee - The iteratee to transform keys. | ||
* @param collection - The array or record to iterate over. | ||
* @returns Returns the composed aggregate object. | ||
*/ | ||
@@ -26,0 +26,0 @@ |
@@ -13,2 +13,5 @@ import type { RecordKey, ArrayOrRecord } from '../types'; | ||
* | ||
* @example | ||
* groupBy([6.1, 4.2, 6.3], Math.floor) | ||
* // => { '4': [4.2], '6': [6.1, 6.3] } | ||
* @category Collection | ||
@@ -18,5 +21,2 @@ * @param collection - The array or object to iterate over. | ||
* @returns Returns the composed aggregate object. | ||
* @example | ||
* groupBy([6.1, 4.2, 6.3], Math.floor) | ||
* // => { '4': [4.2], '6': [6.1, 6.3] } | ||
*/ | ||
@@ -23,0 +23,0 @@ |
/** | ||
* Creates an object composed of the picked `object` properties. | ||
* | ||
* @category Object | ||
* @param object The source object. | ||
* @param keys The property paths to pick. | ||
* @returns {Object} Returns the new object. | ||
* @example | ||
* | ||
* const object = { 'a': 1, 'b': '2', 'c': 3 } | ||
@@ -14,2 +9,6 @@ * | ||
* // => { 'a': 1, 'c': 3 } | ||
* @category Object | ||
* @param object - The source object. | ||
* @param keys - The property paths to pick. | ||
* @returns Returns the new object. | ||
*/ | ||
@@ -16,0 +15,0 @@ |
import { splitWords } from '@helpers/stringModifiers'; | ||
/** | ||
* Converts `string` to camelCase. | ||
* | ||
* @example | ||
* camelCase('Foo Bar') | ||
* // => 'fooBar' | ||
* camelCase('--foo-bar--') | ||
* // => 'fooBar' | ||
* camelCase('__FOO_BAR__') | ||
* // => 'fooBar' | ||
* @category String | ||
* @param str - The string to convert. | ||
* @returns Returns the camel cased string. | ||
*/ | ||
export function camelCase(str: string): string { | ||
@@ -4,0 +19,0 @@ const words = splitWords(str); |
@@ -0,3 +1,14 @@ | ||
/** | ||
* Converts the first character of a string to upper case and the remaining to lower case. | ||
* | ||
* @example | ||
* capitalize('FRED') | ||
* // => 'Fred' | ||
* @category String | ||
* @param str - The string to capitalize. | ||
* @returns Returns the capitalized string. | ||
*/ | ||
export function capitalize(str: string): string { | ||
return str.charAt(0).toUpperCase() + str.slice(1); | ||
} |
@@ -0,1 +1,16 @@ | ||
/** | ||
* Deburrs a string by converting | ||
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) | ||
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) | ||
* letters to basic Latin letters and removing | ||
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). | ||
* | ||
* @example | ||
* deburr('déjà vu') | ||
* // => 'deja vu' | ||
* @category String | ||
* @param str - The string to deburr. | ||
* @returns Returns the deburred string. | ||
*/ | ||
export function deburr(str: string): string { | ||
@@ -2,0 +17,0 @@ // eslint-disable-next-line no-control-regex |
@@ -0,1 +1,12 @@ | ||
/** | ||
* Converts the characters `&`, `<`, `>`, `"` and `'` in a string to their corresponding HTML entities. | ||
* | ||
* @example | ||
* escape('fred, barney, & pebbles') | ||
* // => 'fred, barney, & pebbles' | ||
* @category String | ||
* @param str - The string to escape. | ||
* @returns Returns the escaped string. | ||
*/ | ||
export function escape(str: string): string { | ||
@@ -2,0 +13,0 @@ const escapeChars: Record<string, string> = { |
@@ -0,3 +1,15 @@ | ||
/** | ||
* Escapes the `RegExp` special characters `^`, `$`, `\`, `.`, `*`, `+`, | ||
* `?`, `(`, `)`, `[`, `]`, `{`, `}`, and `|` in a string. | ||
* | ||
* @example | ||
* escapeRegExp('[moderndash](https://moderndash.io/)') | ||
* // => '\[moderndash\]\(https://moderndash\.io/\)' | ||
* @category String | ||
* @param str - The string to escape. | ||
* @returns Returns the escaped string. | ||
*/ | ||
export function escapeRegExp(str: string): string { | ||
return str.replace(/[$()*+.?[\\\]^{|}]/g, '\\$&'); | ||
} |
import { splitWords } from '@helpers/stringModifiers'; | ||
/** | ||
* Converts a string to kebab-case. | ||
* | ||
* @example | ||
* kebabCase('Foo Bar') | ||
* // => 'foo-bar' | ||
* kebabCase('fooBar') | ||
* // => 'foo-bar' | ||
* kebabCase('__FOO_BAR__') | ||
* // => 'foo-bar' | ||
* @category String | ||
* @param str - The string to convert. | ||
* @returns Returns the kebab cased string. | ||
*/ | ||
export function kebabCase(str: string): string { | ||
@@ -4,0 +19,0 @@ const words = splitWords(str); |
import { splitWords } from '@helpers/stringModifiers'; | ||
/** | ||
* Converts a string to PascalCase. | ||
* | ||
* @example | ||
* kebabCase('Foo Bar') | ||
* // => 'FooBar' | ||
* kebabCase('fooBar') | ||
* // => 'FooBar' | ||
* kebabCase('__FOO_BAR__') | ||
* // => 'FooBar' | ||
* @category String | ||
* @param str - The string to convert. | ||
* @returns Returns the pascal cased string. | ||
*/ | ||
export function pascalCase(str: string): string { | ||
@@ -4,0 +20,0 @@ const words = splitWords(str); |
import { splitWords } from '@helpers/stringModifiers'; | ||
/** | ||
* Converts a string to snake_case. | ||
* | ||
* @example | ||
* snakeCase('Foo Bar') | ||
* // => 'foo_bar' | ||
* snakeCase('fooBar') | ||
* // => 'foo_bar' | ||
* snakeCase('--FOO-BAR--') | ||
* // => 'foo_bar' | ||
* snakeCase('foo2bar') | ||
* // => 'foo_2_bar' | ||
* @category String | ||
* @param str - The string to convert. | ||
* @returns Returns the snake cased string. | ||
*/ | ||
export function snakeCase(str: string): string { | ||
@@ -4,0 +21,0 @@ const words = splitWords(str); |
import { splitWords } from '@helpers/stringModifiers'; | ||
/** | ||
* Converts a string to Start Case. | ||
* | ||
* @example | ||
* startCase('--foo-bar--') | ||
* // => 'Foo Bar' | ||
* startCase('fooBar') | ||
* // => 'Foo Bar' | ||
* startCase('__FOO_BAR__') | ||
* // => 'Foo Bar' | ||
* @category String | ||
* @param str - The string to convert. | ||
* @returns Returns the start cased string. | ||
*/ | ||
export function startCase(str: string): string { | ||
@@ -4,0 +19,0 @@ const words = splitWords(str); |
import { deburr } from '@string/deburr'; | ||
/** | ||
* Removes all special characters from a string. | ||
* | ||
* @example | ||
* stripSpecialChars('Héllo! World #$%&*!') | ||
* // => 'Hello World' | ||
* @category String | ||
* @param str - The string to remove special characters from. | ||
* @returns Returns the string with special characters removed. | ||
*/ | ||
export function stripSpecialChars(str: string): string { | ||
@@ -4,0 +15,0 @@ str = deburr(str); |
@@ -1,2 +0,14 @@ | ||
export function unescapeHTML(html: string): string { | ||
/** | ||
* Converts the HTML entities `&`, `<`, `>`, `"` and `'` | ||
* in a string to their corresponding characters. | ||
* | ||
* @example | ||
* unescape('fred, barney, & pebbles') | ||
* // => 'fred, barney, & pebbles' | ||
* @category String | ||
* @param str - The string to unescape. | ||
* @returns Returns the unescaped string. | ||
*/ | ||
export function unescape(str: string): string { | ||
const entityMap: Record<string, string> = { | ||
@@ -9,3 +21,3 @@ '&': '&', | ||
}; | ||
return html.replace(/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g, (entity: string) => entityMap[entity] || entity); | ||
return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, (entity: string) => entityMap[entity] || entity); | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
47464
59
1307
1
0