Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: last should allow set #76

Open
tjmehta opened this issue Mar 23, 2015 · 1 comment
Open

feature: last should allow set #76

tjmehta opened this issue Mar 23, 2015 · 1 comment

Comments

@tjmehta
Copy link
Owner

tjmehta commented Mar 23, 2015

last(arr, key, val)

@stoeffel
Copy link
Contributor

I would prefer to keep last simple.

You could use lens for that.

var lens = require('101/lens');
var last = require('101/last');

var lastLens = lens(
    last,
    function(val, arr) { 
      var clone = arr.slice(); 
      clone[arr.length-1] = val; 
      return clone; 
    }
);

lastLens([1, 2, 3, 4]); // => 4
lastLens.set(6, [1, 2, 3, 4]); // => [1, 2, 3, 6]

Or a new function setLast?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants