Socket
Socket
Sign inDemoInstall

npm-pick-manifest

Package Overview
Dependencies
9
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

15

CHANGELOG.md

@@ -5,2 +5,17 @@ # Change Log

<a name="2.2.0"></a>
# [2.2.0](https://github.com/zkat/npm-pick-manifest/compare/v2.1.0...v2.2.0) (2018-10-30)
### Bug Fixes
* **audit:** npm audit fix --force ([d5ae6c4](https://github.com/zkat/npm-pick-manifest/commit/d5ae6c4))
### Features
* **enjoyBy:** add opts.enjoyBy option to filter versions by date ([0b8a790](https://github.com/zkat/npm-pick-manifest/commit/0b8a790))
<a name="2.1.0"></a>

@@ -7,0 +22,0 @@ # [2.1.0](https://github.com/zkat/npm-pick-manifest/compare/v2.0.1...v2.1.0) (2017-10-18)

28

index.js
'use strict'
const figgyPudding = require('figgy-pudding')
const npa = require('npm-package-arg')
const semver = require('semver')
const PickerOpts = figgyPudding({
defaultTag: { default: 'latest' },
enjoyBy: {},
includeDeprecated: { default: false }
})
module.exports = pickManifest
function pickManifest (packument, wanted, opts) {
opts = opts || {}
opts = PickerOpts(opts)
const time = opts.enjoyBy && packument.time && +(new Date(opts.enjoyBy))
const spec = npa.resolve(packument.name, wanted)

@@ -15,3 +23,10 @@ const type = spec.type

const distTags = packument['dist-tags'] || {}
const versions = Object.keys(packument.versions || {}).filter(v => semver.valid(v, true))
const versions = Object.keys(packument.versions || {}).filter(v => {
return semver.valid(v, true) && (
!time || (
packument.time[v] &&
time >= +(new Date(packument.time[v]))
)
)
})
const undeprecated = versions.filter(v => !packument.versions[v].deprecated)

@@ -39,3 +54,3 @@ let err

const tagVersion = distTags[opts.defaultTag || 'latest']
const tagVersion = distTags[opts.defaultTag]

@@ -46,2 +61,3 @@ if (

packument.versions[tagVersion] &&
(!time || versions.indexOf(tagVersion) !== -1) &&
semver.satisfies(tagVersion, wanted, true)

@@ -66,3 +82,7 @@ ) {

const manifest = target && packument.versions[target]
const manifest = (
target &&
(!time || versions.indexOf(target) !== -1) &&
packument.versions[target]
)
if (!manifest) {

@@ -69,0 +89,0 @@ err = new Error(

9

package.json
{
"name": "npm-pick-manifest",
"version": "2.1.0",
"version": "2.2.0",
"description": "Resolves a matching manifest from a package metadata document according to standard npm semver resolution rules.",

@@ -31,2 +31,3 @@ "main": "index.js",

"dependencies": {
"figgy-pudding": "^3.5.1",
"npm-package-arg": "^6.0.0",

@@ -36,6 +37,6 @@ "semver": "^5.4.1"

"devDependencies": {
"nyc": "^11.2.1",
"nyc": "^13.1.0",
"standard": "^10.0.3",
"standard-version": "^4.2.0",
"tap": "^10.7.0",
"standard-version": "^4.4.0",
"tap": "^12.0.1",
"weallbehave": "^1.2.0",

@@ -42,0 +43,0 @@ "weallcontribute": "^1.0.8"

@@ -77,1 +77,9 @@ # 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/zkat/npm-pick-manifest.svg)](https://travis-ci.org/zkat/npm-pick-manifest) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/npm-pick-manifest?svg=true)](https://ci.appveyor.com/project/zkat/npm-pick-manifest) [![Coverage Status](https://coveralls.io/repos/github/zkat/npm-pick-manifest/badge.svg?branch=latest)](https://coveralls.io/github/zkat/npm-pick-manifest?branch=latest)

version matches the range.
If `opts.enjoyBy` is provided, it should be something that can be passed to `new
Date(x)`, such as a `Date` object or a timestamp string. It will be used to
filter the selected versions such that only versions less than or equal to
`enjoyBy` are considered.
If `opts.includeDeprecated` passed in as true, deprecated versions will be
selected. By default, deprecated versions other than `defaultTag` are ignored.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc