Add for_each for arrays.

This commit is contained in:
Stephen Chung
2022-12-25 12:44:49 +08:00
parent fd401f3048
commit 52d23522e6
4 changed files with 172 additions and 62 deletions

View File

@@ -57,8 +57,9 @@ Net features
### Enhanced array API
* Array methods that take a function pointer, usually a closure (e.g. `map`, `filter`, `index_of` etc.), can now provide a closure with one few parameter but binds the first parameter to `this`.
* This vastly improves performance when working with arrays of object maps by avoiding unnecessary cloning of large types.
* Array methods that take a function pointer, usually a closure (e.g. `map`, `filter`, `index_of`, `reduce` etc.), can now bind the array element to `this` when calling a closure.
* This vastly improves performance when working with arrays of large types (e.g. object maps) by avoiding unnecessary cloning.
* `for_each` is also added for arrays, allowing a closure to mutate array elements (bound to `this`) in turn.
Enhancements
------------