condense

Utility for condensing rest arguments

Usage no npm install needed!

<script type="module">
  import condense from 'https://cdn.skypack.dev/condense';
</script>

README

condense

Build Status

This library is a manifestation against so much hated Array.prototype.slice.call(arguments). Library provides decorator function that can be used to condense all the rest parameters of a function into a last one:

var condense = require("condense")
var apply = condense(function(f, params) {
  "use strict";
  return f.apply(f, params)
})

Which is basically an alternative to writing this:

var apply = function(f) {
  "use strict";
  var params = Array.prototype.slice.call(arguments, 1)
  return f.apply(f, params)
}

Also desugared version of upcoming rest parameters feature (that hopefully will kill arguments):

function apply(f, ...args) {
  "use strict";
  return f.apply(f, args)
}

Now install this library and never ever write Array.prototype.slice.call(arguments) again! And yes it's slower but if it's highly unlikely to be a bottlneck in you program and if it will turn out to be you can always optimize by replacing back to you know what.

Install

npm install condense