Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

get-pkgs

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-pkgs - npm Package Compare versions

Comparing version
0.6.0
to
1.0.0
+87
README.md
# get-pkgs [![NPM version](https://img.shields.io/npm/v/get-pkgs.svg?style=flat)](https://www.npmjs.com/package/get-pkgs) [![NPM monthly downloads](https://img.shields.io/npm/dm/get-pkgs.svg?style=flat)](https://npmjs.org/package/get-pkgs) [![NPM total downloads](https://img.shields.io/npm/dt/get-pkgs.svg?style=flat)](https://npmjs.org/package/get-pkgs) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/get-pkgs.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/get-pkgs)
> Get the package.json for an array of repos from the npm registry, optionally filtering properties using glob patterns.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save get-pkgs
```
## Usage
```js
const getPkgs = require('get-pkgs');
// takes a callback
getPkgs(['assemble', 'verb'], function(err, pkgs) {
console.log(pkgs);
});
// or returns a promise
getPkgs(['assemble', 'verb'])
.then(pkgs => console.log(pkgs))
.catch(console.error);
```
## About
<details>
<summary><strong>Contributing</strong></summary>
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
</details>
<details>
<summary><strong>Running Tests</strong></summary>
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
</details>
<details>
<summary><strong>Building docs</strong></summary>
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
</details>
### Related projects
You might also be interested in these projects:
* [get-first-commit](https://www.npmjs.com/package/get-first-commit): Returns a git repository's first commit as a JavaScript object. | [homepage](https://github.com/jonschlinkert/get-first-commit "Returns a git repository's first commit as a JavaScript object.")
* [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.")
* [github-base](https://www.npmjs.com/package/github-base): JavaScript wrapper that greatly simplifies working with GitHub's API. | [homepage](https://github.com/jonschlinkert/github-base "JavaScript wrapper that greatly simplifies working with GitHub's API.")
### Author
**Jon Schlinkert**
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
### License
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 28, 2018._
+25
-31
/*!
* get-pkgs <https://github.com/jonschlinkert/get-pkgs>
*
* Copyright (c) 2014-2016, Jon Schlinkert.
* Licensed under the MIT License.
* Copyright (c) 2014-present, Jon Schlinkert.
* Released under the MIT License.
*/

@@ -10,5 +10,5 @@

var utils = require('./utils');
const pkg = require('get-pkg');
module.exports = function get(repos, options, cb) {
module.exports = function get(names, options = {}, cb) {
if (typeof options === 'function') {

@@ -19,36 +19,30 @@ cb = options;

if (typeof cb !== 'function') {
throw new TypeError('expected a callback function');
if (typeof names === 'string') {
names = [names];
}
if (typeof repos === 'string') {
repos = [repos];
const pending = [];
const pkgs = [];
for (const name of names) {
const promise = pkg(name)
.then(res => {
if (res) pkgs.push(res);
})
.catch(err => {
if (err.message === 'document not found' && options.silent) return;
return Promise.reject(err);
});
pending.push(promise);
}
if (!Array.isArray(repos)) {
cb(new TypeError('expected a string or array'));
const promise = Promise.all(pending);
if (typeof cb === 'function') {
promise.then(() => cb(null, pkgs)).catch(cb);
return;
}
options = options || {};
utils.each(repos, function(name, next) {
utils.pkg(name, function(err, pkg) {
if (err) {
if (err.message === 'document not found' && options.silent) {
next();
return;
}
next(err);
return;
}
next(null, pkg);
});
}, function(err, pkgs) {
if (err) {
cb(err);
return;
}
cb(null, pkgs.filter(Boolean));
});
return promise.then(() => pkgs);
};
The MIT License (MIT)
Copyright (c) 2014-2016, Jon Schlinkert.
Copyright (c) 2014-present, Jon Schlinkert.

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "get-pkgs",
"description": "Get the package.json for an array of repos from the npm registry, optionally filtering properties using glob patterns.",
"version": "0.6.0",
"version": "1.0.0",
"homepage": "https://github.com/jonschlinkert/get-pkgs",

@@ -13,9 +13,5 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"files": [
"index.js",
"utils.js"
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {

@@ -25,9 +21,7 @@ "test": "mocha"

"dependencies": {
"async-each": "^1.0.0",
"get-pkg": "^0.3.0",
"lazy-cache": "^2.0.1"
"get-pkg": "^1.0.0"
},
"devDependencies": {
"gulp-format-md": "^0.1.9",
"mocha": "^2.5.3"
"gulp-format-md": "^1.0.0",
"mocha": "^5.2.0"
},

@@ -62,5 +56,2 @@ "keywords": [

},
"reflinks": [
"verb"
],
"lint": {

@@ -67,0 +58,0 @@ "reflinks": true

'use strict';
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;
/**
* Lazily required module dependencies
*/
require('async-each', 'each');
require('get-pkg', 'pkg');
require = fn;
/**
* Expose `utils` modules
*/
module.exports = utils;