# get-latest

> Get the latest package.json for a module.

Latest version **0.1.0** (published 2016-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-latest
pnpm add get-latest
yarn add get-latest
bun add get-latest
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-08-17 |
| First published | 2016-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Brian Woodward |
| Maintainers | doowb |
| Keywords | get, latest, module, newer, newest, npm, package, updated, version |

## Links

- npm: https://www.npmjs.com/package/get-latest
- Repository: https://github.com/doowb/get-latest
- Issues: https://github.com/doowb/get-latest/issues
- npm.io page: https://npm.io/package/get-latest

## Dependencies (7)

- [semver](https://npm.io/package/semver.md) ^5.3.0
- [get-pkg](https://npm.io/package/get-pkg.md) ^0.3.0
- [data-store](https://npm.io/package/data-store.md) ^0.16.1
- [date-store](https://npm.io/package/date-store.md) ^0.1.2
- [lazy-cache](https://npm.io/package/lazy-cache.md) ^2.0.1
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1
- [background-process](https://npm.io/package/background-process.md) ^0.1.0

## Recent versions

- 0.1.0 (latest) — 2016-08-17

## README

# get-latest [![NPM version](https://img.shields.io/npm/v/get-latest.svg?style=flat)](https://www.npmjs.com/package/get-latest) [![NPM downloads](https://img.shields.io/npm/dm/get-latest.svg?style=flat)](https://npmjs.org/package/get-latest) [![Build Status](https://img.shields.io/travis/doowb/get-latest.svg?style=flat)](https://travis-ci.org/doowb/get-latest)

Get the latest package.json for a module.

You might also be interested in [get-pkg](https://github.com/jonschlinkert/get-pkg).

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save get-latest
```

## What does this module do?

This module will return the latest (or newest) package.json file for a specified module. The `getLatest` function requires the current package.json file to be able to compare versions and return the current package.json if the latest hasn't been downloaded yet.

The first use of `get-latest` will always return the current package.json because the latest has not been downloaded. Once the latest is downloaded and cached, then the latest version will be returned.

This is intended to be used by CLIs and applications that want to quickly check for the latest version without blocking execution, but still download the latest to be used during the next execution of the CLI or application.

## Usage

```js
var pkg = require('./package.json');
var getLatest = require('get-latest');
var latest = getLatest(pkg);
console.log('current', pkg.version);
console.log('latest', latest.version);
//=> 'current 0.1.0'
//=> 'latest' 0.2.0'
```

## API

### [getLatest](index.js#L23)

Get the latest `package.json` for the specified package.json and given options.

This library will use the given package.json to determine if it's the latest one or if there is a newer version.
If the given package.json is the latest, then it is returned.

**Params**

* `pkg` **{Object}**: Current package.json to use for checking for the latest.
* `options` **{Object}**: Additional options to control how the checking is handled.
* `options.timespan` **{String}**: String used to determine if the background process should be started to npm for the latest version. Defaults to '1 hour ago'.
* `options.cache` **{Boolean}**: Set to `false` to ensure that the background process is always started.
* `returns` **{Object}**: Latest package.json is returned.

**Example**

```js
var latest = getLatest(require('./package.json'));
```

## About

### Related projects

* [background-process](https://www.npmjs.com/package/background-process): Run a process in the background, disconnected from the main process. | [homepage](https://github.com/doowb/background-process "Run a process in the background, disconnected from the main process.")
* [data-store](https://www.npmjs.com/package/data-store): Easily get, set and persist config data. | [homepage](https://github.com/jonschlinkert/data-store "Easily get, set and persist config data.")
* [date-store](https://www.npmjs.com/package/date-store): Easily persist or get stored dates/times. Useful for conditionally making updates in an application based… [more](https://github.com/jonschlinkert/date-store) | [homepage](https://github.com/jonschlinkert/date-store "Easily persist or get stored dates/times. Useful for conditionally making updates in an application based on the amount of time that has passed.")
* [get-pkg](https://www.npmjs.com/package/get-pkg): Get the package.json for a project from npm. | [homepage](https://github.com/jonschlinkert/get-pkg "Get the package.json for a project from npm.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

Please read the [contributing guide](contributing.md) for avice on opening issues, pull requests, and coding standards.

### Building docs

_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_

To generate the readme and API documentation with [verb](https://github.com/verbose/verb):

```sh
$ npm install -g verb verb-generate-readme && verb
```

### Running tests

Install dev dependencies:

```sh
$ npm install -d && npm test
```

### Author

**Brian Woodward**

* [github/doowb](https://github.com/doowb)
* [twitter/doowb](http://twitter.com/doowb)

### License

Copyright © 2016, [Brian Woodward](https://github.com/doowb).
Released under the [MIT license](https://github.com/doowb/get-latest/blob/master/LICENSE).

***

_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on August 17, 2016._

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