Socket
Socket
Sign inDemoInstall

npm-api

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-api - npm Package Compare versions

Comparing version 0.4.8 to 0.4.9

32

lib/view.js

@@ -56,9 +56,17 @@ /*!

var items = [];
var header = {};
utils.request(self.url(params))
.once('error', reject)
.pipe(utils.JSONStream.parse('rows.*'))
.on('header', function(data) {
header = data;
if (header.error) {
reject(new Error(header.reason || header.error));
}
})
.on('data', function (data) {
items.push(data);
})
.on('error', reject)
.on('end', function () {
.once('error', reject)
.once('end', function () {
resolve(items);

@@ -71,2 +79,22 @@ });

/**
* Query the couchdb view with the provided parameters and return a stream of results.
*
* ```js
* view.stream({ group_level: 2, startkey: JSON.stringify(['micromatch']), endkey: JSON.stringify(['micromatch', {}])})
* .on('data', function(data) {
* console.log(data);
* });
* ```
* @param {Object} `params` URL query parameters to pass along to the couchdb view.
* @return {Stream} Streaming results of the query.
* @api public
*/
View.prototype.stream = function(params) {
params = params || {};
return utils.request(this.url(params))
.pipe(utils.JSONStream.parse('rows.*'));
};
/**
* Build a formatted url with the provided parameters.

@@ -73,0 +101,0 @@ *

19

package.json
{
"name": "npm-api",
"description": "Base class for retrieving data from the npm registry.",
"version": "0.4.8",
"version": "0.4.9",
"homepage": "https://github.com/doowb/npm-api",

@@ -31,18 +31,13 @@ "author": "Brian Woodward (https://github.com/doowb)",

"data-store": "^0.16.1",
"download-stats": "^0.3.0",
"download-stats": "^0.3.2",
"get-value": "^2.0.6",
"lazy-cache": "^2.0.1",
"lazy-cache": "^2.0.2",
"merge-deep": "^3.0.0",
"moment": "^2.15.1",
"request": "^2.75.0",
"moment": "^2.16.0",
"request": "^2.78.0",
"set-value": "^0.4.0"
},
"devDependencies": {
"co-limiter": "^1.0.3",
"firebase": "^2.4.1",
"gulp-format-md": "^0.1.7",
"minimist": "^1.2.0",
"mocha": "^3.1.0",
"thunkify": "^2.1.2",
"write-json": "^0.2.2"
"gulp-format-md": "^0.1.11",
"mocha": "^3.1.2"
},

@@ -49,0 +44,0 @@ "keywords": [

@@ -1,4 +0,4 @@

# npm-api [![NPM version](https://img.shields.io/npm/v/npm-api.svg?style=flat)](https://www.npmjs.com/package/npm-api) [![NPM downloads](https://img.shields.io/npm/dm/npm-api.svg?style=flat)](https://npmjs.org/package/npm-api) [![Build Status](https://img.shields.io/travis/doowb/npm-api.svg?style=flat)](https://travis-ci.org/doowb/npm-api)
# npm-api [![NPM version](https://img.shields.io/npm/v/npm-api.svg?style=flat)](https://www.npmjs.com/package/npm-api) [![NPM downloads](https://img.shields.io/npm/dm/npm-api.svg?style=flat)](https://npmjs.org/package/npm-api) [![Linux Build Status](https://img.shields.io/travis/doowb/npm-api.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/npm-api)
Base class for retrieving data from the npm registry.
> Base class for retrieving data from the npm registry.

@@ -35,2 +35,8 @@ ## Install

**Example**
```js
var view = npm.view('byUser');
```
**Params**

@@ -41,12 +47,12 @@

### [.list](index.js#L88)
Create a new instance of `List` or get an existing instance to work with npm couchdb list.
**Example**
```js
var view = npm.view('byUser');
var list = npm.list('sortCount', 'byUser');
```
### [.list](index.js#L88)
Create a new instance of `List` or get an existing instance to work with npm couchdb list.
**Params**

@@ -58,12 +64,12 @@

### [.repo](index.js#L119)
Create an instance of a `repo` to work with.
**Example**
```js
var list = npm.list('sortCount', 'byUser');
var repo = npm.repo('micromatch');
```
### [.repo](index.js#L119)
Create an instance of a `repo` to work with.
**Params**

@@ -74,12 +80,12 @@

### [.maintainer](index.js#L142)
Create an instance of a `maintainer` to work with.
**Example**
```js
var repo = npm.repo('micromatch');
var maintainer = npm.maintainer('doowb');
```
### [.maintainer](index.js#L141)
Create an instance of a `maintainer` to work with.
**Params**

@@ -90,8 +96,2 @@

**Example**
```js
var maintainer = npm.maintainer('doowb');
```
## Models

@@ -111,7 +111,2 @@

**Params**
* `name` **{String}**: Name of the npm maintainer to get information about.
* `store` **{Object}**: Optional cache store instance for caching results. Defaults to a memory store.
**Example**

@@ -123,2 +118,7 @@

**Params**
* `name` **{String}**: Name of the npm maintainer to get information about.
* `store` **{Object}**: Optional cache store instance for caching results. Defaults to a memory store.
### [.repos](lib/models/maintainer.js#L56)

@@ -128,4 +128,2 @@

* `returns` **{Promise}**: Returns array of repository names when promise resolves.
**Example**

@@ -142,2 +140,4 @@

* `returns` **{Promise}**: Returns array of repository names when promise resolves.
### [Repo](lib/models/repo.js#L26)

@@ -147,7 +147,2 @@

**Params**
* `name` **{String}**: Name of the npm repo to get information about.
* `store` **{Object}**: Optional cache store instance for caching results. Defaults to a memory store.
**Example**

@@ -159,2 +154,7 @@

**Params**
* `name` **{String}**: Name of the npm repo to get information about.
* `store` **{Object}**: Optional cache store instance for caching results. Defaults to a memory store.
### [.package](lib/models/repo.js#L57)

@@ -164,4 +164,2 @@

* `returns` **{Promise}**: Returns the package.json object when promise resolves.
**Example**

@@ -178,2 +176,4 @@

* `returns` **{Promise}**: Returns the package.json object when promise resolves.
### [.version](lib/models/repo.js#L89)

@@ -183,7 +183,2 @@

**Params**
* `version` **{String}**: Specific version to retrieve.
* `returns` **{Promise}**: Returns the package.json object for the specified version when promise resolves.
**Example**

@@ -200,2 +195,7 @@

**Params**
* `version` **{String}**: Specific version to retrieve.
* `returns` **{Promise}**: Returns the package.json object for the specified version when promise resolves.
### [.dependencies](lib/models/repo.js#L118)

@@ -205,7 +205,2 @@

**Params**
* `version` **{String}**: Specific version to retrieve. Defaults to `latest`.
* `returns` **{Promise}**: Returns the dependencies object for the specified version when promise resolves.
**Example**

@@ -222,2 +217,7 @@

**Params**
* `version` **{String}**: Specific version to retrieve. Defaults to `latest`.
* `returns` **{Promise}**: Returns the dependencies object for the specified version when promise resolves.
### [.devDependencies](lib/models/repo.js#L138)

@@ -227,7 +227,2 @@

**Params**
* `version` **{String}**: Specific version to retrieve. Defaults to `latest`.
* `returns` **{Promise}**: Returns the devDependencies object for the specified version when promise resolves.
**Example**

@@ -244,2 +239,7 @@

**Params**
* `version` **{String}**: Specific version to retrieve. Defaults to `latest`.
* `returns` **{Promise}**: Returns the devDependencies object for the specified version when promise resolves.
### [.prop](lib/models/repo.js#L159)

@@ -249,8 +249,2 @@

**Params**
* `prop` **{String}**: Name of the property to get.
* `version` **{String}**: Specific version to retrieve. Defaults to `latest`.
* `returns` **{Promise}**: Returns the property for the specified version when promise resolves.
**Example**

@@ -267,2 +261,8 @@

**Params**
* `prop` **{String}**: Name of the property to get.
* `version` **{String}**: Specific version to retrieve. Defaults to `latest`.
* `returns` **{Promise}**: Returns the property for the specified version when promise resolves.
## Registry queries

@@ -274,7 +274,2 @@

**Params**
* `name` **{String}**: Name of couchdb view to use.
* `returns` **{Object}**: instance of `View`
**Example**

@@ -286,2 +281,7 @@

**Params**
* `name` **{String}**: Name of couchdb view to use.
* `returns` **{Object}**: instance of `View`
### [.query](lib/view.js#L51)

@@ -291,7 +291,2 @@

**Params**
* `params` **{Object}**: URL query parameters to pass along to the couchdb view.
* `returns` **{Promise}**: Results of the query when promise is resolved.
**Example**

@@ -308,4 +303,27 @@

### [.url](lib/view.js#L77)
**Params**
* `params` **{Object}**: URL query parameters to pass along to the couchdb view.
* `returns` **{Promise}**: Results of the query when promise is resolved.
### [.stream](lib/view.js#L91)
Query the couchdb view with the provided parameters and return a stream of results.
**Example**
```js
view.stream({ group_level: 2, startkey: JSON.stringify(['micromatch']), endkey: JSON.stringify(['micromatch', {}])})
.on('data', function(data) {
console.log(data);
});
```
**Params**
* `params` **{Object}**: URL query parameters to pass along to the couchdb view.
* `returns` **{Stream}**: Streaming results of the query.
### [.url](lib/view.js#L105)
Build a formatted url with the provided parameters.

@@ -322,2 +340,8 @@

**Example**
```js
var list = new List('dependedUpon', view);
```
**Params**

@@ -329,8 +353,2 @@

**Example**
```js
var list = new List('dependedUpon', view);
```
### [.query](lib/list.js#L53)

@@ -340,7 +358,2 @@

**Params**
* `params` **{Object}**: URL query parameters to pass along to the couchdb list.
* `returns` **{Promise}**: Results of the query when promise is resolved.
**Example**

@@ -357,2 +370,7 @@

**Params**
* `params` **{Object}**: URL query parameters to pass along to the couchdb list.
* `returns` **{Promise}**: Results of the query when promise is resolved.
### [.url](lib/list.js#L80)

@@ -406,6 +424,6 @@

Copyright © 2016, [Brian Woodward](https://github.com/doowb).
Released under the [MIT license](https://github.com/doowb/npm-api/blob/master/LICENSE).
Released under the [MIT license](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on September 28, 2016._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on November 13, 2016._
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc