@vanillaes/absurdum 2.0.6 → 2.0.10
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 +16 -17
- 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
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* StartsWith tests a string to see if it starts with a substring
|
|
3
|
-
*
|
|
4
3
|
* @param {string} string input string
|
|
5
4
|
* @param {string} substr substring to test
|
|
6
5
|
* @returns {boolean} does the input start with the substring?
|
|
7
|
-
*
|
|
8
6
|
* @example
|
|
9
7
|
* const result = strings.startsWith('This sentence starts with', 'This');
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* > true
|
|
12
|
-
*
|
|
13
10
|
* @example
|
|
14
11
|
* const result = strings.startsWith('This sentence does not start with', 'Nope');
|
|
15
12
|
* console.log(result);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-nocheck TODO: Fix types on this late
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* StartsWith tests a string to see if it starts 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 startsWith (string, substr) {
|
|
17
|
+
export function startsWith (string, substr) {
|
|
16
18
|
let chars = string.split('')
|
|
17
19
|
|
|
18
20
|
const reducer = (acc, curr, idx, arr) => {
|
|
@@ -31,5 +33,3 @@ function startsWith (string, substr) {
|
|
|
31
33
|
|
|
32
34
|
return chars.reduce(reducer, null)
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
export { startsWith }
|
package/src/strings/trimEnd.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TrimEnd trims any whitespace or the selected characters from the end of the string
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [
|
|
5
|
-
* @param {string} [chars=' '] characters to remove from end of the string
|
|
3
|
+
* @param {string} string input string
|
|
4
|
+
* @param {string} [chars] characters to remove from end of the string (default ' ')
|
|
6
5
|
* @returns {string} string with the characters removed from end of the string
|
|
7
|
-
*
|
|
8
6
|
* @example
|
|
9
7
|
* const result = strings.trimEnd('-_-abc-_-', '_-');
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* > '-_-abc'
|
|
12
10
|
*/
|
|
13
|
-
export function trimEnd(string
|
|
11
|
+
export function trimEnd(string: string, chars?: string): string;
|
package/src/strings/trimEnd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TrimEnd trims any whitespace or the selected characters from the end of the string
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @param {string} [chars] characters to remove from end of the string (default ' ')
|
|
5
5
|
* @returns {string} string with the characters removed from end of the string
|
|
6
6
|
* @example
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* console.log(result);
|
|
9
9
|
* > '-_-abc'
|
|
10
10
|
*/
|
|
11
|
-
function trimEnd (string, chars = ' ') {
|
|
11
|
+
export function trimEnd (string, chars = ' ') {
|
|
12
12
|
const testChars = new Set([...chars])
|
|
13
13
|
let end = true
|
|
14
14
|
return [...string].reduceRight((acc, curr) => {
|
|
@@ -24,5 +24,3 @@ function trimEnd (string, chars = ' ') {
|
|
|
24
24
|
}
|
|
25
25
|
}, '')
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
export { trimEnd }
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TrimStart trims any whitespace or the selected characters from the beginning of the string
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [
|
|
5
|
-
* @param {string} [chars=' '] characters to remove from beginning of string
|
|
3
|
+
* @param {string} string input string
|
|
4
|
+
* @param {string} [chars] characters to remove from beginning of string (default ' ')
|
|
6
5
|
* @returns {string} string with the characters removed from beginning
|
|
7
|
-
*
|
|
8
6
|
* @example
|
|
9
7
|
* const result = strings.trimStart('-_-abc-_-', '_-');
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* > 'abc-_-'
|
|
12
10
|
*/
|
|
13
|
-
export function trimStart(string
|
|
11
|
+
export function trimStart(string: string, chars?: string): string;
|
package/src/strings/trimStart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TrimStart trims any whitespace or the selected characters from the beginning of the string
|
|
3
|
-
* @param {string}
|
|
3
|
+
* @param {string} string input string
|
|
4
4
|
* @param {string} [chars] characters to remove from beginning of string (default ' ')
|
|
5
5
|
* @returns {string} string with the characters removed from beginning
|
|
6
6
|
* @example
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* console.log(result);
|
|
9
9
|
* > 'abc-_-'
|
|
10
10
|
*/
|
|
11
|
-
function trimStart (string, chars = ' ') {
|
|
11
|
+
export function trimStart (string, chars = ' ') {
|
|
12
12
|
const testChars = new Set([...chars])
|
|
13
13
|
let first = true
|
|
14
14
|
return [...string].reduce((acc, curr) => {
|
|
@@ -24,5 +24,3 @@ function trimStart (string, chars = ' ') {
|
|
|
24
24
|
}
|
|
25
25
|
}, '')
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
export { trimStart }
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Truncates string if it's longer than the given maximum string length. The last characters
|
|
3
3
|
* of the truncated string are replaced with the omission string which defaults to "...".
|
|
4
|
-
*
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {string} [options.omission='...'] string to indicate omitted text
|
|
4
|
+
* @param {string} string string to truncate
|
|
5
|
+
* @param {object} [options] object containing options (default {})
|
|
6
|
+
* @param {number} [options.length] Max length of truncated string (default 30)
|
|
7
|
+
* @param {string} [options.omission] string to indicate omitted text (default '...')
|
|
9
8
|
* @param {RegExp|string} [options.separator] the pattern to end truncation
|
|
10
9
|
* @returns {string} returns truncated string
|
|
11
|
-
*
|
|
12
10
|
* @example
|
|
13
11
|
* const result = strings.truncate('This sentence starts with', 'This');
|
|
14
12
|
* console.log(result);
|
|
15
13
|
* > true
|
|
16
|
-
|
|
17
|
-
export function truncate(string
|
|
18
|
-
length?: number;
|
|
19
|
-
omission?: string;
|
|
20
|
-
separator?: string | RegExp;
|
|
14
|
+
*/
|
|
15
|
+
export function truncate(string: string, options?: {
|
|
16
|
+
length?: number | undefined;
|
|
17
|
+
omission?: string | undefined;
|
|
18
|
+
separator?: string | RegExp | undefined;
|
|
21
19
|
}): string;
|
package/src/strings/truncate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Truncates string if it's longer than the given maximum string length. The last characters
|
|
3
3
|
* of the truncated string are replaced with the omission string which defaults to "...".
|
|
4
|
-
* @param {string}
|
|
4
|
+
* @param {string} string string to truncate
|
|
5
5
|
* @param {object} [options] object containing options (default {})
|
|
6
6
|
* @param {number} [options.length] Max length of truncated string (default 30)
|
|
7
7
|
* @param {string} [options.omission] string to indicate omitted text (default '...')
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* console.log(result);
|
|
13
13
|
* > true
|
|
14
14
|
*/
|
|
15
|
-
function truncate (string, options = {}) {
|
|
15
|
+
export function truncate (string, options = {}) {
|
|
16
16
|
let length = 30
|
|
17
17
|
let omission = '...'
|
|
18
18
|
let separator
|
|
@@ -29,7 +29,7 @@ function truncate (string, options = {}) {
|
|
|
29
29
|
let result = string.slice(0, end)
|
|
30
30
|
if (separator === undefined) { return result + omission }
|
|
31
31
|
|
|
32
|
-
let strSeparator
|
|
32
|
+
let strSeparator = ''
|
|
33
33
|
let regexSeparator
|
|
34
34
|
if (typeof separator === 'string') {
|
|
35
35
|
strSeparator = separator
|
|
@@ -60,5 +60,3 @@ function truncate (string, options = {}) {
|
|
|
60
60
|
}
|
|
61
61
|
return result + omission
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
export { truncate }
|
package/src/strings/words.d.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Splits `string` into an array of its words.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} [string] string to inspect for words
|
|
3
|
+
* @param {string} string string to inspect for words
|
|
5
4
|
* @param {RegExp|string} [pattern] regex pattern to match words or string of characters to split words by.
|
|
6
|
-
* @returns {
|
|
7
|
-
*
|
|
5
|
+
* @returns {string[]} Returns an array of words
|
|
8
6
|
* @example
|
|
9
7
|
* const result = words('I can, I should, & I will');
|
|
10
8
|
* console.log(result);
|
|
11
9
|
* // => ['I', 'can', 'I', 'should', 'I', 'will']
|
|
12
|
-
*
|
|
13
10
|
* @example
|
|
14
11
|
* const result = words('I can, I should, & I will', ' ,');
|
|
15
12
|
* console.log(result);
|
|
16
13
|
* // => ['I', 'can', 'I', 'should', '&', 'I', 'will']
|
|
17
|
-
*
|
|
18
14
|
* @example
|
|
19
15
|
* const result = words('I can, I should, & I will', /[^, ]+/g);
|
|
20
16
|
* console.log(result);
|
|
21
17
|
* // => ['I', 'can', 'I', 'should', '&', 'I', 'will']
|
|
22
18
|
*/
|
|
23
|
-
export function words(string
|
|
19
|
+
export function words(string: string, pattern?: RegExp | string): string[];
|
package/src/strings/words.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Splits `string` into an array of its words.
|
|
5
|
-
* @param {string}
|
|
5
|
+
* @param {string} string string to inspect for words
|
|
6
6
|
* @param {RegExp|string} [pattern] regex pattern to match words or string of characters to split words by.
|
|
7
|
-
* @returns {
|
|
7
|
+
* @returns {string[]} Returns an array of words
|
|
8
8
|
* @example
|
|
9
9
|
* const result = words('I can, I should, & I will');
|
|
10
10
|
* console.log(result);
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* console.log(result);
|
|
19
19
|
* // => ['I', 'can', 'I', 'should', '&', 'I', 'will']
|
|
20
20
|
*/
|
|
21
|
-
function words (string, pattern) {
|
|
21
|
+
export function words (string, pattern) {
|
|
22
22
|
if (pattern === undefined) { return string.match(reUnicodeWords) || [] }
|
|
23
23
|
if (typeof pattern === 'string') {
|
|
24
24
|
return string.match(new RegExp('[^' + pattern + ']+', 'g')) || []
|
|
@@ -84,5 +84,3 @@ const reUnicodeWords = RegExp([
|
|
|
84
84
|
`${rsDigit}+`,
|
|
85
85
|
rsEmoji
|
|
86
86
|
].join('|'), 'g')
|
|
87
|
-
|
|
88
|
-
export { words }
|