babel-plugin-assume-first-argument

Plugin simplifying arrow functions when working with the common case

Usage no npm install needed!

<script type="module">
  import babelPluginAssumeFirstArgument from 'https://cdn.skypack.dev/babel-plugin-assume-first-argument';
</script>

README

Assume First Argument

Babel plugin which reuses a uncommon unary operator for a more common purpose.

['foo', 'bar'].map(~length); // => ['foo', 'bar'].map(uid => uid.length);
[{ foo: 1 }, { foo: 2 }, { foo: 3 }].map(~foo % 2 === 0); // => ...map(uid => uid.foo % 2 === 0)

I initially wanted to use a better syntax, but realized that you can only write Babel plugins for Javascript syntax that they support. This may change in the future.