Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpommerening/babel-plugin-relooper
https://github.com/jpommerening/babel-plugin-relooper
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jpommerening/babel-plugin-relooper
- Owner: jpommerening
- Created: 2015-09-30T15:11:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-02T09:05:43.000Z (about 9 years ago)
- Last Synced: 2024-04-14T15:48:52.829Z (7 months ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# babel-plugin-relooper
> Convert the Array methods `.map`, `.filter`, `.reduce`, `.every` and `.some`
> to plain loops.## Why?
The array methods are awesome. I use them all the time. Unfortunately,
sometimes, when you're processing really large arrays, all those function calls
add up and can really [slow things down][jsperf].Luckily, a [sufficiently smart compiler][smart] can just optimize the function
calls away as long as we don't use recursion or some other weird constructs,
right? Sadly, current JavaScript engines don't appear to be sufficiently smart
in that regard yet.This [Babel][babel] plugin converts calls to the array methods back to plain
loops, as long as Babel can figure out you are calling them on an actual array
and you're using anonymous function expressions.That way I can continue to slam `.map`, `.reduce` and whathaveyou everywhere
without giving a damn about performance. Hooray!*Note:* Currently pretty experimental & under development.
[jsperf]: http://jsperf.com/native-vs-array-js-vs-underscore/144 "jsPerf - comparing different looping strategies"
[smart]: http://c2.com/cgi/wiki?SufficientlySmartCompiler "Sufficiently Smart Compiler"
[babel]: https://babeljs.io "Babel – a JavaScript compiler"