Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Releases: haltcase/babel-plugin-partial-application

v1.6.1

30 Jun 20:09
Compare
Choose a tag to compare

Bug fixes

  • fix error with template literals inside object placeholder calls (f01e6e5)

Playground

try it live

  • log the result of the last line if it's an expression (05d4a39)

v1.6.0

23 Jun 07:14
Compare
Choose a tag to compare

All new features have been added to the online playground!

This release adds positional placeholders! Sometimes called swizzle or rearg,
you can partially apply arguments in a different order than the function normally
accepts, or use a single argument multiple times.

Let's say you want to reorder the arguments of lodash.get(), which normally has
a signature of object, path, defaultValue, to path, defaultValue, object:

// forget that lodash/fp even exists for a second :)
import { get } from 'lodash'

// reorder the arguments so the data is accepted last
const getFunctional = get(_`3`, _`1`, _`2`)

getFunctional('color', 'blue', { color: 'green' })
// -> 'green'

You can also use positional placeholders to reuse a single argument, for example
to create a function checking if something is equal to itself ( NaN never is ):

const isSameThing = _`1` === _`1`

isSameThing('yes!')
// -> true

isSameThing(NaN)
// -> false

Features

  • add positional placeholder syntax (dbc9f9f)

Bug fixes

  • fix mid-chain properties in applied call arguments being compiled if they look like a placeholder (6bc3d01)
  • track custom tokens per file to prevent leaks into others, breaking their placeholders (2e39c99)

Playground

The playground got a few UI & UX improvements:

  • 'send to editor' buttons on all JS code blocks for easily trying out the examples
  • a 'go to top' button in the readme when you've scrolled down
  • better URL handling (used for linking to the readme and specific sections of it)

v1.5.0

10 Jun 08:29
Compare
Choose a tag to compare

All new features have been added to the online playground!

The headline for this release is default parameter support:

const greet = name => console.log(`Hello, ${name}!`)

const sayHelloToPerson = greet(_.name = 'world')

sayHelloToPerson({ name: 'Arlene' })
// -> Hello, Arlene!

sayHelloToPerson({ /* nameless */ })
// -> Hello, world!

This is supported only as arguments in function calls, for basic & object placeholders.

Features

  • add default parameter capability for basic placeholders & object placeholders (a7640ba)

Bug fixes

  • fix template literal compilation so that member expression properties are ignored, ie. _._ is not two placeholders and now compiles to _obj._ (e3a578b)

v1.4.0

20 May 05:22
Compare
Choose a tag to compare

All new features have been added to the online playground!

This release improves spread placeholders by supporting them in member expressions
and fixes an issue that occurs when passing an object placeholder as an argument
to an object placeholder call ( along with further nesting into binary expressions ).

In prior releases, this was the situation:

// worked fine
blah.foo(..._)

// 'Placeholder spread is unsupported outside call expressions.'
_.foo(..._)

... but this will now compile just fine to:

(_obj, ..._spr) => {
  return _obj.foo(..._spr)
}

The other fixes are for these situations:

_.foo(_.bar)
_.foo(_.baz())
_.foo(_.name === 'Dude')

... which would all fail with a container is falsy error. Now they work as expected.

Features

  • support spread placeholders in member calls like _.foo(..._) (b766359)

Bug fixes

  • object placeholders and some previously busted binary expressions now work correctly as arguments to object placeholder member calls ( _.foo(_.bar) ) (4aaadb5)

v1.3.0

28 Apr 22:40
Compare
Choose a tag to compare

This is a small release - the only code related changes were refactors, mostly to the AST traversal strategy. Output shouldn't be affected.

v1.2.0

25 Apr 21:27
Compare
Choose a tag to compare

All new features have been added to the online playground!

This release adds the pretty cool feature of setting a custom placeholder by importing or requireing the plugin, but this is removed at compile time so no runtime dependency is required.

import $ from 'babel-plugin-partial-application'

const log = console.log($, $.foo)
log(42, { foo: 'bar' })

// -> 42 bar

This should keep linters off your back without declaring a global, and should help out TypeScript & Flow users also.

Features

  • allow setting a custom placeholder with import or require (0429c67)
  • support template literals (1062b58)
  • support nested structures & multiple placeholders in binary expressions (cf58624)

v1.1.0

16 Apr 14:26
Compare
Choose a tag to compare

Features

  • support binary expressions (dab9059)

v1.0.0

14 Apr 21:44
Compare
Choose a tag to compare

First official release 🎉