@vanillaes/absurdum 2.0.7 → 2.0.11
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/README.md +3 -3
- package/index.d.ts +3 -3
- package/index.js +2 -0
- package/index.min.js +3 -3
- package/package.json +6 -13
- package/src/arrays/chunk.d.ts +5 -6
- package/src/arrays/chunk.js +6 -6
- package/src/arrays/compact.d.ts +4 -5
- package/src/arrays/compact.js +5 -6
- package/src/arrays/difference.d.ts +5 -6
- package/src/arrays/difference.js +6 -7
- package/src/arrays/drop.d.ts +5 -6
- package/src/arrays/drop.js +5 -6
- package/src/arrays/dropRight.d.ts +5 -6
- package/src/arrays/dropRight.js +5 -6
- package/src/arrays/fill.d.ts +6 -7
- package/src/arrays/fill.js +5 -6
- package/src/arrays/filter.d.ts +4 -5
- package/src/arrays/filter.js +5 -6
- package/src/arrays/find.d.ts +3 -4
- package/src/arrays/find.js +7 -6
- package/src/arrays/findIndex.d.ts +3 -4
- package/src/arrays/findIndex.js +3 -4
- package/src/arrays/findLastIndex.d.ts +3 -4
- package/src/arrays/findLastIndex.js +4 -5
- package/src/arrays/flat.d.ts +5 -6
- package/src/arrays/flat.js +5 -6
- package/src/arrays/frequency.d.ts +6 -5
- package/src/arrays/frequency.js +8 -7
- package/src/arrays/intersection.d.ts +5 -6
- package/src/arrays/intersection.js +7 -6
- package/src/arrays/map.d.ts +4 -5
- package/src/arrays/map.js +5 -6
- package/src/arrays/pull.d.ts +4 -5
- package/src/arrays/pull.js +5 -6
- package/src/arrays/take.d.ts +5 -6
- package/src/arrays/take.js +5 -6
- package/src/arrays/takeRight.d.ts +5 -6
- package/src/arrays/takeRight.js +5 -6
- package/src/arrays/union.d.ts +4 -5
- package/src/arrays/union.js +4 -5
- package/src/arrays/unique.d.ts +4 -5
- package/src/arrays/unique.js +4 -5
- package/src/arrays/unzip.d.ts +4 -5
- package/src/arrays/unzip.js +6 -5
- package/src/arrays/without.d.ts +4 -4
- package/src/arrays/without.js +5 -6
- package/src/arrays/xor.d.ts +4 -5
- package/src/arrays/xor.js +5 -6
- package/src/arrays/zip.d.ts +6 -7
- package/src/arrays/zip.js +7 -8
- package/src/objects/assign.d.ts +1 -3
- package/src/objects/assign.js +3 -3
- package/src/objects/at.d.ts +2 -4
- package/src/objects/at.js +3 -3
- package/src/objects/defaults.d.ts +1 -3
- package/src/objects/defaults.js +3 -3
- package/src/objects/defaultsDeep.d.ts +1 -3
- package/src/objects/defaultsDeep.js +3 -3
- package/src/objects/entries.d.ts +1 -3
- package/src/objects/entries.js +3 -3
- package/src/objects/filter.d.ts +3 -5
- package/src/objects/filter.js +2 -3
- package/src/objects/findKey.d.ts +2 -4
- package/src/objects/findKey.js +2 -3
- package/src/objects/findLastKey.d.ts +2 -4
- package/src/objects/findLastKey.js +2 -3
- package/src/objects/forIn.d.ts +3 -5
- package/src/objects/forIn.js +3 -4
- package/src/objects/fromEntries.d.ts +1 -3
- package/src/objects/fromEntries.js +3 -3
- package/src/objects/get.d.ts +1 -4
- package/src/objects/get.js +2 -3
- package/src/objects/has.d.ts +1 -4
- package/src/objects/has.js +3 -3
- package/src/objects/invert.d.ts +1 -3
- package/src/objects/invert.js +3 -3
- package/src/objects/mapKeys.d.ts +3 -5
- package/src/objects/mapKeys.js +2 -3
- package/src/objects/mapValues.d.ts +3 -5
- package/src/objects/mapValues.js +2 -3
- package/src/objects/merge.d.ts +1 -3
- package/src/objects/merge.js +3 -3
- package/src/objects/pick.d.ts +1 -3
- package/src/objects/pick.js +3 -3
- package/src/objects/result.d.ts +1 -4
- package/src/objects/result.js +2 -3
- package/src/objects/transform.d.ts +3 -5
- package/src/objects/transform.js +2 -3
- package/src/objects/values.d.ts +2 -4
- package/src/objects/values.js +3 -3
- package/src/strings/camelCase.d.ts +2 -4
- package/src/strings/camelCase.js +2 -4
- package/src/strings/chomp.d.ts +1 -4
- package/src/strings/chomp.js +1 -3
- package/src/strings/deburr.d.ts +2 -4
- package/src/strings/deburr.js +3 -4
- package/src/strings/endsWith.d.ts +1 -4
- package/src/strings/endsWith.js +3 -3
- package/src/strings/includes.d.ts +1 -3
- package/src/strings/includes.js +1 -3
- package/src/strings/kebabCase.d.ts +2 -4
- package/src/strings/kebabCase.js +2 -4
- package/src/strings/pad.d.ts +2 -6
- package/src/strings/pad.js +1 -3
- package/src/strings/padEnd.d.ts +2 -6
- package/src/strings/padEnd.js +2 -4
- package/src/strings/padStart.d.ts +2 -6
- package/src/strings/padStart.js +2 -4
- package/src/strings/pascalCase.d.ts +2 -4
- package/src/strings/pascalCase.js +2 -4
- package/src/strings/repeat.d.ts +1 -3
- package/src/strings/repeat.js +1 -3
- package/src/strings/reverse.d.ts +0 -2
- package/src/strings/reverse.js +1 -3
- package/src/strings/snakeCase.d.ts +2 -4
- package/src/strings/snakeCase.js +2 -4
- package/src/strings/startsWith.d.ts +0 -3
- package/src/strings/startsWith.js +3 -3
- package/src/strings/trimEnd.d.ts +3 -5
- package/src/strings/trimEnd.js +2 -4
- package/src/strings/trimStart.d.ts +3 -5
- package/src/strings/trimStart.js +2 -4
- package/src/strings/truncate.d.ts +9 -11
- package/src/strings/truncate.js +3 -5
- package/src/strings/words.d.ts +3 -7
- package/src/strings/words.js +3 -5
package/src/objects/pick.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pick returns a new object composed from the selected object properties.
|
|
3
|
-
*
|
|
4
3
|
* @param {object} object input object
|
|
5
4
|
* @param {...(string|string[])} paths paths names of properties to be returned from an object
|
|
6
5
|
* @returns {object} object with selected properties
|
|
7
|
-
*
|
|
8
6
|
* @example
|
|
9
7
|
* const result = Objects.pick({ a: 'mixed', b34: 'toast', 45: 'pasta' }, 'a', 45);
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* > { 45: 'pasta', a: 'mixed' }
|
|
12
10
|
*/
|
|
13
|
-
export function pick(object:
|
|
11
|
+
export function pick(object: object, ...paths: (string | string[])[]): object;
|
package/src/objects/pick.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-nocheck TODO: Fix types on this late
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Pick returns a new object composed from the selected object properties.
|
|
3
5
|
* @param {object} object input object
|
|
@@ -8,7 +10,7 @@
|
|
|
8
10
|
* console.log(result);
|
|
9
11
|
* > { 45: 'pasta', a: 'mixed' }
|
|
10
12
|
*/
|
|
11
|
-
function pick (object, ...paths) {
|
|
13
|
+
export function pick (object, ...paths) {
|
|
12
14
|
if (paths.length === 0) { return {} }
|
|
13
15
|
const args = new Set()
|
|
14
16
|
|
|
@@ -23,5 +25,3 @@ function pick (object, ...paths) {
|
|
|
23
25
|
return acc
|
|
24
26
|
}, {})
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
export { pick }
|
package/src/objects/result.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Result, creates an array of values corresponding to paths of the object. If value is a function, returns result of calling function
|
|
3
|
-
*
|
|
4
3
|
* @param {object} object input object
|
|
5
4
|
* @param {Array|string} path string or an array of strings describing paths to be returned from an object
|
|
6
5
|
* @param {*} [defaultValue] value returned when path resolves undefined
|
|
7
6
|
* @returns {*} value found by object paths in object, or returns defaultValue if provided and return would otherwise be undefined
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* const obj = { front: [1, 3, 5], back: [() => 15, () => 19] };
|
|
11
9
|
* console.log(objects.result(obj, 'back[1]'));
|
|
12
10
|
* > 19
|
|
13
|
-
*
|
|
14
11
|
* @example
|
|
15
12
|
* const obj = { front: [1, 3, 5], back: [37, 39] };
|
|
16
13
|
* const func = (x) => { return x+7; }
|
|
17
14
|
* console.log(objects.result(obj, ['front', 5], func(3)));
|
|
18
15
|
* > 10
|
|
19
16
|
*/
|
|
20
|
-
export function result(object:
|
|
17
|
+
export function result(object: object, path: any[] | string, defaultValue?: any): any;
|
package/src/objects/result.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable jsdoc/reject-any-type */
|
|
2
|
+
// @ts-nocheck TODO: Fix types on this late
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Result, creates an array of values corresponding to paths of the object. If value is a function, returns result of calling function
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
* console.log(objects.result(obj, ['front', 5], func(3)));
|
|
17
18
|
* > 10
|
|
18
19
|
*/
|
|
19
|
-
function result (object, path, defaultValue) {
|
|
20
|
+
export function result (object, path, defaultValue) {
|
|
20
21
|
if (typeof path === 'undefined') { return undefined }
|
|
21
22
|
let pathArray
|
|
22
23
|
|
|
@@ -41,5 +42,3 @@ function result (object, path, defaultValue) {
|
|
|
41
42
|
return typeof defaultValue === 'function' ? defaultValue() : defaultValue
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
export { result }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Transform works like reduce, except the accumulator is implicitly returned
|
|
3
|
-
*
|
|
4
3
|
* @param {object} object input object
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {object|Array} [accumulator
|
|
4
|
+
* @param {Function} func iteratee function
|
|
5
|
+
* @param {object|Array} [accumulator] custom accumulator object (default {})
|
|
7
6
|
* @returns {object|Array} returns accumulator object after the input object has been iterated over by the function.
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* const result = objects.transform({ harmony: 2, daft: 4, stripes: 6 }, function(acc, val, key) {
|
|
11
9
|
* acc[key] = val + 5 + '_' + idx;
|
|
@@ -13,4 +11,4 @@
|
|
|
13
11
|
* console.log(result);
|
|
14
12
|
* > { harmony: '7_0', daft: '9_1', stripes: '11_2' }
|
|
15
13
|
*/
|
|
16
|
-
export function transform(object:
|
|
14
|
+
export function transform(object: object, func: Function, accumulator?: object | any[]): object | any[];
|
package/src/objects/transform.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable jsdoc/reject-function-type */
|
|
2
|
+
// @ts-nocheck TODO: Fix types on this late
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Transform works like reduce, except the accumulator is implicitly returned
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
* console.log(result);
|
|
14
15
|
* > { harmony: '7_0', daft: '9_1', stripes: '11_2' }
|
|
15
16
|
*/
|
|
16
|
-
function transform (object, func, accumulator = {}) {
|
|
17
|
+
export function transform (object, func, accumulator = {}) {
|
|
17
18
|
if (typeof func === 'undefined') { return object }
|
|
18
19
|
|
|
19
20
|
return Object.keys(object).reduce((acc, key) => {
|
|
@@ -21,5 +22,3 @@ function transform (object, func, accumulator = {}) {
|
|
|
21
22
|
return acc
|
|
22
23
|
}, accumulator)
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
export { transform }
|
package/src/objects/values.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Values is an alias for Object.values returns an array of all values in an object
|
|
3
|
-
*
|
|
4
3
|
* @param {object} object input object
|
|
5
|
-
* @returns {
|
|
6
|
-
*
|
|
4
|
+
* @returns {Array} returns an array of all values in an object
|
|
7
5
|
* @example
|
|
8
6
|
* const result = objects.values({ hold: 25, your: 19, horses: 4 });
|
|
9
7
|
* console.log(result);
|
|
10
8
|
* > [25, 19, 4]
|
|
11
9
|
*/
|
|
12
|
-
export function values(object:
|
|
10
|
+
export function values(object: object): any[];
|
package/src/objects/values.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-nocheck TODO: Fix types on this late
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Values is an alias for Object.values returns an array of all values in an object
|
|
3
5
|
* @param {object} object input object
|
|
@@ -7,11 +9,9 @@
|
|
|
7
9
|
* console.log(result);
|
|
8
10
|
* > [25, 19, 4]
|
|
9
11
|
*/
|
|
10
|
-
function values (object) {
|
|
12
|
+
export function values (object) {
|
|
11
13
|
return Object.keys(object).reduce((acc, key) => {
|
|
12
14
|
acc.push(object[key])
|
|
13
15
|
return acc
|
|
14
16
|
}, [])
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
export { values }
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* camelCase updates a string to camelcase
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [string] input string
|
|
3
|
+
* @param {string} string input string
|
|
5
4
|
* @returns {string} returns new camelCase string
|
|
6
|
-
*
|
|
7
5
|
* @example
|
|
8
6
|
* const result = strings.camelCase('--BEST_friend--');
|
|
9
7
|
* console.log(result);
|
|
10
8
|
* > 'bestFriend'
|
|
11
9
|
*/
|
|
12
|
-
export function camelCase(string
|
|
10
|
+
export function camelCase(string: string): string;
|
package/src/strings/camelCase.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* camelCase updates a string to camelcase
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @returns {string} returns new camelCase string
|
|
5
5
|
* @example
|
|
6
6
|
* const result = strings.camelCase('--BEST_friend--');
|
|
7
7
|
* console.log(result);
|
|
8
8
|
* > 'bestFriend'
|
|
9
9
|
*/
|
|
10
|
-
function camelCase (string) {
|
|
10
|
+
export function camelCase (string) {
|
|
11
11
|
let first = true
|
|
12
12
|
const res = string.replace(/[\u2019']/, '').split(/[\u002D\u2014\-_\s]+/).reduce((acc, word) => {
|
|
13
13
|
if (first && word.length > 0) {
|
|
@@ -20,5 +20,3 @@ function camelCase (string) {
|
|
|
20
20
|
}, '')
|
|
21
21
|
return res
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
export { camelCase }
|
package/src/strings/chomp.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Chomp removes record separator characters (ex \n, \r, \r\n) from the end of a string.
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
|
-
* @param {string} [separator
|
|
4
|
+
* @param {string} [separator] separator removed from end of string (default '\r' | '\n' | '\r\n')
|
|
6
5
|
* @returns {string} does the input end with the substring?
|
|
7
|
-
*
|
|
8
6
|
* @example
|
|
9
7
|
* const result = strings.chomp('Goldy\n\r\n');
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* > 'Goldy\n'
|
|
12
|
-
*
|
|
13
10
|
* @example
|
|
14
11
|
* const result = strings.chomp('Sauce', 'ce');
|
|
15
12
|
* console.log(result);
|
package/src/strings/chomp.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* console.log(result);
|
|
13
13
|
* > 'Sau'
|
|
14
14
|
*/
|
|
15
|
-
function chomp (string, separator) {
|
|
15
|
+
export function chomp (string, separator) {
|
|
16
16
|
const res = string.split('')
|
|
17
17
|
let windows = false
|
|
18
18
|
if (separator === undefined) {
|
|
@@ -64,5 +64,3 @@ function chomp (string, separator) {
|
|
|
64
64
|
}, '')
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
export { chomp }
|
package/src/strings/deburr.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deburrs string by converting all complex Latin characters to basic Latin letters in a string.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [string] input string
|
|
3
|
+
* @param {string} string input string
|
|
5
4
|
* @returns {string} returns simplified string
|
|
6
|
-
*
|
|
7
5
|
* @example
|
|
8
6
|
* const result = strings.deburr('_ŁŐúnged\ufe2f_');
|
|
9
7
|
* console.log(result);
|
|
10
8
|
* > '_LOunged_'
|
|
11
9
|
*/
|
|
12
|
-
export function deburr(string
|
|
10
|
+
export function deburr(string: string): string;
|
package/src/strings/deburr.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deburrs string by converting all complex Latin characters to basic Latin letters in a string.
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @returns {string} returns simplified string
|
|
5
5
|
* @example
|
|
6
6
|
* const result = strings.deburr('_ŁŐúnged\ufe2f_');
|
|
7
7
|
* console.log(result);
|
|
8
8
|
* > '_LOunged_'
|
|
9
9
|
*/
|
|
10
|
-
function deburr (string) {
|
|
10
|
+
export function deburr (string) {
|
|
11
11
|
let result = ''
|
|
12
12
|
const found = string.match(latinRegex)
|
|
13
13
|
if (found) {
|
|
14
14
|
result = found.reduce((res, curr) => {
|
|
15
15
|
if (curr.length === 1) {
|
|
16
|
+
// @ts-ignore
|
|
16
17
|
return Object.prototype.hasOwnProperty.call(latinMap, curr) ? res + latinMap[curr] : res + curr
|
|
17
18
|
} else {
|
|
18
19
|
return res + curr
|
|
@@ -30,5 +31,3 @@ const diacriticalMarks = /[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\u1ab0-\u1aff\
|
|
|
30
31
|
const chars = 'ÀÁÂÃÄÅàáâãäåÇçÐðÈÉÊËèéêëÌÍÎÏìíîïÑñÒÓÔÕÖØòóôõöøÙÚÛÜùúûüÝýÿÆæÞþßĀĂĄāăąĆĈĊČćĉċčĎĐďđĒĔĖĘĚēĕėęěĜĞĠĢĝğġģĤĦĥħĨĪĬĮİĩīĭįıĴĵĶķĸĹĻĽĿŁĺļľŀłŃŅŇŊńņňŋŌŎŐōŏőŔŖŘŕŗřŚŜŞŠśŝşšŢŤŦţťŧŨŪŬŮŰŲũūŭůűųŴŵŶŷŸŹŻŽźżžIJijŒœʼnſ'
|
|
31
32
|
const latinRegex = new RegExp('[' + chars + ']|[^' + chars + ']+', 'g')
|
|
32
33
|
const latinMap = { À: 'A', Á: 'A', Â: 'A', Ã: 'A', Ä: 'A', Å: 'A', à: 'a', á: 'a', â: 'a', ã: 'a', ä: 'a', å: 'a', Ç: 'C', ç: 'c', Ð: 'D', ð: 'd', È: 'E', É: 'E', Ê: 'E', Ë: 'E', è: 'e', é: 'e', ê: 'e', ë: 'e', Ì: 'I', Í: 'I', Î: 'I', Ï: 'I', ì: 'i', í: 'i', î: 'i', ï: 'i', Ñ: 'N', ñ: 'n', Ò: 'O', Ó: 'O', Ô: 'O', Õ: 'O', Ö: 'O', Ø: 'O', ò: 'o', ó: 'o', ô: 'o', õ: 'o', ö: 'o', ø: 'o', Ù: 'U', Ú: 'U', Û: 'U', Ü: 'U', ù: 'u', ú: 'u', û: 'u', ü: 'u', Ý: 'Y', ý: 'y', ÿ: 'y', Æ: 'Ae', æ: 'ae', Þ: 'Th', þ: 'th', ß: 'ss', Ā: 'A', Ă: 'A', Ą: 'A', ā: 'a', ă: 'a', ą: 'a', Ć: 'C', Ĉ: 'C', Ċ: 'C', Č: 'C', ć: 'c', ĉ: 'c', ċ: 'c', č: 'c', Ď: 'D', Đ: 'D', ď: 'd', đ: 'd', Ē: 'E', Ĕ: 'E', Ė: 'E', Ę: 'E', Ě: 'E', ē: 'e', ĕ: 'e', ė: 'e', ę: 'e', ě: 'e', Ĝ: 'G', Ğ: 'G', Ġ: 'G', Ģ: 'G', ĝ: 'g', ğ: 'g', ġ: 'g', ģ: 'g', Ĥ: 'H', Ħ: 'H', ĥ: 'h', ħ: 'h', Ĩ: 'I', Ī: 'I', Ĭ: 'I', Į: 'I', İ: 'I', ĩ: 'i', ī: 'i', ĭ: 'i', į: 'i', ı: 'i', Ĵ: 'J', ĵ: 'j', Ķ: 'K', ķ: 'k', ĸ: 'k', Ĺ: 'L', Ļ: 'L', Ľ: 'L', Ŀ: 'L', Ł: 'L', ĺ: 'l', ļ: 'l', ľ: 'l', ŀ: 'l', ł: 'l', Ń: 'N', Ņ: 'N', Ň: 'N', Ŋ: 'N', ń: 'n', ņ: 'n', ň: 'n', ŋ: 'n', Ō: 'O', Ŏ: 'O', Ő: 'O', ō: 'o', ŏ: 'o', ő: 'o', Ŕ: 'R', Ŗ: 'R', Ř: 'R', ŕ: 'r', ŗ: 'r', ř: 'r', Ś: 'S', Ŝ: 'S', Ş: 'S', Š: 'S', ś: 's', ŝ: 's', ş: 's', š: 's', Ţ: 'T', Ť: 'T', Ŧ: 'T', ţ: 't', ť: 't', ŧ: 't', Ũ: 'U', Ū: 'U', Ŭ: 'U', Ů: 'U', Ű: 'U', Ų: 'U', ũ: 'u', ū: 'u', ŭ: 'u', ů: 'u', ű: 'u', ų: 'u', Ŵ: 'W', ŵ: 'w', Ŷ: 'Y', ŷ: 'y', Ÿ: 'Y', Ź: 'Z', Ż: 'Z', Ž: 'Z', ź: 'z', ż: 'z', ž: 'z', IJ: 'IJ', ij: 'ij', Œ: 'Oe', œ: 'oe', ʼn: "'n", ſ: 's' }
|
|
33
|
-
|
|
34
|
-
export { deburr }
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tests a string to see if it ends with a substring
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
|
-
* @param {string} [substr
|
|
4
|
+
* @param {string} [substr] substring to test (default '')
|
|
6
5
|
* @returns {boolean} does the input end with the substring?
|
|
7
|
-
*
|
|
8
6
|
* @example
|
|
9
7
|
* const result = strings.endsWith('This sentence ends with', 'with');
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* > true
|
|
12
|
-
*
|
|
13
10
|
* @example
|
|
14
11
|
* const result = strings.endsWith('This sentence does not end with', 'nope');
|
|
15
12
|
* console.log(result);
|
package/src/strings/endsWith.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-nocheck TODO: Fix types on this later
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Tests a string to see if it ends with a substring
|
|
3
5
|
* @param {string} string input string
|
|
@@ -12,7 +14,7 @@
|
|
|
12
14
|
* console.log(result);
|
|
13
15
|
* > false
|
|
14
16
|
*/
|
|
15
|
-
function endsWith (string, substr = '') {
|
|
17
|
+
export function endsWith (string, substr = '') {
|
|
16
18
|
const reducer = (acc, _, idx, arr) => {
|
|
17
19
|
// exit early on mismatch
|
|
18
20
|
if (arr[arr.length - idx - 1] !== substr[substr.length - idx - 1]) {
|
|
@@ -29,5 +31,3 @@ function endsWith (string, substr = '') {
|
|
|
29
31
|
|
|
30
32
|
return string.split('').reduce(reducer, null)
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
export { endsWith }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Includes determines whether one string can be found in another string
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
4
|
* @param {string} substr candidate string to be searched for
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {number} start index to begin search for string
|
|
7
6
|
* @returns {boolean} does the input string include the substring?
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* const result = strings.includes('This Lovely Life', 'Love');
|
|
11
9
|
* console.log(result);
|
package/src/strings/includes.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* console.log(result);
|
|
14
14
|
* > false
|
|
15
15
|
*/
|
|
16
|
-
function includes (string, substr, start = 0) {
|
|
16
|
+
export function includes (string, substr, start = 0) {
|
|
17
17
|
if (string.length === 0) return false
|
|
18
18
|
const len = substr.length
|
|
19
19
|
const first = substr.charAt(0)
|
|
@@ -29,5 +29,3 @@ function includes (string, substr, start = 0) {
|
|
|
29
29
|
return false
|
|
30
30
|
}, false)
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
export { includes }
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* kebabCase updates a string to kebabcase
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [string] input string
|
|
3
|
+
* @param {string} string input string
|
|
5
4
|
* @returns {string} returns new kebabCase string
|
|
6
|
-
*
|
|
7
5
|
* @example
|
|
8
6
|
* const result = strings.kebabCase('css classes use kebab case');
|
|
9
7
|
* console.log(result);
|
|
10
8
|
* > 'css-classes-use-kebab-case'
|
|
11
9
|
*/
|
|
12
|
-
export function kebabCase(string
|
|
10
|
+
export function kebabCase(string: string): string;
|
package/src/strings/kebabCase.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* kebabCase updates a string to kebabcase
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @returns {string} returns new kebabCase string
|
|
5
5
|
* @example
|
|
6
6
|
* const result = strings.kebabCase('css classes use kebab case');
|
|
7
7
|
* console.log(result);
|
|
8
8
|
* > 'css-classes-use-kebab-case'
|
|
9
9
|
*/
|
|
10
|
-
function kebabCase (string) {
|
|
10
|
+
export function kebabCase (string) {
|
|
11
11
|
let first = true
|
|
12
12
|
return string.replace(/[\u2019']/, '').split(/[\u002D\u2014\-_\s]+/).reduce((acc, word) => {
|
|
13
13
|
if (word.length > 0) {
|
|
@@ -21,5 +21,3 @@ function kebabCase (string) {
|
|
|
21
21
|
return acc
|
|
22
22
|
}, '')
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
export { kebabCase }
|
package/src/strings/pad.d.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pads the both ends of a string w/ repeated spaces|substrings
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
|
-
* @param {number} [length
|
|
6
|
-
* @param {string} [substr
|
|
4
|
+
* @param {number} [length] length of the padded portion (default 0)
|
|
5
|
+
* @param {string} [substr] substring to apply (default ' ')
|
|
7
6
|
* @returns {string} the input padded w/ spaces|substrings
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* // if no `substr` is provided, it pads the string w/ spaces
|
|
11
9
|
* const result = strings.pad('xyzxyz', 9);
|
|
12
10
|
* console.log(result);
|
|
13
11
|
* > ' xyzxyz '
|
|
14
|
-
*
|
|
15
12
|
* @example
|
|
16
13
|
* // if `length` is shorter than `string` it doesn't add any padding
|
|
17
14
|
* const result = strings.pad('xyzxyz', 4);
|
|
18
15
|
* console.log(result);
|
|
19
16
|
* > 'xyzxyz'
|
|
20
|
-
*
|
|
21
17
|
* @example
|
|
22
18
|
* // if `substr` is defined, it uses that for padding
|
|
23
19
|
* const result = strings.pad('xyzxyz', 16, 'FUN');
|
package/src/strings/pad.js
CHANGED
|
@@ -20,10 +20,8 @@
|
|
|
20
20
|
* console.log(result);
|
|
21
21
|
* > 'FUNFUxyzxyzFUNFU'
|
|
22
22
|
*/
|
|
23
|
-
function pad (string, length = 0, substr = ' ') {
|
|
23
|
+
export function pad (string, length = 0, substr = ' ') {
|
|
24
24
|
const strLen = string.length
|
|
25
25
|
const padLen = (length - strLen) > 0 ? Math.ceil((length - strLen) / 2) : 0
|
|
26
26
|
return string.padStart(length - padLen, substr).padEnd(length, substr)
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
export { pad }
|
package/src/strings/padEnd.d.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pads the end of a string w/ repeated spaces|substrings
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
|
-
* @param {number} [length
|
|
6
|
-
* @param {string} [substr
|
|
4
|
+
* @param {number} [length] length of the padded portion (default 0)
|
|
5
|
+
* @param {string} [substr] substring to apply (default ' ')
|
|
7
6
|
* @returns {string} the input padded w/ spaces|substrings
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* // if no `substr` is provided, it pads the string w/ spaces
|
|
11
9
|
* const result = strings.padEnd('abcabc', 9);
|
|
12
10
|
* console.log(result);
|
|
13
11
|
* > abcabc
|
|
14
|
-
*
|
|
15
12
|
* @example
|
|
16
13
|
* // if `length` is shorter than `string` it doesn't add any padding
|
|
17
14
|
* const result = strings.padEnd('abcabc', 4);
|
|
18
15
|
* console.log(result);
|
|
19
16
|
* > abcabc
|
|
20
|
-
*
|
|
21
17
|
* @example
|
|
22
18
|
* // if `substr` is defined, it uses that for padding
|
|
23
19
|
* const result = strings.padEnd('abcabc', 16, 'fun');
|
package/src/strings/padEnd.js
CHANGED
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
* console.log(result);
|
|
21
21
|
* > 'abcabcfunfunfunf'
|
|
22
22
|
*/
|
|
23
|
-
function padEnd (string, length = 0, substr = ' ') {
|
|
23
|
+
export function padEnd (string, length = 0, substr = ' ') {
|
|
24
24
|
let strLen = string.length
|
|
25
25
|
const padLen = (length - string.length) > 0 ? length - string.length : 0
|
|
26
26
|
let substrIdx = 0
|
|
27
27
|
const stringArr = [...string, ...Array(padLen)]
|
|
28
28
|
|
|
29
|
-
const reducer = (acc, curr) => {
|
|
29
|
+
const reducer = (/** @type {string[]} */ acc, /** @type {string} */ curr) => {
|
|
30
30
|
if (strLen !== 0) {
|
|
31
31
|
acc.push(curr)
|
|
32
32
|
strLen--
|
|
@@ -39,5 +39,3 @@ function padEnd (string, length = 0, substr = ' ') {
|
|
|
39
39
|
|
|
40
40
|
return stringArr.reduce(reducer, []).join('')
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
export { padEnd }
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PadStart pads the start of of a string.
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
|
-
* @param {number} [length
|
|
6
|
-
* @param {string} [substr
|
|
4
|
+
* @param {number} [length] length of the padded portion (default 0)
|
|
5
|
+
* @param {string} [substr] substring to apply (default ' ')
|
|
7
6
|
* @returns {string} the input padded w/ spaces|substrings
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* // if no `substr` is provided, it pads the string w/ spaces
|
|
11
9
|
* const result = strings.padStart('abcabc', 9);
|
|
12
10
|
* console.log(result);
|
|
13
11
|
* > abcabc
|
|
14
|
-
*
|
|
15
12
|
* @example
|
|
16
13
|
* // if `length` is shorter than `string` it doesn't add any padding
|
|
17
14
|
* const result = strings.padStart('abcabc', 4);
|
|
18
15
|
* console.log(result);
|
|
19
16
|
* > abcabc
|
|
20
|
-
*
|
|
21
17
|
* @example
|
|
22
18
|
* // if `substr` is defined, it uses that for padding
|
|
23
19
|
* const result = strings.padStart('abcabc', 16, 'fun');
|
package/src/strings/padStart.js
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
* console.log(result);
|
|
21
21
|
* > 'funfunfunfabcabc'
|
|
22
22
|
*/
|
|
23
|
-
function padStart (string, length = 0, substr = ' ') {
|
|
23
|
+
export function padStart (string, length = 0, substr = ' ') {
|
|
24
24
|
let padLen = (length - string.length) > 0 ? length - string.length : 0
|
|
25
25
|
let substrIdx = 0
|
|
26
26
|
const stringArr = [...Array(padLen), ...string]
|
|
27
27
|
|
|
28
|
-
const reducer = (acc, curr) => {
|
|
28
|
+
const reducer = (/** @type {string[]} */ acc, /** @type {string} */ curr) => {
|
|
29
29
|
if (padLen !== 0) {
|
|
30
30
|
acc.push(substr[substrIdx])
|
|
31
31
|
substrIdx = (substrIdx + 1 < substr.length) ? substrIdx + 1 : 0
|
|
@@ -38,5 +38,3 @@ function padStart (string, length = 0, substr = ' ') {
|
|
|
38
38
|
|
|
39
39
|
return stringArr.reduce(reducer, []).join('')
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export { padStart }
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* pascalCase updates a string to pascalCase
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [string] input string
|
|
3
|
+
* @param {string} string input string
|
|
5
4
|
* @returns {string} returns new pascalCase string
|
|
6
|
-
*
|
|
7
5
|
* @example
|
|
8
6
|
* const result = strings.pascalCase('classes use pascal case');
|
|
9
7
|
* console.log(result);
|
|
10
8
|
* > 'ClassesUsePascalCase'
|
|
11
9
|
*/
|
|
12
|
-
export function pascalCase(string
|
|
10
|
+
export function pascalCase(string: string): string;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* pascalCase updates a string to pascalCase
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @returns {string} returns new pascalCase string
|
|
5
5
|
* @example
|
|
6
6
|
* const result = strings.pascalCase('classes use pascal case');
|
|
7
7
|
* console.log(result);
|
|
8
8
|
* > 'ClassesUsePascalCase'
|
|
9
9
|
*/
|
|
10
|
-
function pascalCase (string) {
|
|
10
|
+
export function pascalCase (string) {
|
|
11
11
|
const res = string.replace(/[\u2019']/, '').split(/[\u002D\u2014\-_\s]+/).reduce((acc, word) => {
|
|
12
12
|
return acc + word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
13
13
|
}, '')
|
|
14
14
|
return res
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
export { pascalCase }
|
package/src/strings/repeat.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Repeat returns a new string containing the provided string copied and concatenated
|
|
3
3
|
* for the number of times given in the parameter
|
|
4
|
-
*
|
|
5
4
|
* @param {string} string input string
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {number} count number of times to repeat the string
|
|
7
6
|
* @returns {string} string containing the specified number of copies of the given string
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* const result = strings.repeat('Moo', 3);
|
|
11
9
|
* console.log(result);
|
package/src/strings/repeat.js
CHANGED
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
* console.log(result);
|
|
10
10
|
* > 'Moo Moo Moo '
|
|
11
11
|
*/
|
|
12
|
-
function repeat (string, count = 0) {
|
|
12
|
+
export function repeat (string, count = 0) {
|
|
13
13
|
if (string.length === 0 || count < 1) return ''
|
|
14
14
|
|
|
15
15
|
return new Array(count).fill('').reduce((res) => {
|
|
16
16
|
return res + string
|
|
17
17
|
}, '')
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
export { repeat }
|
package/src/strings/reverse.d.ts
CHANGED
package/src/strings/reverse.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* snakeCase updates a string to snakecase
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [string] input string
|
|
3
|
+
* @param {string} string input string
|
|
5
4
|
* @returns {string} returns new snakeCase string
|
|
6
|
-
*
|
|
7
5
|
* @example
|
|
8
6
|
* const result = strings.snakeCase('--BEST--friend--');
|
|
9
7
|
* console.log(result);
|
|
10
8
|
* > 'best_friend'
|
|
11
9
|
*/
|
|
12
|
-
export function snakeCase(string
|
|
10
|
+
export function snakeCase(string: string): string;
|
package/src/strings/snakeCase.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* snakeCase updates a string to snakecase
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @returns {string} returns new snakeCase string
|
|
5
5
|
* @example
|
|
6
6
|
* const result = strings.snakeCase('--BEST--friend--');
|
|
7
7
|
* console.log(result);
|
|
8
8
|
* > 'best_friend'
|
|
9
9
|
*/
|
|
10
|
-
function snakeCase (string) {
|
|
10
|
+
export function snakeCase (string) {
|
|
11
11
|
let first = true
|
|
12
12
|
return string.replace(/[\u2019']/, '').split(/[\u002D\u2014\-_\s]+/).reduce((acc, word) => {
|
|
13
13
|
if (word.length > 0) {
|
|
@@ -21,5 +21,3 @@ function snakeCase (string) {
|
|
|
21
21
|
return acc
|
|
22
22
|
}, '')
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
export { snakeCase }
|