You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -36,15 +36,34 @@ var data = function_or_somewhere();
36
36
//};
37
37
38
38
39
-
var result =objectFilter(template, data);
39
+
var result =objFilter(template, data);
40
40
41
41
// result is:
42
-
//{
43
-
// "runtime": {
44
-
//"powerState": "HELLOWORLD",
45
-
// "bootTime": "2017-04-20T13:56:19.377Z",
46
-
// "paused": false,
47
-
// "snapshotInBackground": true
48
-
// }
49
-
//};
42
+
{
43
+
"runtime": {
44
+
"powerState":"HELLOWORLD poweredOn",
45
+
"bootTime":"2017-04-20T13:56:19.377Z",
46
+
"paused":false,
47
+
"snapshotInBackground":true
48
+
}
49
+
};
50
50
~~~~
51
+
52
+
## Template Object
53
+
According to the **Template Object structure**, `obj-filter` supports the following types of value with different behaviour to build the result object.
54
+
55
+
### undefined
56
+
If the *value* of the key is `undefined`, the key will be **filtered** (skipped) and will not included in result object.
57
+
58
+
### object
59
+
If the *value* of the key is an `object`, `obj-filter` will _dive into it and check the **deeper** level of keys_.
60
+
61
+
### function
62
+
If the *value* of the key is an `function`, `obj-filter` will _pass the **value** of the same key in **input data** to the **function**_, and includes it's returned data in result.
63
+
So it's your call to customize how you would like to handle, define what you want to do with the input data. Be sure to **return something** from your function.
64
+
65
+
- If return `undefined`, the key will be **filtered** (skipped).
66
+
- If return anything else, the key will be **included**.
0 commit comments