Skip to content

Commit

Permalink
improved array iterator with keys
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 19, 2024
1 parent f12651c commit e8607c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.12.13] - Unreleased
### Fixed
- Improved the code of iterator with an array.

## [1.12.12] - 2024-11-19
### Added
- New option `autoDataVarname` to replace `useWith`.
Expand Down Expand Up @@ -271,6 +275,7 @@ First version
[#74]: https://github.com/oscarotero/vento/issues/74
[#83]: https://github.com/oscarotero/vento/issues/83

[1.12.13]: https://github.com/oscarotero/vento/compare/v1.12.12...HEAD
[1.12.12]: https://github.com/oscarotero/vento/compare/v1.12.11...v1.12.12
[1.12.11]: https://github.com/oscarotero/vento/compare/v1.12.10...v1.12.11
[1.12.10]: https://github.com/oscarotero/vento/compare/v0.12.9...v1.12.10
Expand Down
4 changes: 1 addition & 3 deletions plugins/for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ function toIterator(
}

if (Array.isArray(item)) {
return withKeys
? Object.entries(item).map(([key, value]) => [parseInt(key, 10), value])
: item;
return withKeys ? item.map((value, i) => [i, value]) : item;
}

if (typeof item === "function") {
Expand Down

0 comments on commit e8607c4

Please sign in to comment.