# next-page-kit

> Helper for handle next-next page

Latest version **1.0.0** (published 2020-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-page-kit
pnpm add next-page-kit
yarn add next-page-kit
bun add next-page-kit
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-02-15 |
| First published | 2016-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | magicdawn |
| Maintainers | magicdawn |
| Keywords | next, page, next-next |

## Links

- npm: https://www.npmjs.com/package/next-page-kit
- Repository: https://github.com/magicdawn/next-page-kit
- Homepage: https://github.com/magicdawn/next-page-kit#readme
- Issues: https://github.com/magicdawn/next-page-kit/issues
- npm.io page: https://npm.io/package/next-page-kit

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [cheerio](https://npm.io/package/cheerio.md) ^0.22.0
- [umi-request](https://npm.io/package/umi-request.md) ^1.2.18

## Recent versions

- 1.0.0 (latest) — 2020-02-15
- 0.0.3 — 2016-06-25
- 0.0.2 — 2016-06-25
- 0.0.1 — 2016-06-25

## README

<!-- AUTO_GENERATED_UNTOUCHED_FLAG -->

# next-page-kit

> Helper for handle next-next page

[![Build Status](https://img.shields.io/travis/magicdawn/next-page-kit.svg?style=flat-square)](https://travis-ci.org/magicdawn/next-page-kit)
[![Coverage Status](https://img.shields.io/codecov/c/github/magicdawn/next-page-kit.svg?style=flat-square)](https://codecov.io/gh/magicdawn/next-page-kit)
[![npm version](https://img.shields.io/npm/v/next-page-kit.svg?style=flat-square)](https://www.npmjs.com/package/next-page-kit)
[![npm downloads](https://img.shields.io/npm/dm/next-page-kit.svg?style=flat-square)](https://www.npmjs.com/package/next-page-kit)
[![npm license](https://img.shields.io/npm/l/next-page-kit.svg?style=flat-square)](http://magicdawn.mit-license.org)

## Install

```sh
$ npm i -S next-page-kit
```

## API

```js
const NextPageKit = require('next-page-kit')
```

### `n = new NextPageKit(options)`

| `options`            | type                                   | remark                    |
| -------------------- | -------------------------------------- | ------------------------- |
| `options.charset`    | `type: String`, allowed`utf8` or `gbk` | the page charset          |
| `options.getCurrent` | function `($: cheerio) => any`         | returns current paeg data |
| `options.hasNext`    | function `($: cheerio) => Boolean`     | test has next page        |
| `options.getNext`    | function `($: cheerio) => String`      | get next page url         |

```js
const n = new NextPageKit({
  getCurrent($) {
    return $('img')
      .map(function() {
        return $(this).attr('src')
      })
      .toArray()
  },
  hasNext($) {},
  getNext($) {},
})

// Promise<string[]>
// all img src
n.run()
```

### `n.run(url, options)`

- `url`: the entry
- `options`:
  - `limit`: page limit

### more see `types/index.d.ts`

```ts
/// <reference types="cheerio" />

export type Charset = 'utf8' | 'gbk'

export default class NextPageKit<T> {
  constructor(options: {
    charset?: Charset
    getCurrent($: CheerioStatic): T[] | T
    hasNext($: CheerioStatic): boolean
    getNext($: CheerioStatic): string
  })

  getCurrent($: CheerioStatic): T[] | T
  hasNext($: CheerioStatic): boolean
  getNext($: CheerioStatic): string

  run(url: string, options?: {limit?: number}): Promise<T[]>
}
```

## Changelog

[CHANGELOG.md](CHANGELOG.md)

## License

the MIT License http://magicdawn.mit-license.org

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