Skip to content

Commit

Permalink
Javascript: Add iterable instance to Diff for destructuring.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dmsnell and GrosSacASac committed May 2, 2024
1 parent 5337709 commit 70f5f62
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
Loading

0 comments on commit 70f5f62

Please sign in to comment.