@etsoo/shared 1.2.42 → 1.2.43
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/README.md +1 -0
- package/__tests__/Utils.ts +6 -0
- package/lib/cjs/Utils.d.ts +5 -0
- package/lib/cjs/Utils.js +13 -0
- package/lib/mjs/Utils.d.ts +5 -0
- package/lib/mjs/Utils.js +13 -0
- package/package.json +1 -1
- 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/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/Utils.d.ts
CHANGED
|
@@ -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/Utils.d.ts
CHANGED
|
@@ -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
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
|