@zohodesk/utils 1.0.0-temp-1 → 1.0.0-temp-1.2
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/es/crud/ArrayManager.js +11 -11
- package/es/crud/ObjectManager.js +5 -5
- package/es/crud/arrayCRUD.js +2 -2
- package/es/eventListenerUtils.js +26 -0
- package/es/index.js +3 -1
- package/package.json +4 -2
package/es/crud/ArrayManager.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { appendToArray, deleteFromArrayOfObjectById, deleteFromArrayByItem,
|
|
2
|
-
import { DUMMY_ARRAY } from '
|
|
1
|
+
import { appendToArray, deleteFromArrayOfObjectById, deleteFromArrayByItem, updateArrayOfObjectItemById, updateArrayItemByItem, emptyArray } from './arrayCRUD';
|
|
2
|
+
import { DUMMY_ARRAY } from '../constantProps/constant';
|
|
3
3
|
|
|
4
4
|
class ArrayManager {
|
|
5
5
|
constructor() {
|
|
@@ -7,7 +7,7 @@ class ArrayManager {
|
|
|
7
7
|
this.array = initialArray;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
addValue(item) {
|
|
11
11
|
this.array = appendToArray({
|
|
12
12
|
array: this.array,
|
|
13
13
|
item
|
|
@@ -15,7 +15,7 @@ class ArrayManager {
|
|
|
15
15
|
return this.array;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
removeValueById(id) {
|
|
19
19
|
this.array = deleteFromArrayOfObjectById({
|
|
20
20
|
arrayOfObject: this.array,
|
|
21
21
|
id
|
|
@@ -23,7 +23,7 @@ class ArrayManager {
|
|
|
23
23
|
return this.array;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
removeValueByItem(item) {
|
|
27
27
|
this.array = deleteFromArrayByItem({
|
|
28
28
|
array: this.array,
|
|
29
29
|
item
|
|
@@ -31,13 +31,13 @@ class ArrayManager {
|
|
|
31
31
|
return this.array;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
clearValue() {
|
|
35
35
|
this.array = emptyArray();
|
|
36
36
|
return this.array;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
this.array =
|
|
39
|
+
updateValueById(id, newItem) {
|
|
40
|
+
this.array = updateArrayOfObjectItemById({
|
|
41
41
|
arrayOfObject: this.array,
|
|
42
42
|
id,
|
|
43
43
|
newItem
|
|
@@ -45,8 +45,8 @@ class ArrayManager {
|
|
|
45
45
|
return this.array;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
this.array =
|
|
48
|
+
updateValueByItem(currentItem, newItem) {
|
|
49
|
+
this.array = updateArrayItemByItem({
|
|
50
50
|
array: this.array,
|
|
51
51
|
currentItem,
|
|
52
52
|
newItem
|
|
@@ -54,7 +54,7 @@ class ArrayManager {
|
|
|
54
54
|
return this.array;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
getValue() {
|
|
58
58
|
return this.array;
|
|
59
59
|
}
|
|
60
60
|
|
package/es/crud/ObjectManager.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { emptyObject, mergeObjects,
|
|
2
|
-
import { DUMMY_OBJECT } from '
|
|
1
|
+
import { emptyObject, mergeObjects, updateObjectValueByKey, removeObjectByKey, removeObjectByKeys } from './objectCRUD';
|
|
2
|
+
import { DUMMY_OBJECT } from '../constantProps/constant';
|
|
3
3
|
|
|
4
4
|
class ObjectManager {
|
|
5
5
|
constructor() {
|
|
@@ -21,7 +21,7 @@ class ObjectManager {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
updateValueByKey(key, value) {
|
|
24
|
-
this.object =
|
|
24
|
+
this.object = updateObjectValueByKey({
|
|
25
25
|
object: this.object,
|
|
26
26
|
key,
|
|
27
27
|
value
|
|
@@ -30,7 +30,7 @@ class ObjectManager {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
removeValueByKeys(keys) {
|
|
33
|
-
this.object =
|
|
33
|
+
this.object = removeObjectByKeys({
|
|
34
34
|
object: this.object,
|
|
35
35
|
keys
|
|
36
36
|
});
|
|
@@ -38,7 +38,7 @@ class ObjectManager {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
removeValueByKey(key) {
|
|
41
|
-
this.object =
|
|
41
|
+
this.object = removeObjectByKey({
|
|
42
42
|
object: this.object,
|
|
43
43
|
key
|
|
44
44
|
});
|
package/es/crud/arrayCRUD.js
CHANGED
|
@@ -7,7 +7,7 @@ export const appendToArray = _ref => {
|
|
|
7
7
|
} = _ref;
|
|
8
8
|
return [...array, item];
|
|
9
9
|
};
|
|
10
|
-
export const
|
|
10
|
+
export const updateArrayOfObjectItemById = _ref2 => {
|
|
11
11
|
let {
|
|
12
12
|
arrayOfObject,
|
|
13
13
|
id,
|
|
@@ -25,7 +25,7 @@ export const modifyArrayOfObjectItemById = _ref2 => {
|
|
|
25
25
|
return object;
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
-
export const
|
|
28
|
+
export const updateArrayItemByItem = _ref3 => {
|
|
29
29
|
let {
|
|
30
30
|
array,
|
|
31
31
|
currentItem,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const addCustomEventListener = _ref => {
|
|
2
|
+
let {
|
|
3
|
+
eventName,
|
|
4
|
+
callback,
|
|
5
|
+
targetElement
|
|
6
|
+
} = _ref;
|
|
7
|
+
|
|
8
|
+
if (!targetElement || typeof targetElement.addEventListener !== 'function') {
|
|
9
|
+
throw new Error('addCustomEventListener: targetElement is not a valid EventTarget. ' + 'Received: ' + String(targetElement));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
targetElement.addEventListener(eventName, callback);
|
|
13
|
+
};
|
|
14
|
+
export const removeCustomEventListener = _ref2 => {
|
|
15
|
+
let {
|
|
16
|
+
eventName,
|
|
17
|
+
callback,
|
|
18
|
+
targetElement
|
|
19
|
+
} = _ref2;
|
|
20
|
+
|
|
21
|
+
if (!targetElement || typeof targetElement.removeEventListener !== 'function') {
|
|
22
|
+
throw new Error('removeCustomEventListener: targetElement is not a valid EventTarget. ' + 'Received: ' + String(targetElement));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
targetElement.removeEventListener(eventName, callback);
|
|
26
|
+
};
|
package/es/index.js
CHANGED
|
@@ -8,4 +8,6 @@ export { default as compileClassNames } from './compileClassNames';
|
|
|
8
8
|
export { default as ErrorBoundary } from './ErrorBoundary';
|
|
9
9
|
export { default as loadResource } from './loadResource';
|
|
10
10
|
export { default as accessKeyCodes, accessKeyNames } from "./accessKeyCodes";
|
|
11
|
-
export { default as renderNode, isRenderable } from './renderNode';
|
|
11
|
+
export { default as renderNode, isRenderable } from './renderNode';
|
|
12
|
+
export { default as getCurrentTime } from './getCurrentTime';
|
|
13
|
+
export { addCustomEventListener, removeCustomEventListener } from './eventListenerUtils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/utils",
|
|
3
|
-
"version": "1.0.0-temp-1",
|
|
3
|
+
"version": "1.0.0-temp-1.2",
|
|
4
4
|
"description": "DOT Utils Collection",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,12 +21,14 @@
|
|
|
21
21
|
"download": "react-cli clean ./node_modules ./package-lock.json && npm install",
|
|
22
22
|
"build": "type react-cli && react-cli build:component:es",
|
|
23
23
|
"build:watch": "react-cli build:component:es -w",
|
|
24
|
+
"build:es": "react-cli build:library:es",
|
|
24
25
|
"clean": "react-cli clean unittest coverage es result.json",
|
|
25
26
|
"rtl": "react-cli rtl ./src ./es",
|
|
26
27
|
"nodefix": "node ../buildtool_patch.js",
|
|
27
28
|
"prepare": "npm run clean && npm run build && npm run rtl",
|
|
28
29
|
"test": "react-cli test",
|
|
29
|
-
"jsdoc": "jsdoc -c jsdoc.json"
|
|
30
|
+
"jsdoc": "jsdoc -c jsdoc.json",
|
|
31
|
+
"expublish": "npm publish --tag experimental-version"
|
|
30
32
|
},
|
|
31
33
|
"files": [
|
|
32
34
|
"es",
|