0.2.0 ā€¢ Published 9 years ago

eslisp-fancy-function v0.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 years ago

eslisp-fancy-function npm.io npm.io npm.io

An eslisp macro that works like an the usual lambda expression macro but also

  • parses splats (atoms starting with ...) in the arguments and turns them into appropriate variable assignments prepended to the function body, and
  • implicitly returns the last thing in the body if it's an expression.

Note that despite the name, this module is strictly a function expressions (lambda-ish) macro, not a function declaration. I'll rearrange that eventually.

Example

(macro fun (require "eslisp-fancy-function"))
(fun (a b ...c d) (* a b d))

ā†“

(function (a, b) {
    var c = Array.prototype.slice.call(arguments, 2, -1);
    var d = arguments[arguments.length - 1];
    return a * (b * d);
});

See the tests for fuller usage.

License

ISC.

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago