• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..20-Sep-2020-

CHANGELOG.mdH A D26-Oct-19854.3 KiB16871

LICENSE.mdH A D26-Oct-1985755 1713

README.mdH A D26-Oct-19853.3 KiB8562

package.jsonH A D20-Sep-20202.3 KiB8382

README.md

1# npm-pick-manifest [![npm version](https://img.shields.io/npm/v/npm-pick-manifest.svg)](https://npm.im/npm-pick-manifest) [![license](https://img.shields.io/npm/l/npm-pick-manifest.svg)](https://npm.im/npm-pick-manifest) [![Travis](https://img.shields.io/travis/npm/npm-pick-manifest.svg)](https://travis-ci.org/npm/npm-pick-manifest) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/npm/npm-pick-manifest?svg=true)](https://ci.appveyor.com/project/npm/npm-pick-manifest) [![Coverage Status](https://coveralls.io/repos/github/npm/npm-pick-manifest/badge.svg?branch=latest)](https://coveralls.io/github/npm/npm-pick-manifest?branch=latest)
2
3[`npm-pick-manifest`](https://github.com/npm/npm-pick-manifest) is a standalone
4implementation of [npm](https://npmjs.com)'s semver range resolution algorithm.
5
6## Install
7
8`$ npm install --save npm-pick-manifest`
9
10## Table of Contents
11
12* [Example](#example)
13* [Features](#features)
14* [Contributing](#contributing)
15* [API](#api)
16  * [`pickManifest()`](#pick-manifest)
17
18### Example
19
20```javascript
21const pickManifest = require('npm-pick-manifest')
22
23fetch('https://registry.npmjs.org/npm-pick-manifest').then(res => {
24  return res.json()
25}).then(packument => {
26  return pickManifest(packument, '^1.0.0')
27}) // get same manifest as npm would get if you `npm i npm-pick-manifest@^1.0.0`
28```
29
30### Features
31
32* Uses npm's exact semver resolution algorithm
33* Supports ranges, tags, and versions
34
35### Contributing
36
37The npm-pick-manifest team enthusiastically welcomes contributions and project participation!
38There's a bunch of things you can do if you want to contribute! The [Contributor
39Guide](CONTRIBUTING.md) has all the information you need for everything from
40reporting bugs to contributing entire new features. Please don't hesitate to
41jump in if you'd like to, or even ask us questions if something isn't clear.
42
43### API
44
45#### <a name="pick-manifest"></a> `> pickManifest(packument, selector, [opts]) -> manifest`
46
47Returns the manifest that matches `selector`, or throws an error.
48
49Packuments are anything returned by metadata URLs from the npm registry. That
50is, they're objects with the following shape (only fields used by
51`npm-pick-manifest` included):
52
53```javascript
54{
55  name: 'some-package',
56  'dist-tags': {
57    foo: '1.0.1'
58  },
59  versions: {
60    '1.0.0': { version: '1.0.0' },
61    '1.0.1': { version: '1.0.1' },
62    '1.0.2': { version: '1.0.2' },
63    '2.0.0': { version: '2.0.0' }
64  }
65}
66```
67
68The algorithm will follow npm's algorithm for semver resolution, and only `tag`,
69`range`, and `version` selectors are supported.
70
71The function will throw `ETARGET` if there was no matching manifest, and
72`ENOVERSIONS` if the packument object has no valid versions in `versions`.
73
74If `opts.defaultTag` is provided, it will be used instead of `latest`. That is,
75if that tag matches the selector, it will be used, even if a higher available
76version matches the range.
77
78If `opts.enjoyBy` is provided, it should be something that can be passed to `new
79Date(x)`, such as a `Date` object or a timestamp string. It will be used to
80filter the selected versions such that only versions less than or equal to
81`enjoyBy` are considered.
82
83If `opts.includeDeprecated` passed in as true, deprecated versions will be
84selected. By default, deprecated versions other than `defaultTag` are ignored.
85