aneka 0.8.0 → 0.9.0
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/CHANGES.md +4 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/src/fill-object.js +17 -0
package/CHANGES.md
CHANGED
package/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import parseDuration from './src/parse-duration.js'
|
|
|
27
27
|
import parseObject from './src/parse-object.js'
|
|
28
28
|
import randomRange from './src/random-range.js'
|
|
29
29
|
import generateId from './src/generate-id.js'
|
|
30
|
+
import fillObject from './src/fill-object.js'
|
|
30
31
|
|
|
31
32
|
export {
|
|
32
33
|
arrangeArray,
|
|
@@ -35,6 +36,7 @@ export {
|
|
|
35
36
|
delay,
|
|
36
37
|
extractText,
|
|
37
38
|
formatText,
|
|
39
|
+
fillObject,
|
|
38
40
|
filterDuplicate,
|
|
39
41
|
filterIndex,
|
|
40
42
|
generateId,
|
|
@@ -68,6 +70,7 @@ export default {
|
|
|
68
70
|
delay,
|
|
69
71
|
extractText,
|
|
70
72
|
formatText,
|
|
73
|
+
fillObject,
|
|
71
74
|
filterDuplicate,
|
|
72
75
|
filterIndex,
|
|
73
76
|
generateId,
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fill object with keys. ```defValue``` is used if the corresponding key doesn't have value
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} obj - Object to fill
|
|
5
|
+
* @param {string[]} keys - Array of keys
|
|
6
|
+
* @param {any} defValue - Default value
|
|
7
|
+
* @returns {Object}
|
|
8
|
+
*/
|
|
9
|
+
function fillObject (obj = {}, keys = [], defValue) {
|
|
10
|
+
const newObj = {}
|
|
11
|
+
for (const key of keys) {
|
|
12
|
+
newObj[key] = obj[key] ?? defValue
|
|
13
|
+
}
|
|
14
|
+
return newObj
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default fillObject
|