# count-sorted

> Count the number of elements in a sorted collection less than, equal, or greater than the given value

Latest version **1.0.0** (published 2015-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install count-sorted
pnpm add count-sorted
yarn add count-sorted
bun add count-sorted
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-09-03 |
| First published | 2015-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zoubin |
| Maintainers | zoubin |
| Keywords | count, sorted, indexOf, array, string, collection |

## Links

- npm: https://www.npmjs.com/package/count-sorted
- Repository: https://github.com/zoubin/count-sorted
- Homepage: https://github.com/zoubin/count-sorted#readme
- Issues: https://github.com/zoubin/count-sorted/issues
- npm.io page: https://npm.io/package/count-sorted

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-09-03

## README

# count-sorted
Count the number of elements in a sorted collection less than, equal, or greater than the given value.

The collection should be either ascending or non-ascending.

## Example

```javascript
var equal = require('count-sorted/equal');
var less = require('count-sorted/less');
var greater = require('count-sorted/greater');

console.log(
  equal([1, 1, 2, 2, 3, 3], 2)  // 2
);

console.log(
  less([1, 1, 2, 2, 3, 3], 2)  // 2
);

console.log(
  greater([1, 1, 2, 2, 3, 3], 2)  // 2
);

console.log(
  equal(
    [{ x: 1 }, { x: 1 }, { x: 2 }, { x: 2 }, { x: 3 }, { x: 3 }],
    { x: 2 },
    function (a, b) {
      return a.x - b.x;
    }
  )
  // 2
);

console.log(
  less(
    [{ x: 1 }, { x: 1 }, { x: 2 }, { x: 2 }, { x: 3 }, { x: 3 }],
    { x: 2 },
    function (a, b) {
      return a.x < b.x;
    }
  )
  // 2
);

console.log(
  greater(
    [{ x: 1 }, { x: 1 }, { x: 2 }, { x: 2 }, { x: 3 }, { x: 3 }],
    { x: 2 },
    function (a, b) {
      return a.x > b.x;
    }
  )
  // 2
);

```

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