# or

> Returns an element from an array when it matches a condition

Latest version **0.2.0** (published 2013-02-27) · 0 weekly downloads

## Install

```sh
npm install or
pnpm add or
yarn add or
bun add or
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2013-02-27 |
| First published | 2013-02-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Florian Margaine |
| Maintainers | ralt |
| Keywords | array, utils |

## Links

- npm: https://www.npmjs.com/package/or
- Repository: https://github.com/Ralt/or
- Issues: https://github.com/Ralt/or/issues
- npm.io page: https://npm.io/package/or

## Recent versions

- 0.2.0 (latest) — 2013-02-27
- 0.1.0 — 2013-02-26

## README

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.

---
_Source: https://npm.io/package/or · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
