utilitish 0.0.21 → 0.0.23
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Licence
|
|
2
2
|
|
|
3
|
-
Ce projet est distribué sous licence [
|
|
3
|
+
Ce projet est distribué sous licence [MIT](https://opensource.org/licenses/MIT) © 2025 Donovan Ferreira.
|
|
4
4
|
|
|
5
5
|
Ceci est une petite librairie qui ajoute plusieurs méthodes au prototype JavaScript.
|
|
6
6
|
|
|
@@ -147,7 +147,7 @@ declare global {
|
|
|
147
147
|
* - Uses JavaScript's falsy value definition
|
|
148
148
|
* - Returns a new array (original is not modified)
|
|
149
149
|
*/
|
|
150
|
-
compact(): T[];
|
|
150
|
+
compact(): NonNullable<T>[];
|
|
151
151
|
/**
|
|
152
152
|
* Enumerates the array into tuples of [value, index].
|
|
153
153
|
* Similar to Python's enumerate but returns value first.
|
|
@@ -132,6 +132,20 @@ describe('Array.prototype', () => {
|
|
|
132
132
|
it('should remove all falsy values', () => {
|
|
133
133
|
expect([0, 1, false, 2, '', 3, null].compact()).toEqual([1, 2, 3]);
|
|
134
134
|
});
|
|
135
|
+
it('should return correct type when array contains null/undefined', () => {
|
|
136
|
+
const input = ['a', null, 'b', undefined, 'c'];
|
|
137
|
+
const result = input.compact();
|
|
138
|
+
expect(result).toEqual(['a', 'b', 'c']);
|
|
139
|
+
const _check = result;
|
|
140
|
+
});
|
|
141
|
+
it('should return empty array if all values are falsy', () => {
|
|
142
|
+
expect([null, undefined, false, 0, ''].compact()).toEqual([]);
|
|
143
|
+
});
|
|
144
|
+
it('should not modify the original array', () => {
|
|
145
|
+
const input = [1, null, 2];
|
|
146
|
+
input.compact();
|
|
147
|
+
expect(input).toEqual([1, null, 2]);
|
|
148
|
+
});
|
|
135
149
|
});
|
|
136
150
|
describe('enumerate()', () => {
|
|
137
151
|
it('should return array of [value, index] tuples', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utilitish",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/FDonovan12/utilitish.git"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsc",
|
|
28
|
-
"test": "jest",
|
|
28
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
29
29
|
"docs": "typedoc",
|
|
30
30
|
"release": "(npm whoami || npm login) && npm test && npm run build && npm version patch && git push --follow-tags && npm publish"
|
|
31
31
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"utils"
|
|
36
36
|
],
|
|
37
37
|
"author": "Donovan Ferreira <donovanferreira12@gmail.com> (https://github.com/FDonovan12)",
|
|
38
|
-
"license": "
|
|
38
|
+
"license": "MIT",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/jest": "^29.5.14",
|
|
41
41
|
"jest": "^29.7.0",
|