@peter.naydenov/walk-async 3.0.1 → 3.0.3
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 +12 -0
- package/dist/walk-async.cjs +1 -1
- package/dist/walk-async.esm.mjs +1 -1
- package/dist/walk-async.umd.js +1 -1
- package/package.json +11 -8
- package/src/main.js +20 -0
- package/tsconfig.json +10 -0
- package/types/main.d.ts +35 -0
- package/types/main.d.ts.map +1 -0
package/Changelog.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
### 3.0.3 (2025-10-12)
|
|
6
|
+
- [x] Dependencies updates. Ask-for-promise to version 3.0.2;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 3.0.2 (2025-01-07)
|
|
11
|
+
- [x] JSDoc was added to the project;
|
|
12
|
+
- [x] Generatated typescript definitions;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
4
16
|
### 3.0.1 ( 2024-12-18)
|
|
5
17
|
- [x] Dependencies updates. Ask-for-promise to version 3.0.1;
|
|
6
18
|
|
package/dist/walk-async.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("ask-for-promise");async function
|
|
1
|
+
"use strict";var e=require("ask-for-promise");async function o(e,o,n){for await(const o of e)await o.next();n.done(o)}function n(e){return null==e||e.nodeType?"simple":e instanceof Array?"array":"object"==typeof e?"object":"simple"}async function*r(e,o,n,r,s,a){yield await t(e,o,n,r,s,...a)}function t(o,t,s,a,i,...c){let[l,d]=a,p=Object.keys(o),u=e(p),f=e();return p.forEach((p,f)=>{let m=n(o[p]),y=o[p],$="simple"!==m&&null!=d,b=e(),k=e(),h=e(),j="array"===n(t),v=!isNaN(p),C=Symbol("ignore___"),w="root"===i&&"root"===p,N=w?"root":`${i}/${p}`;$?d({resolve:b.done,reject:()=>b.done(C),value:y,key:p,breadcrumbs:N},...c):b.done("$$cancel"),b.onComplete(e=>{if("$$cancel"!==e||l)if("$$cancel"!==e&&(y=e,m=n(y)),y!=C)if("simple"===m){if(!l)return void k.done("$$noUpdates");l({resolve:k.done,reject:()=>k.done(C),value:y,key:p,breadcrumbs:N},...c)}else k.done("$$cancel");else u.promises[f].done("ignore object");else k.done("$$noUpdates")}),k.onComplete(e=>{if(w)return s.push(r(y,t,s,a,"root",c)),void u.promises[f].done("root");if(e!=C)if("$$cancel"!==e){if("$$noUpdates"!==e&&(y=e,m=n(y)),"simple"===m){const e=function(e,o){return o instanceof Array&&!isNaN(e)}(p,t);return e?t.push(y):t[p]=y,void u.promises[f].done("key")}h.done()}else h.done();else u.promises[f].done("ignore key")}),h.onComplete(()=>{if("object"===m){const e={};j&&v?t.push(e):t[p]=e,s.push(r(y,e,s,a,N,c)),u.promises[f].done("object")}if("array"===m){const e=[];j&&v?t.push(e):t[p]=e,s.push(r(y,e,s,a,N,c)),u.promises[f].done("array")}})}),u.onComplete(e=>f.done()),f.promise}module.exports=function({data:r,objectCallback:s=null,keyCallback:a=null},...i){let c,l=n(r),d=[],p="root",u=[a,s],f=e();switch(l){case"array":c=[],t({root:r},c,d,u,p,...i).then(()=>o(d,c,f));break;case"object":c={},t({root:r},c,d,u,p,...i).then(()=>{o(d,c,f)});break;case"simple":f.done(r)}return f.promise};
|
package/dist/walk-async.esm.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"ask-for-promise";function o({data:o,objectCallback:t=null,keyCallback:
|
|
1
|
+
import e from"ask-for-promise";function o({data:o,objectCallback:t=null,keyCallback:a=null},...i){let c,l=r(o),p=[],d="root",u=[a,t],f=e();switch(l){case"array":c=[],s({root:o},c,p,u,d,...i).then(()=>n(p,c,f));break;case"object":c={},s({root:o},c,p,u,d,...i).then(()=>{n(p,c,f)});break;case"simple":f.done(o)}return f.promise}async function n(e,o,n){for await(const o of e)await o.next();n.done(o)}function r(e){return null==e||e.nodeType?"simple":e instanceof Array?"array":"object"==typeof e?"object":"simple"}async function*t(e,o,n,r,t,a){yield await s(e,o,n,r,t,...a)}function s(o,n,s,a,i,...c){let[l,p]=a,d=Object.keys(o),u=e(d),f=e();return d.forEach((d,f)=>{let m=r(o[d]),y=o[d],$="simple"!==m&&null!=p,b=e(),k=e(),h=e(),j="array"===r(n),v=!isNaN(d),C=Symbol("ignore___"),w="root"===i&&"root"===d,N=w?"root":`${i}/${d}`;$?p({resolve:b.done,reject:()=>b.done(C),value:y,key:d,breadcrumbs:N},...c):b.done("$$cancel"),b.onComplete(e=>{if("$$cancel"!==e||l)if("$$cancel"!==e&&(y=e,m=r(y)),y!=C)if("simple"===m){if(!l)return void k.done("$$noUpdates");l({resolve:k.done,reject:()=>k.done(C),value:y,key:d,breadcrumbs:N},...c)}else k.done("$$cancel");else u.promises[f].done("ignore object");else k.done("$$noUpdates")}),k.onComplete(e=>{if(w)return s.push(t(y,n,s,a,"root",c)),void u.promises[f].done("root");if(e!=C)if("$$cancel"!==e){if("$$noUpdates"!==e&&(y=e,m=r(y)),"simple"===m){const e=function(e,o){return o instanceof Array&&!isNaN(e)}(d,n);return e?n.push(y):n[d]=y,void u.promises[f].done("key")}h.done()}else h.done();else u.promises[f].done("ignore key")}),h.onComplete(()=>{if("object"===m){const e={};j&&v?n.push(e):n[d]=e,s.push(t(y,e,s,a,N,c)),u.promises[f].done("object")}if("array"===m){const e=[];j&&v?n.push(e):n[d]=e,s.push(t(y,e,s,a,N,c)),u.promises[f].done("array")}})}),u.onComplete(e=>f.done()),f.promise}export{o as default};
|
package/dist/walk-async.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("ask-for-promise")):"function"==typeof define&&define.amd?define(["ask-for-promise"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).walkAsync=o(e.askForPromise)}(this,
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("ask-for-promise")):"function"==typeof define&&define.amd?define(["ask-for-promise"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).walkAsync=o(e.askForPromise)}(this,function(e){"use strict";async function o(e,o,n){for await(const o of e)await o.next();n.done(o)}function n(e){return null==e||e.nodeType?"simple":e instanceof Array?"array":"object"==typeof e?"object":"simple"}async function*r(e,o,n,r,s,i){yield await t(e,o,n,r,s,...i)}function t(o,t,s,i,a,...c){let[l,d]=i,f=Object.keys(o),p=e(f),u=e();return f.forEach((f,u)=>{let m=n(o[f]),y=o[f],b="simple"!==m&&null!=d,$=e(),k=e(),h=e(),j="array"===n(t),v=!isNaN(f),C=Symbol("ignore___"),g="root"===a&&"root"===f,w=g?"root":`${a}/${f}`;b?d({resolve:$.done,reject:()=>$.done(C),value:y,key:f,breadcrumbs:w},...c):$.done("$$cancel"),$.onComplete(e=>{if("$$cancel"!==e||l)if("$$cancel"!==e&&(y=e,m=n(y)),y!=C)if("simple"===m){if(!l)return void k.done("$$noUpdates");l({resolve:k.done,reject:()=>k.done(C),value:y,key:f,breadcrumbs:w},...c)}else k.done("$$cancel");else p.promises[u].done("ignore object");else k.done("$$noUpdates")}),k.onComplete(e=>{if(g)return s.push(r(y,t,s,i,"root",c)),void p.promises[u].done("root");if(e!=C)if("$$cancel"!==e){if("$$noUpdates"!==e&&(y=e,m=n(y)),"simple"===m){const e=function(e,o){return o instanceof Array&&!isNaN(e)}(f,t);return e?t.push(y):t[f]=y,void p.promises[u].done("key")}h.done()}else h.done();else p.promises[u].done("ignore key")}),h.onComplete(()=>{if("object"===m){const e={};j&&v?t.push(e):t[f]=e,s.push(r(y,e,s,i,w,c)),p.promises[u].done("object")}if("array"===m){const e=[];j&&v?t.push(e):t[f]=e,s.push(r(y,e,s,i,w,c)),p.promises[u].done("array")}})}),p.onComplete(e=>u.done()),u.promise}return function({data:r,objectCallback:s=null,keyCallback:i=null},...a){let c,l=n(r),d=[],f="root",p=[i,s],u=e();switch(l){case"array":c=[],t({root:r},c,d,p,f,...a).then(()=>o(d,c,u));break;case"object":c={},t({root:r},c,d,p,f,...a).then(()=>{o(d,c,u)});break;case"simple":u.done(r)}return u.promise}});
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peter.naydenov/walk-async",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Deep copy with fine control during the process. Can be used also as a deep forEach function",
|
|
5
5
|
"main": ".dist/walk-async.umd.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"types": "./types/main.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"import": "./.dist/walk-async.esm.mjs",
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
"scripts": {
|
|
18
19
|
"test": "mocha test",
|
|
19
20
|
"cover": "c8 mocha test",
|
|
20
|
-
"build": "rollup -c"
|
|
21
|
+
"build": "rollup -c",
|
|
22
|
+
"postbuild": "tsc -p tsconfig.json"
|
|
21
23
|
},
|
|
22
24
|
"repository": {
|
|
23
25
|
"type": "git",
|
|
@@ -26,16 +28,17 @@
|
|
|
26
28
|
"author": "Peter Naydenov",
|
|
27
29
|
"license": "MIT",
|
|
28
30
|
"dependencies": {
|
|
29
|
-
"ask-for-promise": "3.0.
|
|
31
|
+
"ask-for-promise": "3.0.2"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
33
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
34
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
35
|
+
"@rollup/plugin-node-resolve": "^16.0.2",
|
|
34
36
|
"@rollup/plugin-terser": "^0.4.4",
|
|
35
37
|
"c8": "^10.1.3",
|
|
36
|
-
"chai": "^
|
|
37
|
-
"mocha": "^11.
|
|
38
|
-
"rollup": "^4.
|
|
38
|
+
"chai": "^6.2.0",
|
|
39
|
+
"mocha": "^11.7.4",
|
|
40
|
+
"rollup": "^4.52.4",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
39
42
|
},
|
|
40
43
|
"c8": {
|
|
41
44
|
"include": [
|
package/src/main.js
CHANGED
|
@@ -16,8 +16,28 @@
|
|
|
16
16
|
|
|
17
17
|
import askForPromise from "ask-for-promise"
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} Options
|
|
21
|
+
* @property {Object} data - The data structure to be copied.
|
|
22
|
+
* @property {Function|null} objectCallback - A function called for every object in the data structure.
|
|
23
|
+
* @property {Function|null} keyCallback - A function called for every property in the data structure.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
19
27
|
|
|
20
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Walk-async is a deep copy function that executes callback functions on every object and property.
|
|
31
|
+
* Callbacks are async functions.
|
|
32
|
+
*
|
|
33
|
+
* @param {Options} options - Object with following properties:
|
|
34
|
+
* - data - The data structure to be copied.
|
|
35
|
+
* - objectCallback - A function that will be called for every object in the data structure.
|
|
36
|
+
* - keyCallback - A function that will be called for every property in the data structure.
|
|
37
|
+
* @param {...any} args - Any additional arguments will be passed to the callback functions.
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise} - A promise that resolves to the immutable copy of the data structure.
|
|
40
|
+
*/
|
|
21
41
|
function walk ({
|
|
22
42
|
data:origin
|
|
23
43
|
, objectCallback = null
|
package/tsconfig.json
ADDED
package/types/main.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default walk;
|
|
2
|
+
export type Options = {
|
|
3
|
+
/**
|
|
4
|
+
* - The data structure to be copied.
|
|
5
|
+
*/
|
|
6
|
+
data: any;
|
|
7
|
+
/**
|
|
8
|
+
* - A function called for every object in the data structure.
|
|
9
|
+
*/
|
|
10
|
+
objectCallback: Function | null;
|
|
11
|
+
/**
|
|
12
|
+
* - A function called for every property in the data structure.
|
|
13
|
+
*/
|
|
14
|
+
keyCallback: Function | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} Options
|
|
18
|
+
* @property {Object} data - The data structure to be copied.
|
|
19
|
+
* @property {Function|null} objectCallback - A function called for every object in the data structure.
|
|
20
|
+
* @property {Function|null} keyCallback - A function called for every property in the data structure.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Walk-async is a deep copy function that executes callback functions on every object and property.
|
|
24
|
+
* Callbacks are async functions.
|
|
25
|
+
*
|
|
26
|
+
* @param {Options} options - Object with following properties:
|
|
27
|
+
* - data - The data structure to be copied.
|
|
28
|
+
* - objectCallback - A function that will be called for every object in the data structure.
|
|
29
|
+
* - keyCallback - A function that will be called for every property in the data structure.
|
|
30
|
+
* @param {...any} args - Any additional arguments will be passed to the callback functions.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise} - A promise that resolves to the immutable copy of the data structure.
|
|
33
|
+
*/
|
|
34
|
+
declare function walk({ data: origin, objectCallback, keyCallback }: Options, ...args: any[]): Promise<any>;
|
|
35
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":";;;;;;;;;oBAqBc,WAAS,IAAI;;;;iBACb,WAAS,IAAI;;AAJ3B;;;;;GAKG;AAKH;;;;;;;;;;;GAWG;AACH,qEARW,OAAO,WAIJ,GAAG,EAAA,gBAmChB"}
|