🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

get-latest

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-latest

Get the latest package.json for a module.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

get-latest NPM version NPM downloads Build Status

Get the latest package.json for a module.

You might also be interested in get-pkg.

Install

Install with npm:

$ 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

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

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

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

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for avice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

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

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.

This file was generated by verb, v0.9.0, on August 17, 2016.

Keywords

get

FAQs

Package last updated on 17 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts