@etsoo/shared 1.2.42 → 1.2.44
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/.github/workflows/main.yml +3 -3
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/__tests__/Utils.ts +6 -0
- package/lib/cjs/DomUtils.d.ts +0 -1
- package/lib/cjs/Utils.d.ts +6 -1
- package/lib/cjs/Utils.js +13 -0
- package/lib/mjs/DomUtils.d.ts +0 -1
- package/lib/mjs/Utils.d.ts +6 -1
- package/lib/mjs/Utils.js +13 -0
- package/package.json +3 -3
- package/src/Utils.ts +13 -0
|
@@ -22,13 +22,13 @@ jobs:
|
|
|
22
22
|
steps:
|
|
23
23
|
# https://github.com/actions/checkout, This action checks-out your repository under $GITHUB_WORKSPACE
|
|
24
24
|
# so your workflow can access it.
|
|
25
|
-
- uses: actions/checkout@
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
26
|
|
|
27
27
|
# Set up your GitHub Actions workflow with a specific version of node.js
|
|
28
28
|
# Setup .npmrc file to publish to npm
|
|
29
|
-
- uses: actions/setup-node@
|
|
29
|
+
- uses: actions/setup-node@v4
|
|
30
30
|
with:
|
|
31
|
-
node-version: '
|
|
31
|
+
node-version: '20.x'
|
|
32
32
|
registry-url: 'https://registry.npmjs.org'
|
|
33
33
|
|
|
34
34
|
# Named after Continuous Integration, installs dependencies directly from package-lock.json
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2004-2024 ETSOO ® (亿速思维 ®), https://
|
|
3
|
+
Copyright (c) 2004-2024 ETSOO ® (亿速思维 ®), https://etsoo.com, https://etsoo.nz
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -300,6 +300,7 @@ String and other related utilities
|
|
|
300
300
|
|parseJsonArray|Try to parse JSON input to array|
|
|
301
301
|
|parsePath|Parse path similar with node.js path.parse|
|
|
302
302
|
|parseString|Parse string (JSON) to specific type|
|
|
303
|
+
|removeEmptyValues|Remove empty values (null, undefined, '') from the input object|
|
|
303
304
|
|removeNonLetters|Remove non letters (0-9, a-z, A-Z)|
|
|
304
305
|
|replaceNullOrEmpty|Replace null or empty with default value|
|
|
305
306
|
|setLabels|Set source with new labels|
|
package/__tests__/Utils.ts
CHANGED
|
@@ -296,6 +296,12 @@ test('Tests for parsePath, Windows path', () => {
|
|
|
296
296
|
expect(result.name).toBe('file');
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
+
test('Tests for removeEmptyValues', () => {
|
|
300
|
+
const obj = { a: 1, b: '', c: null, d: undefined, e: 'e' };
|
|
301
|
+
Utils.removeEmptyValues(obj);
|
|
302
|
+
expect(obj).toEqual({ a: 1, e: 'e' });
|
|
303
|
+
});
|
|
304
|
+
|
|
299
305
|
test('Tests for setNestedValue', () => {
|
|
300
306
|
const obj = { jsonData: { photoSize: [200, 100], supportResizing: true } };
|
|
301
307
|
|
package/lib/cjs/DomUtils.d.ts
CHANGED
package/lib/cjs/Utils.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export declare namespace Utils {
|
|
|
148
148
|
* @param args Arguments
|
|
149
149
|
* @returns Result
|
|
150
150
|
*/
|
|
151
|
-
const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<
|
|
151
|
+
const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
|
|
152
152
|
/**
|
|
153
153
|
* Get time zone
|
|
154
154
|
* @returns Timezone
|
|
@@ -236,6 +236,11 @@ export declare namespace Utils {
|
|
|
236
236
|
* @returns Parsed value
|
|
237
237
|
*/
|
|
238
238
|
function parseString<T>(input: string | undefined | null, defaultValue: T): T;
|
|
239
|
+
/**
|
|
240
|
+
* Remove empty values (null, undefined, '') from the input object
|
|
241
|
+
* @param input Input object
|
|
242
|
+
*/
|
|
243
|
+
function removeEmptyValues(input: object): void;
|
|
239
244
|
/**
|
|
240
245
|
* Remove non letters
|
|
241
246
|
* @param input Input string
|
package/lib/cjs/Utils.js
CHANGED
|
@@ -477,6 +477,19 @@ var Utils;
|
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
Utils.parseString = parseString;
|
|
480
|
+
/**
|
|
481
|
+
* Remove empty values (null, undefined, '') from the input object
|
|
482
|
+
* @param input Input object
|
|
483
|
+
*/
|
|
484
|
+
function removeEmptyValues(input) {
|
|
485
|
+
Object.keys(input).forEach((key) => {
|
|
486
|
+
const value = Reflect.get(input, key);
|
|
487
|
+
if (value == null || value === '') {
|
|
488
|
+
Reflect.deleteProperty(input, key);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
Utils.removeEmptyValues = removeEmptyValues;
|
|
480
493
|
/**
|
|
481
494
|
* Remove non letters
|
|
482
495
|
* @param input Input string
|
package/lib/mjs/DomUtils.d.ts
CHANGED
package/lib/mjs/Utils.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export declare namespace Utils {
|
|
|
148
148
|
* @param args Arguments
|
|
149
149
|
* @returns Result
|
|
150
150
|
*/
|
|
151
|
-
const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<
|
|
151
|
+
const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
|
|
152
152
|
/**
|
|
153
153
|
* Get time zone
|
|
154
154
|
* @returns Timezone
|
|
@@ -236,6 +236,11 @@ export declare namespace Utils {
|
|
|
236
236
|
* @returns Parsed value
|
|
237
237
|
*/
|
|
238
238
|
function parseString<T>(input: string | undefined | null, defaultValue: T): T;
|
|
239
|
+
/**
|
|
240
|
+
* Remove empty values (null, undefined, '') from the input object
|
|
241
|
+
* @param input Input object
|
|
242
|
+
*/
|
|
243
|
+
function removeEmptyValues(input: object): void;
|
|
239
244
|
/**
|
|
240
245
|
* Remove non letters
|
|
241
246
|
* @param input Input string
|
package/lib/mjs/Utils.js
CHANGED
|
@@ -471,6 +471,19 @@ export var Utils;
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
Utils.parseString = parseString;
|
|
474
|
+
/**
|
|
475
|
+
* Remove empty values (null, undefined, '') from the input object
|
|
476
|
+
* @param input Input object
|
|
477
|
+
*/
|
|
478
|
+
function removeEmptyValues(input) {
|
|
479
|
+
Object.keys(input).forEach((key) => {
|
|
480
|
+
const value = Reflect.get(input, key);
|
|
481
|
+
if (value == null || value === '') {
|
|
482
|
+
Reflect.deleteProperty(input, key);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
Utils.removeEmptyValues = removeEmptyValues;
|
|
474
487
|
/**
|
|
475
488
|
* Remove non letters
|
|
476
489
|
* @param input Input string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.44",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@types/lodash.isequal": "^4.5.8",
|
|
59
59
|
"jest": "^29.7.0",
|
|
60
60
|
"jest-environment-jsdom": "^29.7.0",
|
|
61
|
-
"ts-jest": "^29.
|
|
62
|
-
"typescript": "^5.4
|
|
61
|
+
"ts-jest": "^29.2.4",
|
|
62
|
+
"typescript": "^5.5.4"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"lodash.isequal": "^4.5.0"
|
package/src/Utils.ts
CHANGED
|
@@ -657,6 +657,19 @@ export namespace Utils {
|
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
|
|
660
|
+
/**
|
|
661
|
+
* Remove empty values (null, undefined, '') from the input object
|
|
662
|
+
* @param input Input object
|
|
663
|
+
*/
|
|
664
|
+
export function removeEmptyValues(input: object) {
|
|
665
|
+
Object.keys(input).forEach((key) => {
|
|
666
|
+
const value = Reflect.get(input, key);
|
|
667
|
+
if (value == null || value === '') {
|
|
668
|
+
Reflect.deleteProperty(input, key);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
660
673
|
/**
|
|
661
674
|
* Remove non letters
|
|
662
675
|
* @param input Input string
|