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

Feature request: pass index and array arguments in matchEach() #170

Open
OttoAllmendinger opened this issue Feb 21, 2018 · 1 comment
Open

Comments

@OttoAllmendinger
Copy link

These arguments are there for JS some(), every(), forEach() etc. They make it easy to test if an array is sorted, for instance:

> [1, 2, 3].every((v, i, arr) => (i === 0) || arr[i-1] < v)
true
> [1, 2, 3, 1].every((v, i, arr) => (i === 0) || arr[i-1] < v)
false

It would be cool if this could be written as

[1, 2, 3, 1].should.matchEach((v, i, arr) => (i === 0) || arr[i-1] < v)

The error message could contain the index at which it failed

@btd
Copy link
Member

btd commented Feb 24, 2018

hi,
sorry for silence, this sounds good to me. unfortunately i could not promise any eta for this. i am quite busy at work currently.

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

No branches or pull requests

2 participants