| Server IP : 138.197.176.125 / Your IP : 216.73.216.41 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/dev.wowchat.co_old/node_modules/or/ |
Upload File : |
Returns the element of an array when the callback returns true.
Purpose
---
This module provides a similar function as `Array.prototype.filter`, but
it returns the element, not an array. And it stops looping as soon as it
finds a result.
Usage
---
```javascript
var arr = ['item', 'other', 'finally'];
var item = or(arr, function(item) {
return item === 'other';
});
console.log(item); // "other"
// Real world example
var matchesSelector = or(['matchesSelector', 'mozMatchesSelector',
'webkitMatchesSelector', 'oMatchesSelector',
'msMatchesSelector'], function(shim) {
return shim in document.documentElement;
});
document.getElementById('some')[matchesSelector]('#some'); // true
```
API
---
The module returns a function accepting the following arguments:
- `array`: the array on which to iterate
- `callback`: the function being called
- `context`: the context on which to call the callback
Contributors
---
- [Florian Margaine](http://margaine.com)
License
---
MIT License.