@empathyco/x-components 3.0.0-alpha.76 → 3.0.0-alpha.79
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/CHANGELOG.md +35 -0
- package/core/index.js +0 -1
- package/core/index.js.map +1 -1
- package/design-system/default-theme.css +100 -100
- package/docs/API-reference/api/x-components.actionstree.md +1 -1
- package/docs/API-reference/api/x-components.anyactionstree.md +1 -1
- package/docs/API-reference/api/x-components.anygetterstree.md +1 -1
- package/docs/API-reference/api/x-components.anymutationstree.md +1 -1
- package/docs/API-reference/api/x-components.compilemessage.md +1 -1
- package/docs/API-reference/api/x-components.extraparams.md +2 -2
- package/docs/API-reference/api/x-components.extraparamsmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.extraparamsstate.md +1 -1
- package/docs/API-reference/api/x-components.extraparamsxevents.md +4 -4
- package/docs/API-reference/api/x-components.getterstree.md +1 -1
- package/docs/API-reference/api/x-components.identifierresultsmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.identifierresultsstate.md +1 -1
- package/docs/API-reference/api/x-components.md +0 -8
- package/docs/API-reference/api/x-components.mutationstree.md +1 -1
- package/docs/API-reference/api/x-components.nextqueriesmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.nextqueriesstate.md +1 -1
- package/docs/API-reference/api/x-components.popularsearchesmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.popularsearchesstate.md +1 -1
- package/docs/API-reference/api/x-components.querysuggestionsmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.querysuggestionsstate.md +1 -1
- package/docs/API-reference/api/x-components.recommendationsmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.recommendationsstate.md +1 -1
- package/docs/API-reference/api/x-components.relatedtagsmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.relatedtagsstate.md +1 -1
- package/docs/API-reference/api/x-components.renderlessextraparams.md +1 -1
- package/docs/API-reference/api/x-components.returns.md +0 -2
- package/docs/API-reference/api/x-components.scrollstate.md +1 -1
- package/docs/API-reference/api/x-components.searchmutations.setparams.md +1 -1
- package/docs/API-reference/api/x-components.searchstate.md +2 -2
- package/docs/API-reference/api/x-components.setextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setidentifierresultsextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setinitialextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setnextqueriesextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setpopularsearchesextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setquerysuggestionsextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setrecommendationsextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setrelatedtagsextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setsearchextraparams.md +1 -1
- package/docs/API-reference/api/x-components.simplestateselector.md +0 -2
- package/docs/API-reference/api/x-components.snippetconfigextraparams.md +1 -1
- package/docs/API-reference/api/x-components.urlhandler.md +1 -1
- package/docs/API-reference/api/x-components.urlmutations.setinitialextraparams.md +1 -1
- package/docs/API-reference/api/x-components.urlstate.md +1 -1
- package/docs/API-reference/api/x-components.urlxevents.extraparamsloadedfromurl.md +1 -1
- package/docs/API-reference/api/x-components.urlxevents.md +1 -1
- package/docs/API-reference/api/x-components.vuecssclasses.md +0 -2
- package/docs/API-reference/api/x-components.wiring.md +1 -1
- package/js/components/global-x-bus.vue.js.map +1 -1
- package/js/components/global-x-bus.vue_rollup-plugin-vue_script.vue.js +1 -1
- package/js/components/global-x-bus.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/snippet-callbacks.vue.js.map +1 -1
- package/js/components/snippet-callbacks.vue_rollup-plugin-vue_script.vue.js +1 -1
- package/js/components/snippet-callbacks.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/components/suggestions/base-suggestion.vue.js.map +1 -1
- package/js/components/suggestions/base-suggestion.vue_rollup-plugin-vue_script.vue.js +1 -1
- package/js/components/suggestions/base-suggestion.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/filters/compile-message.filter.js.map +1 -1
- package/js/index.js +0 -1
- package/js/index.js.map +1 -1
- package/js/plugins/x-emitters.js +1 -1
- package/js/plugins/x-emitters.js.map +1 -1
- package/js/plugins/x-plugin.js +1 -2
- package/js/plugins/x-plugin.js.map +1 -1
- package/js/store/utils/getters-proxy.utils.js +1 -1
- package/js/store/utils/getters-proxy.utils.js.map +1 -1
- package/js/store/utils/store-emitters.utils.js.map +1 -1
- package/js/x-installer/x-installer/x-installer.js +1 -1
- package/js/x-installer/x-installer/x-installer.js.map +1 -1
- package/js/x-modules/extra-params/components/extra-params.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/renderless-extra-param.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/renderless-extra-param.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js +1 -2
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue.js +2 -2
- package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
- package/js/x-modules/facets/components/facets/facets.vue_rollup-plugin-vue_script.vue.js +1 -1
- package/js/x-modules/facets/components/facets/facets.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/facets/store/getters/facets.getter.js +1 -1
- package/js/x-modules/facets/store/getters/facets.getter.js.map +1 -1
- package/js/x-modules/facets/store/getters/selected-filters-by-facet.getter.js +1 -1
- package/js/x-modules/facets/store/getters/selected-filters-by-facet.getter.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
- package/js/x-modules/scroll/components/scroll-to-top.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/search/store/actions/reset-state.action.js +1 -1
- package/js/x-modules/search/store/actions/reset-state.action.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js +1 -1
- package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/url/store/getters/url-params.getter.js +1 -1
- package/js/x-modules/url/store/getters/url-params.getter.js.map +1 -1
- package/js/x-modules/url/store/mutations/set-params.mutation.js +1 -1
- package/js/x-modules/url/store/mutations/set-params.mutation.js.map +1 -1
- package/package.json +13 -15
- package/report/tsdoc-metadata.json +1 -1
- package/report/x-adapter.api.json +1 -1
- package/report/x-components.api.json +688 -1054
- package/report/x-components.api.md +1 -24
- package/report/x-types.api.json +1 -1
- package/types/components/snippet-callbacks.vue.d.ts.map +1 -1
- package/types/components/suggestions/base-suggestion.vue.d.ts.map +1 -1
- package/types/filters/compile-message.filter.d.ts +1 -1
- package/types/filters/compile-message.filter.d.ts.map +1 -1
- package/types/plugins/x-emitters.d.ts.map +1 -1
- package/types/plugins/x-plugin.d.ts.map +1 -1
- package/types/store/actions.types.d.ts +2 -1
- package/types/store/actions.types.d.ts.map +1 -1
- package/types/store/getters.types.d.ts +1 -1
- package/types/store/getters.types.d.ts.map +1 -1
- package/types/store/mutations.types.d.ts +1 -1
- package/types/store/mutations.types.d.ts.map +1 -1
- package/types/store/utils/getters-proxy.utils.d.ts.map +1 -1
- package/types/store/utils/store-emitters.utils.d.ts +2 -1
- package/types/store/utils/store-emitters.utils.d.ts.map +1 -1
- package/types/utils/index.d.ts +0 -1
- package/types/utils/index.d.ts.map +1 -1
- package/types/utils/types.d.ts +1 -9
- package/types/utils/types.d.ts.map +1 -1
- package/types/wiring/wiring.types.d.ts +2 -1
- package/types/wiring/wiring.types.d.ts.map +1 -1
- package/types/x-installer/x-installer/x-installer.d.ts.map +1 -1
- package/types/x-modules/extra-params/components/extra-params.vue.d.ts +1 -1
- package/types/x-modules/extra-params/components/extra-params.vue.d.ts.map +1 -1
- package/types/x-modules/extra-params/components/renderless-extra-param.vue.d.ts +1 -1
- package/types/x-modules/extra-params/components/renderless-extra-param.vue.d.ts.map +1 -1
- package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts +1 -1
- package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts.map +1 -1
- package/types/x-modules/extra-params/events.types.d.ts +1 -1
- package/types/x-modules/extra-params/events.types.d.ts.map +1 -1
- package/types/x-modules/extra-params/store/emitters.d.ts +1 -1
- package/types/x-modules/extra-params/store/types.d.ts +1 -1
- package/types/x-modules/extra-params/store/types.d.ts.map +1 -1
- package/types/x-modules/extra-params/wiring.d.ts +4 -4
- package/types/x-modules/extra-params/wiring.d.ts.map +1 -1
- package/types/x-modules/facets/components/facets/facets.vue.d.ts +1 -1
- package/types/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
- package/types/x-modules/identifier-results/store/types.d.ts +1 -1
- package/types/x-modules/identifier-results/store/types.d.ts.map +1 -1
- package/types/x-modules/identifier-results/wiring.d.ts +2 -2
- package/types/x-modules/identifier-results/wiring.d.ts.map +1 -1
- package/types/x-modules/next-queries/store/types.d.ts +1 -1
- package/types/x-modules/next-queries/store/types.d.ts.map +1 -1
- package/types/x-modules/next-queries/wiring.d.ts +2 -2
- package/types/x-modules/next-queries/wiring.d.ts.map +1 -1
- package/types/x-modules/popular-searches/store/types.d.ts +1 -1
- package/types/x-modules/popular-searches/store/types.d.ts.map +1 -1
- package/types/x-modules/popular-searches/wiring.d.ts +2 -2
- package/types/x-modules/popular-searches/wiring.d.ts.map +1 -1
- package/types/x-modules/query-suggestions/store/types.d.ts +1 -1
- package/types/x-modules/query-suggestions/store/types.d.ts.map +1 -1
- package/types/x-modules/query-suggestions/wiring.d.ts +2 -2
- package/types/x-modules/query-suggestions/wiring.d.ts.map +1 -1
- package/types/x-modules/recommendations/store/types.d.ts +1 -1
- package/types/x-modules/recommendations/store/types.d.ts.map +1 -1
- package/types/x-modules/recommendations/wiring.d.ts +2 -2
- package/types/x-modules/recommendations/wiring.d.ts.map +1 -1
- package/types/x-modules/related-tags/store/types.d.ts +1 -1
- package/types/x-modules/related-tags/store/types.d.ts.map +1 -1
- package/types/x-modules/related-tags/wiring.d.ts +2 -2
- package/types/x-modules/related-tags/wiring.d.ts.map +1 -1
- package/types/x-modules/scroll/components/scroll-to-top.vue.d.ts +1 -1
- package/types/x-modules/scroll/components/scroll-to-top.vue.d.ts.map +1 -1
- package/types/x-modules/scroll/store/types.d.ts +1 -1
- package/types/x-modules/scroll/store/types.d.ts.map +1 -1
- package/types/x-modules/search/store/types.d.ts +1 -1
- package/types/x-modules/search/store/types.d.ts.map +1 -1
- package/types/x-modules/search/wiring.d.ts +2 -2
- package/types/x-modules/search/wiring.d.ts.map +1 -1
- package/types/x-modules/url/components/url-handler.vue.d.ts +1 -1
- package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
- package/types/x-modules/url/events.types.d.ts +3 -2
- package/types/x-modules/url/events.types.d.ts.map +1 -1
- package/types/x-modules/url/store/types.d.ts +1 -1
- package/types/x-modules/url/store/types.d.ts.map +1 -1
- package/types/x-modules/url/wiring.d.ts +2 -2
- package/types/x-modules/url/wiring.d.ts.map +1 -1
- package/docs/API-reference/api/x-components.cleanundefined.md +0 -26
- package/docs/API-reference/api/x-components.dictionary.md +0 -13
- package/docs/API-reference/api/x-components.every.md +0 -27
- package/docs/API-reference/api/x-components.foreach.md +0 -25
- package/docs/API-reference/api/x-components.getnewandupdatedkeys.md +0 -27
- package/docs/API-reference/api/x-components.map.md +0 -27
- package/docs/API-reference/api/x-components.objectfilter.md +0 -27
- package/docs/API-reference/api/x-components.reduce.md +0 -28
- package/js/utils/object.js +0 -115
- package/js/utils/object.js.map +0 -1
- package/types/utils/object.d.ts +0 -70
- package/types/utils/object.d.ts.map +0 -1
package/js/utils/object.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Iterates over every non-undefined property of the object calling the callback passed as
|
|
3
|
-
* parameter.
|
|
4
|
-
*
|
|
5
|
-
* @param obj - The object to iterate through each property.
|
|
6
|
-
* @param callbackFn - The callback function to call for each property.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
function forEach(obj, callbackFn) {
|
|
10
|
-
if (obj == null) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
let index = 0;
|
|
14
|
-
for (const key in obj) {
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined) {
|
|
16
|
-
callbackFn(key, obj[key], index++);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Iterates through the obj properties calling the reducer function.
|
|
22
|
-
*
|
|
23
|
-
* @param obj - The object to iterate through each property.
|
|
24
|
-
* @param reducer - A function that will be called for each property, modifying the initialValue
|
|
25
|
-
* object.
|
|
26
|
-
* @param initialValue - The initial value of the accumulator property of the reducer function.
|
|
27
|
-
* @returns Result of the reducer function.
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
function reduce(obj, reducer, initialValue) {
|
|
31
|
-
let accumulator = initialValue;
|
|
32
|
-
forEach(obj, (key, value, index) => {
|
|
33
|
-
accumulator = reducer(accumulator, key, value, index);
|
|
34
|
-
});
|
|
35
|
-
return accumulator;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Creates an object from another object transforming each property value.
|
|
39
|
-
*
|
|
40
|
-
* @param obj - The object to transform each property value.
|
|
41
|
-
* @param mapper - The mapper function which will transform each value.
|
|
42
|
-
* @returns A record with the result of the mapper.
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
function map(obj, mapper) {
|
|
46
|
-
return reduce(obj, (accumulator, key, value, index) => {
|
|
47
|
-
accumulator[key] = mapper(key, value, index);
|
|
48
|
-
return accumulator;
|
|
49
|
-
}, {});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Creates an object picking only the not undefined properties.
|
|
53
|
-
*
|
|
54
|
-
* @param obj - The object from whom pick the values.
|
|
55
|
-
* @returns A new object with the not undefined properties of the source object.
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
function cleanUndefined(obj) {
|
|
59
|
-
return typeof obj !== 'object' || obj === null || Array.isArray(obj)
|
|
60
|
-
? obj
|
|
61
|
-
: reduce(obj, (pickedObject, key, value) => {
|
|
62
|
-
pickedObject[key] = cleanUndefined(value);
|
|
63
|
-
return pickedObject;
|
|
64
|
-
}, {});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Creates an object picking only the ones that pass the test implemented by the
|
|
68
|
-
* provided function isIncluded.
|
|
69
|
-
*
|
|
70
|
-
* @param obj - T object to be filtered.
|
|
71
|
-
* @param isIncluded - Test function that every obj item must pass.
|
|
72
|
-
* @returns A filtered object.
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
|
-
function objectFilter(obj, isIncluded) {
|
|
76
|
-
return reduce(obj, (accumulator, key, value, index) => {
|
|
77
|
-
if (isIncluded(key, value, index)) {
|
|
78
|
-
accumulator[key] = value;
|
|
79
|
-
}
|
|
80
|
-
return accumulator;
|
|
81
|
-
}, {});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Compares two objects of the same type, checking the values of their keys and retrieving
|
|
85
|
-
* those that were not present in the old value and/or those whose value has changed.
|
|
86
|
-
*
|
|
87
|
-
* @param newValue - The new object value.
|
|
88
|
-
* @param oldValue - The old object value.
|
|
89
|
-
*
|
|
90
|
-
* @returns An array of keys.
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
function getNewAndUpdatedKeys(newValue, oldValue) {
|
|
94
|
-
if (newValue === oldValue || !newValue || !oldValue) {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
return Object.keys(newValue).filter(key => !(key in oldValue) || newValue[key] !== oldValue[key]);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Ensures that the given condition is met in all the non-undefined entries of the object.
|
|
101
|
-
*
|
|
102
|
-
* @param object - The object to check if every item meets the given condition.
|
|
103
|
-
* @param condition - The condition to check in each one of the entries of the object.
|
|
104
|
-
*
|
|
105
|
-
* @returns True when all the entries pass the condition. False otherwise.
|
|
106
|
-
* @public
|
|
107
|
-
*/
|
|
108
|
-
function every(object, condition) {
|
|
109
|
-
return Object.entries(object)
|
|
110
|
-
.filter(([, value]) => value !== undefined)
|
|
111
|
-
.every(([key, value], index) => condition(key, value, index));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export { cleanUndefined, every, forEach, getNewAndUpdatedKeys, map, objectFilter, reduce };
|
|
115
|
-
//# sourceMappingURL=object.js.map
|
package/js/utils/object.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sources":["../../../src/utils/object.ts"],"sourcesContent":["import { Dictionary } from './types';\n\n/**\n * Iterates over every non-undefined property of the object calling the callback passed as\n * parameter.\n *\n * @param obj - The object to iterate through each property.\n * @param callbackFn - The callback function to call for each property.\n * @public\n */\nexport function forEach<T extends Dictionary>(\n obj: T | undefined | null,\n callbackFn: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => void\n): void {\n if (obj == null) {\n return;\n }\n\n let index = 0;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined) {\n callbackFn(key, obj[key], index++);\n }\n }\n}\n\n/**\n * Iterates through the obj properties calling the reducer function.\n *\n * @param obj - The object to iterate through each property.\n * @param reducer - A function that will be called for each property, modifying the initialValue\n * object.\n * @param initialValue - The initial value of the accumulator property of the reducer function.\n * @returns Result of the reducer function.\n * @public\n */\nexport function reduce<T extends Dictionary, V>(\n obj: T | undefined | null,\n reducer: (\n accumulator: V,\n key: keyof T,\n value: Exclude<T[keyof T], undefined>,\n index: number\n ) => V,\n initialValue: V\n): V {\n let accumulator = initialValue;\n forEach(obj, (key, value, index) => {\n accumulator = reducer(accumulator, key, value, index);\n });\n return accumulator;\n}\n\n/**\n * Creates an object from another object transforming each property value.\n *\n * @param obj - The object to transform each property value.\n * @param mapper - The mapper function which will transform each value.\n * @returns A record with the result of the mapper.\n * @public\n */\nexport function map<T extends Dictionary, W>(\n obj: T | undefined | null,\n mapper: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => W\n): Record<keyof T, W> {\n return reduce(\n obj,\n (accumulator, key, value, index) => {\n accumulator[key] = mapper(key, value, index);\n return accumulator;\n },\n {} as Record<keyof T, W>\n );\n}\n\n/**\n * Creates an object picking only the not undefined properties.\n *\n * @param obj - The object from whom pick the values.\n * @returns A new object with the not undefined properties of the source object.\n * @public\n */\nexport function cleanUndefined<T>(obj: T): T {\n return typeof obj !== 'object' || obj === null || Array.isArray(obj)\n ? obj\n : reduce(\n obj,\n (pickedObject, key, value) => {\n pickedObject[key] = cleanUndefined(value);\n return pickedObject;\n },\n {} as T\n );\n}\n\n/**\n * Creates an object picking only the ones that pass the test implemented by the\n * provided function isIncluded.\n *\n * @param obj - T object to be filtered.\n * @param isIncluded - Test function that every obj item must pass.\n * @returns A filtered object.\n * @public\n */\nexport function objectFilter<T extends Dictionary>(\n obj: T | undefined | null,\n isIncluded: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => boolean\n): T {\n return reduce(\n obj,\n (accumulator, key, value, index) => {\n if (isIncluded(key, value, index)) {\n accumulator[key] = value;\n }\n return accumulator;\n },\n {} as T\n );\n}\n\n/**\n * Compares two objects of the same type, checking the values of their keys and retrieving\n * those that were not present in the old value and/or those whose value has changed.\n *\n * @param newValue - The new object value.\n * @param oldValue - The old object value.\n *\n * @returns An array of keys.\n * @public\n */\nexport function getNewAndUpdatedKeys<ObjectType extends Dictionary>(\n newValue: ObjectType | undefined,\n oldValue: ObjectType | undefined\n): (keyof ObjectType)[] {\n if (newValue === oldValue || !newValue || !oldValue) {\n return [];\n }\n\n return Object.keys(newValue).filter(key => !(key in oldValue) || newValue[key] !== oldValue[key]);\n}\n\n/**\n * Ensures that the given condition is met in all the non-undefined entries of the object.\n *\n * @param object - The object to check if every item meets the given condition.\n * @param condition - The condition to check in each one of the entries of the object.\n *\n * @returns True when all the entries pass the condition. False otherwise.\n * @public\n */\nexport function every<ObjectType extends Dictionary>(\n object: ObjectType,\n condition: (\n key: keyof ObjectType,\n value: Exclude<ObjectType[keyof ObjectType], undefined>,\n index: number\n ) => boolean\n): boolean {\n return Object.entries(object)\n .filter(([, value]) => value !== undefined)\n .every(([key, value], index) => condition(key, value, index));\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;SAQgB,OAAO,CACrB,GAAyB,EACzB,UAAwF;IAExF,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO;KACR;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YAC5E,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC;AAED;;;;;;;;;;SAUgB,MAAM,CACpB,GAAyB,EACzB,OAKM,EACN,YAAe;IAEf,IAAI,WAAW,GAAG,YAAY,CAAC;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK;QAC7B,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KACvD,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;SAQgB,GAAG,CACjB,GAAyB,EACzB,MAAiF;IAEjF,OAAO,MAAM,CACX,GAAG,E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G,CAAC;AAED;;;;;;;;;SASgB,KAAK,CACnB,MAAkB,EAClB,SAIY;IAEZ,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,SAAS,CAAC;SAC1C,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAClE;;;;"}
|
package/types/utils/object.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Dictionary } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Iterates over every non-undefined property of the object calling the callback passed as
|
|
4
|
-
* parameter.
|
|
5
|
-
*
|
|
6
|
-
* @param obj - The object to iterate through each property.
|
|
7
|
-
* @param callbackFn - The callback function to call for each property.
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare function forEach<T extends Dictionary>(obj: T | undefined | null, callbackFn: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => void): void;
|
|
11
|
-
/**
|
|
12
|
-
* Iterates through the obj properties calling the reducer function.
|
|
13
|
-
*
|
|
14
|
-
* @param obj - The object to iterate through each property.
|
|
15
|
-
* @param reducer - A function that will be called for each property, modifying the initialValue
|
|
16
|
-
* object.
|
|
17
|
-
* @param initialValue - The initial value of the accumulator property of the reducer function.
|
|
18
|
-
* @returns Result of the reducer function.
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export declare function reduce<T extends Dictionary, V>(obj: T | undefined | null, reducer: (accumulator: V, key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => V, initialValue: V): V;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an object from another object transforming each property value.
|
|
24
|
-
*
|
|
25
|
-
* @param obj - The object to transform each property value.
|
|
26
|
-
* @param mapper - The mapper function which will transform each value.
|
|
27
|
-
* @returns A record with the result of the mapper.
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
export declare function map<T extends Dictionary, W>(obj: T | undefined | null, mapper: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => W): Record<keyof T, W>;
|
|
31
|
-
/**
|
|
32
|
-
* Creates an object picking only the not undefined properties.
|
|
33
|
-
*
|
|
34
|
-
* @param obj - The object from whom pick the values.
|
|
35
|
-
* @returns A new object with the not undefined properties of the source object.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export declare function cleanUndefined<T>(obj: T): T;
|
|
39
|
-
/**
|
|
40
|
-
* Creates an object picking only the ones that pass the test implemented by the
|
|
41
|
-
* provided function isIncluded.
|
|
42
|
-
*
|
|
43
|
-
* @param obj - T object to be filtered.
|
|
44
|
-
* @param isIncluded - Test function that every obj item must pass.
|
|
45
|
-
* @returns A filtered object.
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export declare function objectFilter<T extends Dictionary>(obj: T | undefined | null, isIncluded: (key: keyof T, value: Exclude<T[keyof T], undefined>, index: number) => boolean): T;
|
|
49
|
-
/**
|
|
50
|
-
* Compares two objects of the same type, checking the values of their keys and retrieving
|
|
51
|
-
* those that were not present in the old value and/or those whose value has changed.
|
|
52
|
-
*
|
|
53
|
-
* @param newValue - The new object value.
|
|
54
|
-
* @param oldValue - The old object value.
|
|
55
|
-
*
|
|
56
|
-
* @returns An array of keys.
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export declare function getNewAndUpdatedKeys<ObjectType extends Dictionary>(newValue: ObjectType | undefined, oldValue: ObjectType | undefined): (keyof ObjectType)[];
|
|
60
|
-
/**
|
|
61
|
-
* Ensures that the given condition is met in all the non-undefined entries of the object.
|
|
62
|
-
*
|
|
63
|
-
* @param object - The object to check if every item meets the given condition.
|
|
64
|
-
* @param condition - The condition to check in each one of the entries of the object.
|
|
65
|
-
*
|
|
66
|
-
* @returns True when all the entries pass the condition. False otherwise.
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export declare function every<ObjectType extends Dictionary>(object: ObjectType, condition: (key: keyof ObjectType, value: Exclude<ObjectType[keyof ObjectType], undefined>, index: number) => boolean): boolean;
|
|
70
|
-
//# sourceMappingURL=object.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../src/utils/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,EAC1C,GAAG,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EACzB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACvF,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,EAC5C,GAAG,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EACzB,OAAO,EAAE,CACP,WAAW,EAAE,CAAC,EACd,GAAG,EAAE,MAAM,CAAC,EACZ,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EACrC,KAAK,EAAE,MAAM,KACV,CAAC,EACN,YAAY,EAAE,CAAC,GACd,CAAC,CAMH;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,EACzC,GAAG,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EACzB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,MAA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