sparse-array
Advanced tools
Comparing version 1.1.2 to 1.2.0
10
index.js
@@ -88,4 +88,12 @@ 'use strict' | ||
find (finder) { | ||
let i = 0, found, last | ||
while ((i < this.length) && !found) { | ||
last = this.get(i) | ||
found = finder(last) | ||
i++ | ||
} | ||
return found ? last : undefined | ||
} | ||
_internalPositionFor (index, noCreate) { | ||
@@ -92,0 +100,0 @@ const bytePos = this._bytePosFor(index, noCreate) |
{ | ||
"name": "sparse-array", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Sparse array implementation in JS with no dependencies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,4 +51,11 @@ # sparse-array | ||
Find: | ||
```js | ||
const firstEven = arr.find((elem) => (elem % 2) === 0) | ||
``` | ||
## License | ||
ISC |
8479
9
289
60