This repository was archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
JavaScript: Diff is not iterable #39
Comments
@NeilFraser A quick comment on whether the new JS API behaviour which breaks Array destructuring is intentional or whether it's a bug and will be fixed would be very helpful - thanks! |
I think the API behaviour change is not intentional
add the following
Another possible is to cast to a real Array:
|
dmsnell
added a commit
to dmsnell/diff-match-patch
that referenced
this issue
May 2, 2024
Resolves google#39 It can be useful to extract `Diff` elements using destructuring assignment. For example: ```js const a = dmp.diff_main('abc', 'ab123c', false); const [eq, str] = a[0]; ``` Because the `Diff` object is not an array, however, this is not possible, even though it acts like an array. In this patch a new `Symbol.iterator` method is added to the `Diff` class so that this pattern can be used. Props: @JackuB, @GrosSacASac, @TheSpyder Co-authored-by: Cyril Walle <cyril.walle@protonmail.com>
I've incorporated a |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There was a change in JS version cd60d24#diff-5270d640a6c9c1b0590326b029d71ec8R76 from plain Array to a
diff_match_patch.Diff
Object that's trying to emulate Array.The new object is not iterable, which messes up for example with Array destructing:
[Symbol.iterator]
would do the trick, but its browser support is questionableThe text was updated successfully, but these errors were encountered: