<commit_before># cheerio-eq

Add `:eq()` selector functionality to [cheerio](https://github.com/cheeriojs/cheerio).

[![build status](https://secure.travis-ci.org/watson/cheerio-eq.png)](http://travis-ci.org/watson/cheerio-eq)

## What's the problem?

Cheerio sacrifices advanced CSS selector support for speed. This means
for instance that the `:eq()` selector isn't supported. The work-around
is normally to use the `.eq()` function instead:

```js
// this will not work:
$('div:eq(1)');

// use this instead:
$('div').eq(1);
```

This is a good alternative if you write the CSS selectors from scrach,
but what if you are working with selectors that already contain `:eq()`?
*Don't fear, cheerio-eq is here :)*

## Solution

The solution to the problem is to automatically parse the selector
string at run-time. So if you give cheerio-eq a selector like
`div:eq(1)` it will return the follwoing cheerio curser:
`$('div').eq(1)`.

It also works for complex selectors, so that `div:eq(1) h2:eq(0) span`
will be converted and interpreted as
`$('div').eq(1).find('h2').eq(0).find('span')`.

## Installation

```
npm install cheerio-eq
```

## Usage

```js
var cheerio = require('cheerio');
var find = require('cheerio-eq');

var html = '<div>foo</div><div>bar</div>';
var selector = 'div:eq(1)';<commit_msg>Emphasize silly catchphrase<commit_after># cheerio-eq

Add `:eq()` selector functionality to [cheerio](https://github.com/cheeriojs/cheerio).

[![build status](https://secure.travis-ci.org/watson/cheerio-eq.png)](http://travis-ci.org/watson/cheerio-eq)

## What's the problem?

Cheerio sacrifices advanced CSS selector support for speed. This means
for instance that the `:eq()` selector isn't supported. The work-around
is normally to use the `.eq()` function instead:

```js
// this will not work:
$('div:eq(1)');

// use this instead:
$('div').eq(1);
```

This is a good alternative if you write the CSS selectors from scrach,
but what if you are working with selectors that already contain `:eq()`?
**Don't fear, cheerio-eq is here :)**

## Solution

The solution to the problem is to automatically parse the selector
string at run-time. So if you give cheerio-eq a selector like
`div:eq(1)` it will return the follwoing cheerio curser:
`$('div').eq(1)`.

It also works for complex selectors, so that `div:eq(1) h2:eq(0) span`
will be converted and interpreted as
`$('div').eq(1).find('h2').eq(0).find('span')`.

## Installation

```
npm install cheerio-eq
```

## Usage

```js
var cheerio = require('cheerio');
var find = require('cheerio-eq');

var html = '<div>foo</div><div>bar</div>';
var selector = 'div:eq(1)';
{'fraction_non_alphanumeric': 0.16374714394516374, 'fraction_numerical': 0.008377760853008377, 'mean_word_length': 4.824833702882484, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7497384', 'n_tokens_mistral': 918, 'n_tokens_neox': 882, 'n_words': 299}