@peter.naydenov/walk-async 6.0.0 → 6.1.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/.agents/skills/git-walk-async/SKILL.md +173 -0
- package/Changelog.md +7 -0
- package/Migration.guide.md +120 -0
- package/package.json +18 -8
- package/rollup.config.js +0 -41
- package/tsconfig.json +0 -11
- package/vitest.config.js +0 -8
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: git-walk-async
|
|
3
|
+
description: |
|
|
4
|
+
Help developers use `@peter.naydenov/walk-async` (the async `walk` from
|
|
5
|
+
the git-walk-async project, v6.0.0): write a deep copy with `await
|
|
6
|
+
walk({ data, keyCallback?, objectCallback?, timeout? })`, use the
|
|
7
|
+
`resolve` / `reject` pair inside callbacks to store or drop values, and
|
|
8
|
+
leverage the `timeout` option as a debugging safety net. Use when the
|
|
9
|
+
developer asks for a deep copy with simultaneous async transforms, a
|
|
10
|
+
deep `forEach` that can `await` work and drop or rewrite values, a
|
|
11
|
+
single-pass async clone that filters keys by name, or anything phrased
|
|
12
|
+
as "async deep copy / async deep clone / async deep walk / async deep
|
|
13
|
+
forEach" where the transforms do real async I/O. Do NOT use for: sync
|
|
14
|
+
walks (point to the sibling `@peter.naydenov/walk` instead),
|
|
15
|
+
deep-copying a `Map` / `Set` / `Date` / typed array (use
|
|
16
|
+
`structuredClone` for those), retry / abort semantics, or fixing bugs
|
|
17
|
+
in the library itself.
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# git-walk-async helper
|
|
21
|
+
|
|
22
|
+
A single-pass deep walk over a JavaScript data structure that runs two
|
|
23
|
+
optional async callbacks during the visit. Each callback can `await`
|
|
24
|
+
work and reports back via `resolve(value)` or `reject()`. A plain deep
|
|
25
|
+
copy is the no-callback case.
|
|
26
|
+
|
|
27
|
+
This is the **async sibling** of `@peter.naydenov/walk`. If your
|
|
28
|
+
callbacks don't actually need `await`, prefer the sync version — it's
|
|
29
|
+
noticeably faster because it avoids the promise machinery.
|
|
30
|
+
|
|
31
|
+
Source of truth:
|
|
32
|
+
- `src/main.js` — JSDoc on every public function and typedef (`walk`, `keyCallback`, `objectCallback`, `CallbackArgs`, `Resolve`, `Reject`, `Options`)
|
|
33
|
+
- `test/01-deepCopy.test.js` — plain deep copy
|
|
34
|
+
- `test/02-keyCallback.test.js` — primitive transforms
|
|
35
|
+
- `test/03-objectCallback.test.js` — object/array transforms
|
|
36
|
+
- `test/04-async.test.js` — real async work in callbacks
|
|
37
|
+
- `test/05-bothCallbacks.test.js` — interaction between the two
|
|
38
|
+
- `test/06-builtins.test.js` — Date / Map / Set / typed arrays / DOM nodes
|
|
39
|
+
- `README.md` — narrative docs (lead paragraph, "When to use `walk-async` vs `structuredClone`" callout, "Migrating from `@peter.naydenov/walk`" table, "Timeout" section, "Limitations")
|
|
40
|
+
|
|
41
|
+
## Procedure
|
|
42
|
+
|
|
43
|
+
1. **Map the developer's intent to the right shape of `await walk({ data, ... })` call**:
|
|
44
|
+
- "Just deep-copy this" / "give me an immutable copy" → `await walk({ data })` (no callbacks)
|
|
45
|
+
- "Drop a few keys while copying" → `await walk({ data, keyCallback })`; call `reject()` for the keys to drop
|
|
46
|
+
- "Mask a value" / "rewrite a value" → `await walk({ data, keyCallback })`; call `resolve(newValue)`
|
|
47
|
+
- "Skip a whole subtree" → `await walk({ data, objectCallback })`; call `reject()` at the right key
|
|
48
|
+
- "Await something inside the walk" (DB lookup, fetch, fs.readFile) → `await walk({ data, keyCallback: async ({ resolve, value, key }) => { const fresh = await fetch(value); resolve(fresh) } })`
|
|
49
|
+
- "Run a function on every leaf" (deep `forEach` with side effects) → `await walk({ data, keyCallback })`; the callback must still call `resolve(value)` (see gotcha below)
|
|
50
|
+
|
|
51
|
+
2. **Generate code that follows the real API contract**:
|
|
52
|
+
- ESM import: `import walk from '@peter.naydenov/walk-async'` (CJS: `require('@peter.naydenov/walk-async')`)
|
|
53
|
+
- **The call returns a Promise** — `await` it, or chain `.then`. Forgetting this is the #1 mistake.
|
|
54
|
+
- Options shape: `{ data, keyCallback?, objectCallback?, timeout? }`. Same names as the sync `walk`, plus `timeout`.
|
|
55
|
+
- Callback signature is `({ value, key, breadcrumbs, resolve, reject }, ...args)`. Always destructure the five fields from the first arg.
|
|
56
|
+
- Extra positional args passed to `walk` are forwarded to both callbacks as `...args`. Use this for context the callbacks need but you don't want to close over.
|
|
57
|
+
- **There is no `IGNORE` symbol.** The way to drop a key is `reject()` — that's it. The internal `IGNORE = Symbol('ignore___')` is private implementation detail; do not import, construct, or return it from user code. Returning it from a callback is a bug (it would be treated as a value to store, not a drop signal).
|
|
58
|
+
- The callback MUST call `resolve(...)` or `reject()` on every code path. If it doesn't, the walk promise never settles. The `timeout` option is the recommended way to catch this in development.
|
|
59
|
+
- `resolve` accepts anything a sync `walk` would accept: a primitive, a built-in like `Date` / `Map` / `Set`, or a plain object/array. A plain object/array is walked into (deferred). A `Date` / `Map` / `Set` is stored by reference.
|
|
60
|
+
|
|
61
|
+
3. **Apply the order-of-execution rules**:
|
|
62
|
+
- Within one level, keys are visited in `Object.keys` order on the current object/array.
|
|
63
|
+
- A level finishes before any nested walk starts. The new walk into a returned object/array is deferred.
|
|
64
|
+
- For the same value, `objectCallback` runs before `keyCallback`. If `objectCallback` resolves a new object, that object is what `keyCallback` sees when it processes the children.
|
|
65
|
+
- The root goes through `objectCallback` first (if defined), then its children are walked. Rejecting from the root `objectCallback` short-circuits the whole walk to `[]` (for array roots) or `{}` (for object roots).
|
|
66
|
+
- **Within a level, all keys are started concurrently** — they don't wait for each other to resolve before the next one is fired. They just have to finish before the next level begins. (This is the part where the async version earns its keep — `await` work in callbacks runs in parallel for free.)
|
|
67
|
+
|
|
68
|
+
4. **Surface only the relevant gotcha proactively** — pick at most one from the list below that applies to the current example, and only if the user is unlikely to know it:
|
|
69
|
+
- **The biggest trap: `walk-async` is `await`able.** A no-`await` call silently drops the result. `walk(...)` alone returns a Promise, not the copy.
|
|
70
|
+
- **Don't return values from callbacks.** Returning `value` or `IGNORE` from a callback is a sync-API leak — the walk ignores the return. The right call is `resolve(value)` or `reject()`. If a user just ported from sync `walk` and writes `return value` in their callback, their result will be `{}` (the empty container, because nothing was ever stored).
|
|
71
|
+
- **Callbacks must call `resolve` or `reject` on every code path.** A path that returns early or `throw`s without calling either will leave the walk promise pending forever. Either wire every path explicitly, or set `timeout` during development to surface these as a clear rejection with breadcrumbs of the stuck callbacks.
|
|
72
|
+
- **Don't `await walk-async` from inside a callback.** That's the first item on the Limitations list in the README — it corrupts the in-progress walk. If you need recursion, let the library handle it by `resolve`-ing a plain object/array from the callback.
|
|
73
|
+
- **Built-in types are not walked.** `Date`, `RegExp`, `Map`, `Set`, `WeakMap`, `WeakSet`, `ArrayBuffer`, `DataView`, typed arrays, DOM nodes, and functions are passed by reference. If the user wants a deep clone of a `Map`/`Set`/typed array, recommend `structuredClone` for that subtree, or do it themselves before calling `walk-async`.
|
|
74
|
+
- **`'simple'` is the storage type, not the return type.** A plain object or array resolved from `keyCallback` is re-typed and walked into (deferred). A `Date` resolved from `keyCallback` is `'simple'` and stored by reference. This is the v6.0.0 contract.
|
|
75
|
+
|
|
76
|
+
5. **If the request is "I just need a deep clone with no transforms"** (or the user doesn't actually need async), point them at `structuredClone` first (built into the platform, no dependency, no promise), and mention the sync `walk` as a fallback. Only use `walk-async` when real async I/O is happening inside the callbacks.
|
|
77
|
+
|
|
78
|
+
6. **If the request is for a sync walk**, route to `@peter.naydenov/walk` (separate package, similar interface, no promise machinery). The two are kept in sync semantically — same callback args, same three-outcome contract — but the sync version is faster when you don't need `await`.
|
|
79
|
+
|
|
80
|
+
## Output contract
|
|
81
|
+
|
|
82
|
+
- One focused code snippet, ESM by default (CJS if asked)
|
|
83
|
+
- The snippet must `await` the `walk` call (or chain `.then`); never produce a snippet that calls `walk` and ignores the returned Promise
|
|
84
|
+
- One line of context explaining which option(s) are used and why
|
|
85
|
+
- A pointer to the relevant source/test section if the developer wants to dig deeper
|
|
86
|
+
- Surface at most one relevant gotcha proactively, only if it applies to the example
|
|
87
|
+
- Never include a code example that uses `return value` / `return IGNORE` from a callback (those are the sync API)
|
|
88
|
+
- Never include a code example that `await`s `walk-async` from inside one of its own callbacks
|
|
89
|
+
|
|
90
|
+
## Failure handling
|
|
91
|
+
|
|
92
|
+
- The developer's use case genuinely ambiguous (e.g., "deep clone this") → point them at `structuredClone` for the no-deps no-callback case, then `walk-async` only if they want callbacks that `await`
|
|
93
|
+
- Developer reports a bug or unexpected behavior in `walk-async` itself → do NOT try to fix from this skill; route to the project source or maintainer
|
|
94
|
+
- Developer wants a walk that never settles, or hits the timeout, or sees the "callbacks still pending" error → point at the `Timeout` section in the README and the callback "every code path resolves" rule
|
|
95
|
+
- Developer asks for an API `walk-async` doesn't have (e.g., `walk.pick(...)`, `walk.omit(...)`) → do not invent it; point at the callback-factory pattern in the README ("Why one callback, not a list of methods" section) where such helpers belong outside the library
|
|
96
|
+
|
|
97
|
+
## Examples
|
|
98
|
+
|
|
99
|
+
**"Fetch fresh data for every URL string in the object, drop the rest"**
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import walk from '@peter.naydenov/walk-async'
|
|
103
|
+
|
|
104
|
+
const result = await walk({
|
|
105
|
+
data: source,
|
|
106
|
+
keyCallback: async ({ value, resolve, reject }) => {
|
|
107
|
+
if (typeof value !== 'string' || !/^https?:\/\//.test(value)) {
|
|
108
|
+
reject() // drop non-URL primitives
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const r = await fetch(value)
|
|
113
|
+
resolve(await r.json())
|
|
114
|
+
} catch (e) {
|
|
115
|
+
reject() // drop on network failure
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
timeout: 5000, // surfaces forgotten resolve/reject with breadcrumbs
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`await` is mandatory — without it you have a Promise, not a result. `reject()` (no argument) is the only way to drop a key. The `timeout` is a debugging safety net; remove or raise it for production. See `test/04-async.test.js` for the executable pattern.
|
|
123
|
+
|
|
124
|
+
**"Drop a whole `metadata` subtree"**
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import walk from '@peter.naydenov/walk-async'
|
|
128
|
+
|
|
129
|
+
const result = await walk({
|
|
130
|
+
data: user,
|
|
131
|
+
objectCallback: ({ key, value, resolve, reject }) =>
|
|
132
|
+
key === 'metadata' ? reject() : resolve(value)
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Rejecting from `objectCallback` drops the entire subtree (not just the immediate property). `keyCallback` is not used here, so primitive keys inside `metadata` are never visited. See `test/03-objectCallback.test.js`.
|
|
137
|
+
|
|
138
|
+
**"Deep `forEach` — log every leaf"**
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
import walk from '@peter.naydenov/walk-async'
|
|
142
|
+
|
|
143
|
+
await walk({
|
|
144
|
+
data: tree,
|
|
145
|
+
keyCallback: ({ value, key, breadcrumbs, resolve }) => {
|
|
146
|
+
console.log(`${breadcrumbs}/${key} = ${value}`)
|
|
147
|
+
resolve(value) // pass-through — required, otherwise this key is dropped
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The callback MUST call `resolve` or `reject` on every code path. A missing call leaves the walk pending — if you suspect this in your own code, set `timeout: 1000` during dev and look at which callback the rejection names. The `breadcrumbs` argument is a slash-delimited path starting with `'root'`, e.g. `'root/props/age'`. See "Deep 'forEach'" in `README.md`.
|
|
153
|
+
|
|
154
|
+
**"Port a sync `walk` call to `walk-async`"**
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
// walk (sync)
|
|
158
|
+
const result = walk ({
|
|
159
|
+
data: user,
|
|
160
|
+
keyCallback: ({ value, key, IGNORE }) => key === 'password' ? IGNORE : value
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
// walk-async — same shape, just promise-based
|
|
164
|
+
const result = await walk ({
|
|
165
|
+
data: user,
|
|
166
|
+
keyCallback: ({ value, key, resolve, reject }) => {
|
|
167
|
+
if ( key === 'password' ) reject () // was: return IGNORE
|
|
168
|
+
else resolve ( value ) // was: return value
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The mechanical translation: `return X` → `resolve(X)`, `return IGNORE` → `reject()`. Add `await` to the call. Add `timeout` during dev to surface any path that forgets to resolve/reject. The "Migrating from `@peter.naydenov/walk`" section in `README.md` has the full table.
|
package/Changelog.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
### 6.1.0 (2026-09-01)
|
|
6
|
+
- [x] Feature: Added a skill at `.agents/skills/git-walk-async/SKILL.md`;
|
|
7
|
+
- [x] Packaging: Added `.agents/skills` to the `"files"` allow-list in `package.json` so the Mavis skill ships with the npm package. AI-agent users can discover the walk-async skill from `node_modules` directly, without needing access to the source repo. The same allow-list also drops the dev-only `rollup.config.js`, `tsconfig.json`, and `vitest.config.js` that were leaking under the previous `.npmignore`-only packaging;
|
|
8
|
+
- [x] Docs: Prefilled `Migration.guide.md` for every major release: sync-`@peter.naydenov/walk` → `walk-async` (the README's "Migrating from `@peter.naydenov/walk`" table, folded in), v3.x → v6.x (callback signatures tightened with exported `Resolve` / `Reject` typedefs), v3.0.x → v3.1.x (the `timeout` option, the built-in-type pass-by-reference fix from v3.1.2, and the v3.0.6/v3.0.7 root-callback bug fixes), the existing v2.x → v3.x root-callback entry, v1.x → v2.x (ES module + `dist` + `exports`), and v1.0.0 → v1.x (the early null/undefined, DOM-node, and collection-container fixes). The README still has a copy of the sync-`walk` → `walk-async` table — flag for a follow-up if you want the README trimmed to a one-liner pointer so the docs aren't split across two files;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
5
12
|
### 6.0.0 (2026-08-08)
|
|
6
13
|
- [x] Allign version numbers with `@peter.naydenov/walk`. We jumping from 3.1.3 to 6.0.0;
|
|
7
14
|
- [x] Types: Tighten callback signatures in `types/main.d.ts`. `keyCallback` and `objectCallback` are now typed as `KeyCallback` / `ObjectCallback` over a `CallbackArgs` shape (`value`, `key`, `breadcrumbs`, `resolve`, `reject`); `resolve` and `reject` are exported as `Resolve` / `Reject` types so TypeScript users get autocomplete. Driven from JSDoc in `src/main.js`; regenerate with `npm run build`;
|
package/Migration.guide.md
CHANGED
|
@@ -1,8 +1,94 @@
|
|
|
1
1
|
# Migration Guides
|
|
2
2
|
|
|
3
|
+
Upgrade notes for non-trivial `walk-async` releases. For the full per-release list of changes, see the [Changelog](Changelog.md); this guide focuses on what *you* have to change in your code.
|
|
4
|
+
|
|
5
|
+
Most common first, then version history newest-first.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## From `@peter.naydenov/walk` (sync sibling)
|
|
10
|
+
|
|
11
|
+
`walk-async` is the async sibling of [`@peter.naydenov/walk`](https://github.com/PeterNaydenov/walk). They share the same callback parameter names (`value`, `key`, `breadcrumbs`) and the same three-outcome contract. The only mechanical change is how you express the return value:
|
|
12
|
+
|
|
13
|
+
| `walk` (sync) | `walk-async` (async) |
|
|
14
|
+
| -------------------------------- | ---------------------------- |
|
|
15
|
+
| `return value` | `resolve(value)` |
|
|
16
|
+
| `return newObject` | `resolve(newObject)` |
|
|
17
|
+
| `return IGNORE` | `reject()` |
|
|
18
|
+
|
|
19
|
+
The options shape is identical: `{ data, keyCallback, objectCallback }`. `walk-async` adds an optional `timeout` (milliseconds). The walk call itself becomes an `await` (or `.then`).
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// walk
|
|
23
|
+
const result = walk ({
|
|
24
|
+
data: user,
|
|
25
|
+
keyCallback: ({ value, key, IGNORE }) => key === 'password' ? IGNORE : value
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// walk-async — same shape, just promise-based
|
|
29
|
+
const result = await walk ({
|
|
30
|
+
data: user,
|
|
31
|
+
keyCallback: ({ value, key, resolve, reject }) => {
|
|
32
|
+
if ( key === 'password' ) reject ()
|
|
33
|
+
else resolve ( value )
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If your callbacks don't actually need async work, prefer the sync `walk` — it's noticeably faster because it avoids the promise machinery. Reach for `walk-async` only when you have real async work inside the callbacks (database lookups, network calls, file reads, etc.) and the cost of multiple `walk` calls would be unacceptable.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## From v.3.x.x - v.6.x.x
|
|
43
|
+
|
|
44
|
+
v6 is a version-alignment release with `@peter.naydenov/walk` (the sync sibling). **Behaviour is unchanged from v.3.1.3** — every v3.x callback that worked in v3.1.3 still works identically in v6.x. The only user-facing change is on the TypeScript side.
|
|
45
|
+
|
|
46
|
+
### Callback signatures are now strictly typed
|
|
47
|
+
|
|
48
|
+
`keyCallback` and `objectCallback` are now typed as `KeyCallback` / `ObjectCallback` over a `CallbackArgs` shape, and `resolve` / `reject` are exported as `Resolve` / `Reject` typedefs so TypeScript users get autocomplete. If your callbacks already called `resolve(value)` / `reject()` correctly, they keep working unchanged at runtime; TypeScript will now catch signature mistakes at compile time.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// v3.x.x - call signatures inferred from usage; no Resolve/Reject typedefs
|
|
52
|
+
function keyCallback ({ value, key, resolve, reject }) {
|
|
53
|
+
if (key === 'password') reject()
|
|
54
|
+
else resolve(value)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// v6.x.x - same code, now type-checked against the exported Resolve / Reject
|
|
58
|
+
import type { KeyCallback, Resolve, Reject } from '@peter.naydenov/walk-async'
|
|
59
|
+
const keyCallback: KeyCallback = ({ value, key, resolve, reject }) => {
|
|
60
|
+
if (key === 'password') reject()
|
|
61
|
+
else (resolve as Resolve)(value)
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If you're on JavaScript (not TypeScript), there is nothing to change.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## From v.3.0.x - v.3.1.x
|
|
70
|
+
|
|
71
|
+
A new optional `timeout` (milliseconds) was added. When set, the walk promise is rejected if any callback has not called `resolve` or `reject` in time; the error message lists the breadcrumbs of every still-pending callback so the broken code path can be found directly.
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
// v3.0.x
|
|
75
|
+
const result = await walk ({ data, keyCallback }) // hangs forever if a callback forgets to resolve
|
|
76
|
+
|
|
77
|
+
// v3.1.x
|
|
78
|
+
const result = await walk ({ data, keyCallback, timeout: 5000 })
|
|
79
|
+
// if a callback never settles, the walk promise is rejected with:
|
|
80
|
+
// walk-async: timed out after 5000ms; callbacks still pending:
|
|
81
|
+
// - keyCallback at 'root/props/age'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This is purely additive — the option is optional, off by default, and identical to v3.0.x when omitted. The pre-existing v3.0.6 and v3.0.7 bug fixes (`__proto__` no longer replacing the copy's prototype; top-level property named `root` no longer dropped; `objectCallback` resolving the root with a primitive no longer crashes) shipped in this window. Correct code gets more lenient, not more strict.
|
|
85
|
+
|
|
86
|
+
This is also the window when `Date`, `RegExp`, `Map`, `Set`, `WeakMap`, `WeakSet`, `ArrayBuffer`, `DataView`, and typed arrays became passed by reference (v.3.1.2). They used to come out as empty `{}` — that was almost always a bug, so the fix is a no-op for working code, but if you were somehow relying on the broken behaviour, this is the release that changed it.
|
|
87
|
+
|
|
3
88
|
|
|
4
89
|
|
|
5
90
|
## From v.2.x.x - v.3.x.x
|
|
91
|
+
|
|
6
92
|
Difference between v.2.x.x and v.3.x.x is that object callbacks are triggered on 'root' object as well. So if you have object callbacks that are not working as expected after upgrade, you need to add extra line of code for version 3.
|
|
7
93
|
|
|
8
94
|
```js
|
|
@@ -21,3 +107,37 @@ function oCallbackFn ({ value:o, key, IGNORE, breadcrumbs }) {
|
|
|
21
107
|
Everything else works the same.
|
|
22
108
|
|
|
23
109
|
|
|
110
|
+
|
|
111
|
+
## From v.1.x.x - v.2.x.x
|
|
112
|
+
|
|
113
|
+
v2 converted the package to a proper ES module and added a built `dist/` (CommonJS, ESM, UMD) plus a `package.json` `exports` map and a Rollup build pipeline.
|
|
114
|
+
|
|
115
|
+
**For most users the upgrade is automatic** — your bundler / runtime picks the right build from the `exports` map. The only breaking case is if you were reaching into the package by path:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
// v1.x.x - CommonJS; the package exports a function
|
|
119
|
+
const walk = require ( '@peter.naydenov/walk-async' )
|
|
120
|
+
|
|
121
|
+
// v2.x.x - ES module; the default export is the walk function
|
|
122
|
+
import walk from '@peter.naydenov/walk-async'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
If you were loading source directly (`require('@peter.naydenov/walk-async/src/main')` or similar), use the package's `exports` map (`@peter.naydenov/walk-async/src/main`) instead, or just import the default.
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## From v.1.0.0 - v.1.x.x
|
|
130
|
+
|
|
131
|
+
v1.x added a series of small but important fixes. If you are still on v.1.0.0, the relevant ones are:
|
|
132
|
+
|
|
133
|
+
### v.1.1.0 - `null` and `undefined` resolution
|
|
134
|
+
|
|
135
|
+
Returning `null` or `undefined` from a callback is now stored as the literal value (not treated as "skip"). If you were relying on `null` to mean "drop this key", switch to `reject()` (in v6.x) or to whatever the v1.x equivalent was — the API has since changed.
|
|
136
|
+
|
|
137
|
+
### v.1.2.0 - DOM nodes copied by reference
|
|
138
|
+
|
|
139
|
+
`walk-async` no longer descends into HTML DOM nodes — they are passed through by reference. This is the same contract as functions, and (added later in v.3.1.2) `Date` / `Map` / `Set` / `RegExp` / typed arrays.
|
|
140
|
+
|
|
141
|
+
### v.1.3.0 - `undefined`-valued keys preserved; collection containers
|
|
142
|
+
|
|
143
|
+
Keys whose value is `undefined` are now copied (they were being dropped in v.1.0.0). Also, callbacks can now extract data into provided collection containers during iteration.
|
package/package.json
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peter.naydenov/walk-async",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Deep copy with fine control during the process. Can be used also as a deep forEach function",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "./dist/walk-async.umd.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./types/main.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"import": "
|
|
11
|
-
"require": "
|
|
10
|
+
"import": "./dist/walk-async.esm.mjs",
|
|
11
|
+
"require": "./dist/walk-async.cjs",
|
|
12
12
|
"default": "./dist/walk-async.umd.js"
|
|
13
13
|
},
|
|
14
14
|
"./package.json": "./package.json",
|
|
15
15
|
"./dist/*": "./dist/*",
|
|
16
16
|
"./src/*": "./src/*"
|
|
17
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src",
|
|
21
|
+
"types",
|
|
22
|
+
"README.md",
|
|
23
|
+
"Changelog.md",
|
|
24
|
+
"Migration.guide.md",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
".agents/skills"
|
|
27
|
+
],
|
|
18
28
|
"scripts": {
|
|
19
29
|
"test": "vitest run",
|
|
20
30
|
"test:watch": "vitest",
|
|
@@ -35,11 +45,11 @@
|
|
|
35
45
|
"@rollup/plugin-commonjs": "^29.0.3",
|
|
36
46
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
37
47
|
"@rollup/plugin-terser": "^1.0.0",
|
|
38
|
-
"@vitest/coverage-v8": "4.1.
|
|
39
|
-
"rollup": "^4.
|
|
48
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
49
|
+
"rollup": "^4.63.1",
|
|
40
50
|
"typescript": "^7.0.2",
|
|
41
|
-
"vite": "^8.2.
|
|
42
|
-
"vitest": "4.1.
|
|
51
|
+
"vite": "^8.2.2",
|
|
52
|
+
"vitest": "4.1.11"
|
|
43
53
|
},
|
|
44
54
|
"vitest": {
|
|
45
55
|
"coverage": {
|
package/rollup.config.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve'
|
|
2
|
-
import commonjs from '@rollup/plugin-commonjs'
|
|
3
|
-
import terser from '@rollup/plugin-terser';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default [
|
|
7
|
-
// browser-friendly UMD build
|
|
8
|
-
{
|
|
9
|
-
input: 'src/main.js',
|
|
10
|
-
output: {
|
|
11
|
-
name: 'walkAsync',
|
|
12
|
-
file: 'dist/walk-async.umd.js',
|
|
13
|
-
format: 'umd',
|
|
14
|
-
globals: {
|
|
15
|
-
'ask-for-promise': 'askForPromise'
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
external : [ 'ask-for-promise' ],
|
|
19
|
-
plugins: [
|
|
20
|
-
resolve(), // so Rollup can find `ms`
|
|
21
|
-
commonjs() // so Rollup can convert `ms` to an ES module
|
|
22
|
-
, terser()
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
// CommonJS (for Node) and ES module (for bundlers) build.
|
|
27
|
-
// (We could have three entries in the configuration array
|
|
28
|
-
// instead of two, but it's quicker to generate multiple
|
|
29
|
-
// builds from a single configuration where possible, using
|
|
30
|
-
// an array for the `output` option, where we can specify
|
|
31
|
-
// `file` and `format` for each target)
|
|
32
|
-
{
|
|
33
|
-
input: 'src/main.js',
|
|
34
|
-
external: ['ask-for-promise'],
|
|
35
|
-
output: [
|
|
36
|
-
{ file: 'dist/walk-async.cjs' , format: 'cjs' },
|
|
37
|
-
{ file: 'dist/walk-async.esm.mjs', format: 'es' }
|
|
38
|
-
],
|
|
39
|
-
plugins: [ terser() ]
|
|
40
|
-
}
|
|
41
|
-
];
|
package/tsconfig.json
DELETED