@peter.naydenov/walk-async 1.1.0 → 1.2.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/Changelog.md CHANGED
@@ -1,10 +1,17 @@
1
1
  # Release History
2
2
 
3
3
 
4
+
5
+ ### 1.2.0 ( 2023-09-18)
6
+ - [x] HTML DOM nodes - copy by reference;
7
+
8
+
9
+
4
10
  ### 1.1.0 ( 2022-11-23)
5
11
  - [x] Resolving with `Null` and `undefined` from callback functions will be treated as value;
6
12
 
7
13
 
14
+
8
15
  ### 1.0.1 ( 2022-09-19)
9
16
  - [x] Fix: Deep copy process is losing object properties that are equal to 'null';
10
17
 
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Walk-async (@peter.naydenov/walk-async)
2
2
 
3
+ ![version](https://img.shields.io/github/package-json/v/peterNaydenov/walk-async)
4
+ ![license](https://img.shields.io/github/license/peterNaydenov/walk-async)
5
+
3
6
  Creates an immutable copies of javascript data structures(objects, arrays or mixed). Can execute callback functions on every object property(objectCallback) and/or every primitive property(keyCallback). Callbacks can modify result object during the walk process. Mask, filter or substitute values during the copy process.
4
7
 
5
8
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peter.naydenov/walk-async",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Deep copy with fine control during the process. Can be used also as a deep forEach function",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -17,8 +17,8 @@
17
17
  "ask-for-promise": "1.3.1"
18
18
  },
19
19
  "devDependencies": {
20
- "chai": "^4.3.7",
21
- "mocha": "^10.1.0",
20
+ "chai": "^4.3.8",
21
+ "mocha": "^10.2.0",
22
22
  "nyc": "^15.1.0"
23
23
  },
24
24
  "nyc": {
package/src/main.js CHANGED
@@ -63,6 +63,7 @@ async function goNext ( extend, result, end ) {
63
63
 
64
64
  function findType ( x ) {
65
65
  if ( x == null ) return 'simple' // null and undefined
66
+ if ( x.nodeType ) return 'simple' // DOM node
66
67
  if ( x instanceof Array ) return 'array'
67
68
  if ( typeof x === 'object' ) return 'object'
68
69
  return 'simple' // number, bigint, string, boolean, symbol, function
@@ -83,6 +83,35 @@ describe ( 'Walk-async -> Deep copy', () => {
83
83
  done ()
84
84
  })
85
85
  }) // it Data property has value null
86
+
87
+
88
+
89
+ it ( 'html nodes - copy by reference', done => {
90
+ const data = {
91
+ name : 'Peter'
92
+ , pretendHTML : { nodeType: 1 }
93
+ };
94
+ walk ({ data })
95
+ .then ( r => {
96
+ r.pretendHTML.something = 'hello'
97
+ expect ( data.pretendHTML.something ).to.be.equal ( 'hello' ) // Recognize html nodes and keep them as a reference
98
+ done ()
99
+ })
100
+ }) // html nodes - copy by reference
101
+
102
+
103
+
104
+ it ( 'Functions type - copy by reference', () => {
105
+ const data = {
106
+ name : 'Peter'
107
+ , func : () => 12
108
+ };
109
+
110
+ walk ({ data })
111
+ .then ( r => {
112
+ expect ( r.func() ).to.be.equal ( 12 )
113
+ })
114
+ }) // it Functions type - copy by reference
86
115
 
87
116
  }) // describe
88
117