# find-next-version

> find next version

Latest version **1.3.7** (published 2019-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install find-next-version
pnpm add find-next-version
yarn add find-next-version
bun add find-next-version
```

## 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.3.7 |
| Published | 2019-12-03 |
| First published | 2019-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | shun@getto.systems |
| Maintainers | shun-getto-systems |

## Links

- npm: https://www.npmjs.com/package/find-next-version
- Repository: https://github.com/getto-systems/node-find-next-version
- Homepage: https://github.com/getto-systems/node-find-next-version#readme
- Issues: https://github.com/getto-systems/node-find-next-version/issues
- npm.io page: https://npm.io/package/find-next-version

## Recent versions

- 1.3.7 (latest) — 2019-12-03
- 1.3.6 — 2019-12-03
- 1.3.5 — 2019-12-03
- 1.3.4 — 2019-12-03
- 1.3.3 — 2019-11-29
- 1.3.1 — 2019-10-21
- 1.3.0 — 2019-10-21
- 1.2.2 — 2019-10-21
- 1.2.1 — 2019-10-21
- 1.2.0 — 2019-10-21
- 1.1.0 — 2019-10-21
- 1.0.0 — 2019-09-17
- 0.0.1 — 2019-09-17

## README

# find-next-version

find next version

status: production ready

```html
<script src="/path/to/find-next-version.js" defer></script>
<script defer>
(function(info) {
  FindNextVersion.find({ from: info.version, url: FindNextVersion.url.index })
    .then(function(version) {
      location.href = "/" + version + "/" + info.path + location.search;
    });
})(FindNextVersion.parse_pathname(location.pathname));
</script>
```


###### Table of Contents

- [Requirements](#Requirements)
- [Usage](#Usage)
- [License](#License)


## Requirements

- Promise


## Usage

### Install

```bash
npm install find-next-version
cp node_modules/find-next-version/dist/find-next-version.js path/to/find-next-version.js
```

### find

find next version

```javascript
FindNextVersion.find({
  from: "0.0.0", // start finding from this version
  url: function(version) {
    // construct search url
    return "/" + version + "/index.html";
  },
}) // => Promise
  .then(function(version) {
    // next version found
  })
  .catch(function() {
    // next version not found
  });
```

1. request to `HEAD /1.0.1/index.html`, `HEAD /1.1.0/index.html`, `HEAD /2.0.0/index.html`
1. if response status is 200, re-check (1) with next version
1. finally, resolve with (2) version

version number must follow semantic version rule


### url

construct search url functions

```javascript
FindNextVersion.url.index("1.0.0") // => "/1.0.0/index.html"
```


### parse_pathname

get version and path from pathname

```javascript
FindNextVersion.parse_pathname("/1.0.0/path/to/request")
// => { version: "1.0.0", path: "path/to/request" }

FindNextVersion.parse_pathname("/")
// => { version: "0.0.0", path: "" }

FindNextVersion.parse_pathname("/", {fallback_version: "2.0.0"})
// => { version: "2.0.0", path: "" }
```


## License

find-next-version is licensed under the [MIT](LICENSE) license.

Copyright &copy; since 2019 shun@getto.systems

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