`Array.some` for iterables.
npm install iterable-some




::some()
========
Array.some for iterables.
Installation
------------
``sh`
$ npm install iterable-some
Usage
-----
`js
import some from 'iterable-some/module';
// or:
const some = require('iterable-some');
`
These are all true:
`js
[true]::some(function() { return this; });
[false, null, 0, 'truthy']::some(function() { return this; });
new Set([5])
::some(function() { return this > 4; })
;
new Map([2, 'nope'], [5, 'yup'])
::some(function() { return this === 'yup'; })
;
`
– and these are false:
`js
[false, false]::some(function() { return this; });
[]::some(function() { return this; });
new Set([3, 1, 0, 4])
::some(function() { return this > 4; })
;
`
::some() is lazy – just as Array.some. It stops executing the condition as soon as it finds one match:
`js`
[0, 1, 'not checked']::some(function() {
if (this > 0) return true;
if (this === 'not checked') throw 'No worries, this won’t be thrown.'
});
It works great with trine-style libraries:
`js
import isTruthy from 'this-is-truthy/module';
[null, undefined, 0, NaN]::some(isTruthy);
//» false
`
Huh?
----
If you’re wondering what the ::` thing means, you’d better read this excellent overview by @jussi-kalliokoski or have a look at the function bind syntax proposal.
License
-------
[MIT][] © [Tomek Wiszniewski][]
[MIT]: ./License.md
[Tomek Wiszniewski]: https://github.com/tomekwi