<commit_before>Repository URLs
===
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url]

> Get repository URLs for one or more packages.


## Installation

``` bash
$ npm install npm-package-repo-url
```


## Usage

``` javascript
var urls = require( 'npm-package-repo-url' );
```

#### urls( opts, clbk )

Get repository URLs for one or more packages.

``` javascript
var opts = {
	'packages': [
		'dstructs-matrix',
		'compute-erf',
		'log',
		'utils-copy'
	]	
};

urls( opts, clbk );

function clbk( error, data ) {
	if ( error ) {
		throw error;
	}
	console.dir( data );
	/*
		{
			"meta": {
				"total": 4,
				"success": 4,
				"failure": 0
			},
			"data": {
				"dstructs-matrix": "...",
				"compute-erf": "...",
				"log": null,
				"utils-copy": "..."
			},
			"failures": {}
	*/
}
```

The `function` accepts the following `options`:

*	__packages__: `array` of package names (*required*).
*	__registry__: registry. Default: `'registry.npmjs.org'`.
*	__port__: registry port. Default: `80`.
* 	__protocol__: registry protocol. Default: `'http'`.

To query an alternative registry, set the relevant options.

``` javascript
var opts = {
	'packages': [
		'dstructs-array',
		'flow-map',
		'utils-merge2'
	],
	'registry': 'my.favorite.npm/registry',
	'port': 80,
	'protocol': 'https'
};

urls( opts, clbk );
```


## Notes

*	If the module encounters an application-level `error` (e.g., no network connection, non-existent registry, etc), that `error` is returned immediately to the provided `callback`.
*	If the module encounters a downstream `error` (e.g., timeout, reset connection, etc), that `error` is included in the returned results under the `failures` field.
*	Successfully resolved packages without an associated repository URL have a `url` value equal to `null`.


## Examples

``` javascript
var ls = require( 'npm-list-author-packages' );
var urls = require( 'npm-package-repo-url' );

var opts = {
	'username': 'kgryte'
};

ls( opts, onList );

function onList( error, list ) {
	var opts;
	if ( error ) {
		throw error;
	}
	if ( !list.length ) {
		return {};
	}
	opts = {
		'packages': list
	};
	urls( opts, onUrls );
}

function onUrls( error, data ) {
	if ( error ) {
		throw error;
	}
	console.dir( data );
}
```

To run the example code from the top-level application directory,

``` bash
$ DEBUG=* node ./examples/index.js
```


---
## CLI

### Installation

To use the module as a general utility, install the module globally

``` bash
$ npm install -g npm-package-repo-url
```


### Usage

``` bash
Usage: pkgrepo [options] pkg1 pkg2 ...

Options:

  -h,  --help                Print this message.
  -V,  --version             Print the package version.
  -p,  --port port           Registry port. Default: 80.
       --registry registry   Registry. Default: 'registry.npmjs.org'.
       --protocol protocol   Registry protocol. Default: 'http'.
```


### Notes

*	If a package is successfully resolved, the `package:url` pair is written to `stdout` as newline-delimited [`JSON`][json].
*	If a package cannot be resolved due to a downstream `error` (failure), the package (and its associated `error`) is written to `sterr` as newline-delimited [`JSON`][json].
*	Output order is __not__ guaranteed to match input order.


### Examples

``` bash
$ DEBUG=* pkgrepo dstructs-matrix compute-erf utils-copy log
# => {"dstructs-matrix":"..."}
# => {"log":null}
# => {"utils-copy":"..."}
# => {"compute-erf":"..."}
```


---
## Tests

### Unit

This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory:

``` bash
$ make test
```

All new feature development should have corresponding unit tests to validate correct functionality.


### Test Coverage

This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

``` bash
$ make test-cov
```

Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,

``` bash
$ make view-cov
```
<commit_msg>Update README examples<commit_after>Repository URLs
===
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url]

> Get repository URLs for one or more packages.


## Installation

``` bash
$ npm install npm-package-repo-url
```


## Usage

``` javascript
var urls = require( 'npm-package-repo-url' );
```

#### urls( opts, clbk )

Get repository URLs for one or more packages.

``` javascript
var opts = {
	'packages': [
		'dstructs-matrix',
		'compute-erf',
		'log',
		'utils-copy'
	]	
};

urls( opts, clbk );

function clbk( error, data ) {
	if ( error ) {
		throw error;
	}
	console.dir( data );
	/*
		{
			"meta": {
				"total": 4,
				"success": 4,
				"failure": 0
			},
			"data": {
				"dstructs-matrix": "https://github.com/dstructs/matrix.git",
				"compute-erf": "https://github.com/compute-io/erf.git",
				"log": null,
				"utils-copy": "https://github.com/kgryte/utils-copy.git"
			},
			"failures": {}
	*/
}
```

The `function` accepts the following `options`:

*	__packages__: `array` of package names (*required*).
*	__registry__: registry. Default: `'registry.npmjs.org'`.
*	__port__: registry port. Default: `80`.
* 	__protocol__: registry protocol. Default: `'http'`.

To query an alternative registry, set the relevant options.

``` javascript
var opts = {
	'packages': [
		'dstructs-array',
		'flow-map',
		'utils-merge2'
	],
	'registry': 'my.favorite.npm/registry',
	'port': 80,
	'protocol': 'https'
};

urls( opts, clbk );
```


## Notes

*	If the module encounters an application-level `error` (e.g., no network connection, non-existent registry, etc), that `error` is returned immediately to the provided `callback`.
*	If the module encounters a downstream `error` (e.g., timeout, reset connection, etc), that `error` is included in the returned results under the `failures` field.
*	Successfully resolved packages without an associated repository URL have a `url` value equal to `null`.


## Examples

``` javascript
var ls = require( 'npm-list-author-packages' );
var urls = require( 'npm-package-repo-url' );

var opts = {
	'username': 'kgryte'
};

ls( opts, onList );

function onList( error, list ) {
	var opts;
	if ( error ) {
		throw error;
	}
	if ( !list.length ) {
		return {};
	}
	opts = {
		'packages': list
	};
	urls( opts, onUrls );
}

function onUrls( error, data ) {
	if ( error ) {
		throw error;
	}
	console.dir( data );
}
```

To run the example code from the top-level application directory,

``` bash
$ DEBUG=* node ./examples/index.js
```


---
## CLI

### Installation

To use the module as a general utility, install the module globally

``` bash
$ npm install -g npm-package-repo-url
```


### Usage

``` bash
Usage: pkgrepo [options] pkg1 pkg2 ...

Options:

  -h,  --help                Print this message.
  -V,  --version             Print the package version.
  -p,  --port port           Registry port. Default: 80.
       --registry registry   Registry. Default: 'registry.npmjs.org'.
       --protocol protocol   Registry protocol. Default: 'http'.
```


### Notes

*	If a package is successfully resolved, the `package:url` pair is written to `stdout` as newline-delimited [`JSON`][json].
*	If a package cannot be resolved due to a downstream `error` (failure), the package (and its associated `error`) is written to `sterr` as newline-delimited [`JSON`][json].
*	Output order is __not__ guaranteed to match input order.


### Examples

``` bash
$ DEBUG=* pkgrepo dstructs-matrix compute-erf utils-copy log
# => {"dstructs-matrix":"https://github.com/dstructs/matrix.git"}
# => {"log":null}
# => {"utils-copy":"https://github.com/kgryte/utils-copy.git"}
# => {"compute-erf":"https://github.com/compute-io/erf.git"}
```


---
## Tests

### Unit

This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory:

``` bash
$ make test
```

All new feature development should have corresponding unit tests to validate correct functionality.


### Test Coverage

This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

``` bash
$ make test-cov
```

Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,

``` bash
$ make view-cov
```

{'fraction_non_alphanumeric': 0.1570028818443804, 'fraction_numerical': 0.00276657060518732, 'mean_word_length': 3.5639137296159915, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2383701', 'n_tokens_mistral': 3055, 'n_tokens_neox': 2754, 'n_words': 907}