Giter VIP home page Giter VIP logo

babel-plugin-partial-application's People

Contributors

haltcase avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

5310 d3dc

babel-plugin-partial-application's Issues

Using one argument few times

It will be nice to have ability to use an argument few times in function body.

For example, we want to create isNaN function, which looks like this in classic JavaScript:

const isNaN = x => x !== x

So we want to write something like this:

const isNaN = _ !== _

But it will be compiled into

const isNaN = (_a, _b) => {
  return _a !== _b
}

Not into

const isNaN = _a => {
  return _a !== _a
}

This ability requires new syntax. For example Clojure anonymous function syntax:

(def isNaN #(= % %))

Or:

(def isNaN #(= %1 %1))

In this Clojure examples we use % for 1-arity functions, and %1, %2, ..., %n for n-arity functions.
Rewritten with this syntax example:

const isNaN = % !== %

And cases when we need more than one argument:

const array = [1, 2, 3, 4, 5]
array.reduce(%1 + %2)
// -> 15

Of course not necessary use % as placeholder, I use it just to keep a parallel with Clojure.

Deprecation in favor of `param.macro`

I've decided to deprecate this package in favor of my newer project param.macro. It's more focused, explicit, and stable, though it does intentionally lack a few of the features from this plugin to achieve those things. It has the same online playground as this plugin so you can compare it immediately in your browser.

The main difference is that the feature set has been split into two symbols instead of one, _ and it. This is phenomenally easier to handle (param.macro uses far less code than this plugin) and also easier to understand. There are clear semantic differences between the two. From param.macro's readme:

_ will always traverse upward out of the nearest function call, while it will be transformed in place.

it will always refer to the first argument even when used multiple times in an argument list. Each _ will always refer to the next argument.

Features supported by both:

  • lambda parameters ( using a separate it symbol )
  • argument placeholders ( using _ )
  • custom tokens ( using aliased imports )
  • arbitrary expressions & assignment ( object placeholders, template literals, binary expressions, etc. )

Features not intended for param.macro:

In the interest of readable, easily understandable code these features are intentionally left out.

  • positional placeholders
  • default parameters
  • usage without import

Features being considered for param.macro:

  • spread placeholder

If anyone has questions on the differences or how to migrate let me know, but the readme and the playground should help a lot with that.

Repo / npm package takeover

If you're interested in taking over the GitHub repo and the npm package, hit me up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.