aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/pacote/node_modules/promise-retry
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/promise-retry')
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/.editorconfig15
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/.npmignore2
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/.travis.yml5
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/LICENSE19
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/README.md92
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/index.js52
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.editorconfig12
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.eslintrc.json7
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.npmignore2
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.travis.yml5
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/README.md72
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/bower.json30
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.js22
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.umd.js26
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/package.json68
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/.eslintrc.json5
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/test.js92
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/package.json71
-rw-r--r--deps/npm/node_modules/pacote/node_modules/promise-retry/test/test.js263
19 files changed, 860 insertions, 0 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/.editorconfig b/deps/npm/node_modules/pacote/node_modules/promise-retry/.editorconfig
new file mode 100644
index 0000000000..8bc4f108d5
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[package.json]
+indent_size = 2
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/.npmignore b/deps/npm/node_modules/pacote/node_modules/promise-retry/.npmignore
new file mode 100644
index 0000000000..a22dcdd470
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+npm-debug.*
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/.travis.yml b/deps/npm/node_modules/pacote/node_modules/promise-retry/.travis.yml
new file mode 100644
index 0000000000..f85680370f
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - "0.12"
+ - "4"
+ - "5"
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/LICENSE b/deps/npm/node_modules/pacote/node_modules/promise-retry/LICENSE
new file mode 100644
index 0000000000..db5e914de1
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2014 IndigoUnited
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/README.md b/deps/npm/node_modules/pacote/node_modules/promise-retry/README.md
new file mode 100644
index 0000000000..85c3bc57e8
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/README.md
@@ -0,0 +1,92 @@
+# node-promise-retry
+
+[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]
+
+[npm-url]:https://npmjs.org/package/promise-retry
+[downloads-image]:http://img.shields.io/npm/dm/promise-retry.svg
+[npm-image]:http://img.shields.io/npm/v/promise-retry.svg
+[travis-url]:https://travis-ci.org/IndigoUnited/node-promise-retry
+[travis-image]:http://img.shields.io/travis/IndigoUnited/node-promise-retry/master.svg
+[david-dm-url]:https://david-dm.org/IndigoUnited/node-promise-retry
+[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-promise-retry.svg
+[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-promise-retry#info=devDependencies
+[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-promise-retry.svg
+
+Retries a function that returns a promise, leveraging the power of the [retry](https://github.com/tim-kos/node-retry) module to the promises world.
+
+There's already some modules that are able to retry functions that return promises but
+they were rather difficult to use or do not offer an easy way to do conditional retries.
+
+
+## Installation
+
+`$ npm install promise-retry`
+
+
+## Usage
+
+### promiseRetry(fn, [options])
+
+Calls `fn` until the returned promise ends up fulfilled or rejected with an error different than
+a `retry` error.
+The `options` argument is an object which maps to the [retry](https://github.com/tim-kos/node-retry) module options:
+
+- `retries`: The maximum amount of times to retry the operation. Default is `10`.
+- `factor`: The exponential factor to use. Default is `2`.
+- `minTimeout`: The number of milliseconds before starting the first retry. Default is `1000`.
+- `maxTimeout`: The maximum number of milliseconds between two retries. Default is `Infinity`.
+- `randomize`: Randomizes the timeouts by multiplying with a factor between `1` to `2`. Default is `false`.
+
+
+The `fn` function will receive a `retry` function as its first argument that should be called with an error whenever you want to retry `fn`. The `retry` function will always throw an error.
+If there's retries left, it will throw a special `retry` error that will be handled internally to call `fn` again.
+If there's no retries left, it will throw the actual error passed to it.
+
+If you prefer, you can pass the options first using the alternative function signature `promiseRetry([options], fn)`.
+
+## Example
+```js
+var promiseRetry = require('promise-retry');
+
+// Simple example
+promiseRetry(function (retry, number) {
+ console.log('attempt number', number);
+
+ return doSomething()
+ .catch(retry);
+})
+.then(function (value) {
+ // ..
+}, function (err) {
+ // ..
+});
+
+// Conditional example
+promiseRetry(function (retry, number) {
+ console.log('attempt number', number);
+
+ return doSomething()
+ .catch(function (err) {
+ if (err.code === 'ETIMEDOUT') {
+ retry(err);
+ }
+
+ throw err;
+ });
+})
+.then(function (value) {
+ // ..
+}, function (err) {
+ // ..
+});
+```
+
+
+## Tests
+
+`$ npm test`
+
+
+## License
+
+Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/index.js b/deps/npm/node_modules/pacote/node_modules/promise-retry/index.js
new file mode 100644
index 0000000000..092f275686
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/index.js
@@ -0,0 +1,52 @@
+'use strict';
+
+var errcode = require('err-code');
+var retry = require('retry');
+
+var hasOwn = Object.prototype.hasOwnProperty;
+
+function isRetryError(err) {
+ return err && err.code === 'EPROMISERETRY' && hasOwn.call(err, 'retried');
+}
+
+function promiseRetry(fn, options) {
+ var temp;
+ var operation;
+
+ if (typeof fn === 'object' && typeof options === 'function') {
+ // Swap options and fn when using alternate signature (options, fn)
+ temp = options;
+ options = fn;
+ fn = temp;
+ }
+
+ operation = retry.operation(options);
+
+ return new Promise(function (resolve, reject) {
+ operation.attempt(function (number) {
+ Promise.resolve()
+ .then(function () {
+ return fn(function (err) {
+ if (isRetryError(err)) {
+ err = err.retried;
+ }
+
+ throw errcode('Retrying', 'EPROMISERETRY', { retried: err });
+ }, number);
+ })
+ .then(resolve, function (err) {
+ if (isRetryError(err)) {
+ err = err.retried;
+
+ if (operation.retry(err || new Error())) {
+ return;
+ }
+ }
+
+ reject(err);
+ });
+ });
+ });
+}
+
+module.exports = promiseRetry;
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.editorconfig b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.editorconfig
new file mode 100644
index 0000000000..829280bee1
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[package.json]
+indent_size = 2
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.eslintrc.json b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.eslintrc.json
new file mode 100644
index 0000000000..f34b41d96c
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.eslintrc.json
@@ -0,0 +1,7 @@
+{
+ "root": true,
+ "extends": [
+ "@satazor/eslint-config/es5",
+ "@satazor/eslint-config/addons/node"
+ ]
+} \ No newline at end of file
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.npmignore b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.npmignore
new file mode 100644
index 0000000000..a22dcdd470
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+npm-debug.*
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.travis.yml b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.travis.yml
new file mode 100644
index 0000000000..f85680370f
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - "0.12"
+ - "4"
+ - "5"
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/README.md b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/README.md
new file mode 100644
index 0000000000..19a390df08
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/README.md
@@ -0,0 +1,72 @@
+# err-code
+
+[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]
+
+[npm-url]:https://npmjs.org/package/err-code
+[downloads-image]:http://img.shields.io/npm/dm/err-code.svg
+[npm-image]:http://img.shields.io/npm/v/err-code.svg
+[travis-url]:https://travis-ci.org/IndigoUnited/js-err-code
+[travis-image]:http://img.shields.io/travis/IndigoUnited/js-err-code/master.svg
+[david-dm-url]:https://david-dm.org/IndigoUnited/js-err-code
+[david-dm-image]:https://img.shields.io/david/IndigoUnited/js-err-code.svg
+[david-dm-dev-url]:https://david-dm.org/IndigoUnited/js-err-code#info=devDependencies
+[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/js-err-code.svg
+
+Create new error instances with a code and additional properties.
+
+
+## Installation
+
+`$ npm install err-code` - `NPM`
+`$ bower install err-code` - `bower`
+
+The browser file is named index.umd.js which supports CommonJS, AMD and globals (errCode).
+
+
+## Why
+
+I find myself doing this repeatedly:
+
+```js
+var err = new Error('My message');
+err.code = 'SOMECODE';
+err.detail = 'Additional information about the error';
+throw err;
+```
+
+
+## Usage
+
+Simple usage.
+
+```js
+var errcode = require('err-code');
+
+// fill error with message + code
+throw errcode(new Error('My message'), 'ESOMECODE');
+// fill error with message + code + props
+throw errcode(new Error('My message'), 'ESOMECODE', { detail: 'Additional information about the error' });
+// fill error with message + props
+throw errcode(new Error('My message'), { detail: 'Additional information about the error' });
+
+
+// You may also pass a string in the first argument and an error will be automatically created
+// for you, though the stack trace will contain err-code in it.
+
+// create error with message + code
+throw errcode('My message', 'ESOMECODE');
+// create error with message + code + props
+throw errcode('My message', 'ESOMECODE', { detail: 'Additional information about the error' });
+// create error with message + props
+throw errcode('My message', { detail: 'Additional information about the error' });
+```
+
+
+## Tests
+
+`$ npm test`
+
+
+## License
+
+Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/bower.json b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/bower.json
new file mode 100644
index 0000000000..a39cb702ce
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/bower.json
@@ -0,0 +1,30 @@
+{
+ "name": "err-code",
+ "version": "1.1.1",
+ "description": "Create new error instances with a code and additional properties",
+ "main": "index.umd.js",
+ "homepage": "https://github.com/IndigoUnited/js-err-code",
+ "authors": [
+ "IndigoUnited <hello@indigounited.com> (http://indigounited.com)"
+ ],
+ "moduleType": [
+ "amd",
+ "globals",
+ "node"
+ ],
+ "keywords": [
+ "error",
+ "err",
+ "code",
+ "properties",
+ "property"
+ ],
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.js b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.js
new file mode 100644
index 0000000000..1a0a69f626
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.js
@@ -0,0 +1,22 @@
+'use strict';
+
+function createError(msg, code, props) {
+ var err = msg instanceof Error ? msg : new Error(msg);
+ var key;
+
+ if (typeof code === 'object') {
+ props = code;
+ } else if (code != null) {
+ err.code = code;
+ }
+
+ if (props) {
+ for (key in props) {
+ err[key] = props[key];
+ }
+ }
+
+ return err;
+}
+
+module.exports = createError;
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.umd.js b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.umd.js
new file mode 100644
index 0000000000..d1dbdf7335
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/index.umd.js
@@ -0,0 +1,26 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.errCode = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+'use strict';
+
+function createError(msg, code, props) {
+ var err = msg instanceof Error ? msg : new Error(msg);
+ var key;
+
+ if (typeof code === 'object') {
+ props = code;
+ } else if (code != null) {
+ err.code = code;
+ }
+
+ if (props) {
+ for (key in props) {
+ err[key] = props[key];
+ }
+ }
+
+ return err;
+}
+
+module.exports = createError;
+
+},{}]},{},[1])(1)
+}); \ No newline at end of file
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/package.json b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/package.json
new file mode 100644
index 0000000000..8d2cd5b86e
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/package.json
@@ -0,0 +1,68 @@
+{
+ "_from": "err-code@^1.0.0",
+ "_id": "err-code@1.1.2",
+ "_integrity": "sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA=",
+ "_location": "/pacote/promise-retry/err-code",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "err-code@^1.0.0",
+ "name": "err-code",
+ "escapedName": "err-code",
+ "rawSpec": "^1.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^1.0.0"
+ },
+ "_requiredBy": [
+ "/pacote/promise-retry"
+ ],
+ "_resolved": "https://registry.npmjs.org/err-code/-/err-code-1.1.2.tgz",
+ "_shasum": "06e0116d3028f6aef4806849eb0ea6a748ae6960",
+ "_shrinkwrap": null,
+ "_spec": "err-code@^1.0.0",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/pacote/node_modules/promise-retry",
+ "author": {
+ "name": "IndigoUnited",
+ "email": "hello@indigounited.com",
+ "url": "http://indigounited.com"
+ },
+ "bin": null,
+ "bugs": {
+ "url": "https://github.com/IndigoUnited/js-err-code/issues/"
+ },
+ "bundleDependencies": false,
+ "dependencies": {},
+ "deprecated": false,
+ "description": "Create an error with a code",
+ "devDependencies": {
+ "@satazor/eslint-config": "^3.0.0",
+ "browserify": "^14.0.0",
+ "eslint": "^3.0.0",
+ "expect.js": "^0.3.1",
+ "mocha": "^3.0.2"
+ },
+ "homepage": "https://github.com/IndigoUnited/js-err-code#readme",
+ "keywords": [
+ "error",
+ "err",
+ "code",
+ "properties",
+ "property"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "err-code",
+ "optionalDependencies": {},
+ "peerDependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/IndigoUnited/js-err-code.git"
+ },
+ "scripts": {
+ "browserify": "browserify -s err-code index.js > index.umd.js",
+ "lint": "eslint '{*.js,test/**/*.js}' --ignore-pattern *.umd.js",
+ "test": "mocha --bail"
+ },
+ "version": "1.1.2"
+}
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/.eslintrc.json b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/.eslintrc.json
new file mode 100644
index 0000000000..f9fbb2d6ce
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+} \ No newline at end of file
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/test.js b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/test.js
new file mode 100644
index 0000000000..81b2b26d37
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/node_modules/err-code/test/test.js
@@ -0,0 +1,92 @@
+'use strict';
+
+var errcode = require('../index');
+var expect = require('expect.js');
+
+describe('errcode', function () {
+ describe('string as first argument', function () {
+ it('should create an error object without code', function () {
+ var err = errcode('my message');
+
+ expect(err).to.be.an(Error);
+ expect(err.hasOwnProperty(err.code)).to.be(false);
+ });
+
+ it('should create an error object with code', function () {
+ var err = errcode('my message', 'ESOME');
+
+ expect(err).to.be.an(Error);
+ expect(err.code).to.be('ESOME');
+ });
+
+ it('should create an error object with code and properties', function () {
+ var err = errcode('my message', 'ESOME', { foo: 'bar', bar: 'foo' });
+
+ expect(err).to.be.an(Error);
+ expect(err.code).to.be('ESOME');
+ expect(err.foo).to.be('bar');
+ expect(err.bar).to.be('foo');
+ });
+
+ it('should create an error object without code but with properties', function () {
+ var err = errcode('my message', { foo: 'bar', bar: 'foo' });
+
+ expect(err).to.be.an(Error);
+ expect(err.code).to.be(undefined);
+ expect(err.foo).to.be('bar');
+ expect(err.bar).to.be('foo');
+ });
+ });
+
+ describe('error as first argument', function () {
+ it('should accept an error and do nothing', function () {
+ var myErr = new Error('my message');
+ var err = errcode(myErr);
+
+ expect(err).to.be(myErr);
+ expect(err.hasOwnProperty(err.code)).to.be(false);
+ });
+
+ it('should accept an error and add a code', function () {
+ var myErr = new Error('my message');
+ var err = errcode(myErr, 'ESOME');
+
+ expect(err).to.be(myErr);
+ expect(err.code).to.be('ESOME');
+ });
+
+ it('should accept an error object and add code & properties', function () {
+ var myErr = new Error('my message');
+ var err = errcode(myErr, 'ESOME', { foo: 'bar', bar: 'foo' });
+
+ expect(err).to.be.an(Error);
+ expect(err.code).to.be('ESOME');
+ expect(err.foo).to.be('bar');
+ expect(err.bar).to.be('foo');
+ });
+
+ it('should create an error object without code but with properties', function () {
+ var myErr = new Error('my message');
+ var err = errcode(myErr, { foo: 'bar', bar: 'foo' });
+
+ expect(err).to.be.an(Error);
+ expect(err.code).to.be(undefined);
+ expect(err.foo).to.be('bar');
+ expect(err.bar).to.be('foo');
+ });
+ });
+
+ it('should allow passing null & undefined in the first argument', function () {
+ var err;
+
+ err = errcode(null, 'ESOME');
+ expect(err).to.be.an(Error);
+ expect(err.message).to.be('null');
+ expect(err.code).to.be('ESOME');
+
+ err = errcode(undefined, 'ESOME');
+ expect(err).to.be.an(Error);
+ expect(err.message).to.be('');
+ expect(err.code).to.be('ESOME');
+ });
+});
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/package.json b/deps/npm/node_modules/pacote/node_modules/promise-retry/package.json
new file mode 100644
index 0000000000..6e32d3a89b
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/package.json
@@ -0,0 +1,71 @@
+{
+ "_from": "promise-retry@^1.1.1",
+ "_id": "promise-retry@1.1.1",
+ "_integrity": "sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0=",
+ "_location": "/pacote/promise-retry",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "promise-retry@^1.1.1",
+ "name": "promise-retry",
+ "escapedName": "promise-retry",
+ "rawSpec": "^1.1.1",
+ "saveSpec": null,
+ "fetchSpec": "^1.1.1"
+ },
+ "_requiredBy": [
+ "/pacote",
+ "/pacote/make-fetch-happen"
+ ],
+ "_resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz",
+ "_shasum": "6739e968e3051da20ce6497fb2b50f6911df3d6d",
+ "_shrinkwrap": null,
+ "_spec": "promise-retry@^1.1.1",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/pacote",
+ "author": {
+ "name": "IndigoUnited",
+ "email": "hello@indigounited.com",
+ "url": "http://indigounited.com"
+ },
+ "bin": null,
+ "bugs": {
+ "url": "https://github.com/IndigoUnited/node-promise-retry/issues/"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "err-code": "^1.0.0",
+ "retry": "^0.10.0"
+ },
+ "deprecated": false,
+ "description": "Retries a function that returns a promise, leveraging the power of the retry module.",
+ "devDependencies": {
+ "expect.js": "^0.3.1",
+ "mocha": "^3.0.0",
+ "sleep-promise": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=0.12"
+ },
+ "homepage": "https://github.com/IndigoUnited/node-promise-retry#readme",
+ "keywords": [
+ "retry",
+ "promise",
+ "backoff",
+ "repeat",
+ "replay"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "promise-retry",
+ "optionalDependencies": {},
+ "peerDependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/IndigoUnited/node-promise-retry.git"
+ },
+ "scripts": {
+ "test": "mocha --bail -t 10000"
+ },
+ "version": "1.1.1"
+}
diff --git a/deps/npm/node_modules/pacote/node_modules/promise-retry/test/test.js b/deps/npm/node_modules/pacote/node_modules/promise-retry/test/test.js
new file mode 100644
index 0000000000..466b0991e0
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/promise-retry/test/test.js
@@ -0,0 +1,263 @@
+'use strict';
+
+var expect = require('expect.js');
+var promiseRetry = require('../');
+var promiseDelay = require('sleep-promise');
+
+describe('promise-retry', function () {
+ it('should call fn again if retry was called', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry) {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ if (count <= 2) {
+ retry(new Error('foo'));
+ }
+
+ return 'final';
+ });
+ }, { factor: 1 })
+ .then(function (value) {
+ expect(value).to.be('final');
+ expect(count).to.be(3);
+ }, function () {
+ throw new Error('should not fail');
+ });
+ });
+
+ it('should call fn with the attempt number', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry, number) {
+ count += 1;
+ expect(count).to.equal(number);
+
+ return promiseDelay(10)
+ .then(function () {
+ if (count <= 2) {
+ retry(new Error('foo'));
+ }
+
+ return 'final';
+ });
+ }, { factor: 1 })
+ .then(function (value) {
+ expect(value).to.be('final');
+ expect(count).to.be(3);
+ }, function () {
+ throw new Error('should not fail');
+ });
+ });
+
+ it('should not retry on fulfillment if retry was not called', function () {
+ var count = 0;
+
+ return promiseRetry(function () {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ return 'final';
+ });
+ })
+ .then(function (value) {
+ expect(value).to.be('final');
+ expect(count).to.be(1);
+ }, function () {
+ throw new Error('should not fail');
+ });
+ });
+
+ it('should not retry on rejection if retry was not called', function () {
+ var count = 0;
+
+ return promiseRetry(function () {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ throw new Error('foo');
+ });
+ })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err.message).to.be('foo');
+ expect(count).to.be(1);
+ });
+ });
+
+ it('should not retry on rejection if nr of retries is 0', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry) {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ throw new Error('foo');
+ })
+ .catch(retry);
+ }, { retries : 0 })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err.message).to.be('foo');
+ expect(count).to.be(1);
+ });
+ });
+
+ it('should reject the promise if the retries were exceeded', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry) {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ throw new Error('foo');
+ })
+ .catch(retry);
+ }, { retries: 2, factor: 1 })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err.message).to.be('foo');
+ expect(count).to.be(3);
+ });
+ });
+
+ it('should pass options to the underlying retry module', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry) {
+ return promiseDelay(10)
+ .then(function () {
+ if (count < 2) {
+ count += 1;
+ retry(new Error('foo'));
+ }
+
+ return 'final';
+ });
+ }, { retries: 1, factor: 1 })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err.message).to.be('foo');
+ });
+ });
+
+ it('should convert direct fulfillments into promises', function () {
+ return promiseRetry(function () {
+ return 'final';
+ }, { factor: 1 })
+ .then(function (value) {
+ expect(value).to.be('final');
+ }, function () {
+ throw new Error('should not fail');
+ });
+ });
+
+ it('should convert direct rejections into promises', function () {
+ promiseRetry(function () {
+ throw new Error('foo');
+ }, { retries: 1, factor: 1 })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err.message).to.be('foo');
+ });
+ });
+
+ it('should not crash on undefined rejections', function () {
+ return promiseRetry(function () {
+ throw undefined;
+ }, { retries: 1, factor: 1 })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err).to.be(undefined);
+ })
+ .then(function () {
+ return promiseRetry(function (retry) {
+ retry();
+ }, { retries: 1, factor: 1 });
+ })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err).to.be(undefined);
+ });
+ });
+
+ it('should retry if retry() was called with undefined', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry) {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ if (count <= 2) {
+ retry();
+ }
+
+ return 'final';
+ });
+ }, { factor: 1 })
+ .then(function (value) {
+ expect(value).to.be('final');
+ expect(count).to.be(3);
+ }, function () {
+ throw new Error('should not fail');
+ });
+ });
+
+ it('should work with several retries in the same chain', function () {
+ var count = 0;
+
+ return promiseRetry(function (retry) {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ retry(new Error('foo'));
+ })
+ .catch(function (err) {
+ retry(err);
+ });
+ }, { retries: 1, factor: 1 })
+ .then(function () {
+ throw new Error('should not succeed');
+ }, function (err) {
+ expect(err.message).to.be('foo');
+ expect(count).to.be(2);
+ });
+ });
+
+ it('should allow options to be passed first', function () {
+ var count = 0;
+
+ return promiseRetry({ factor: 1 }, function (retry) {
+ count += 1;
+
+ return promiseDelay(10)
+ .then(function () {
+ if (count <= 2) {
+ retry(new Error('foo'));
+ }
+
+ return 'final';
+ });
+ }).then(function (value) {
+ expect(value).to.be('final');
+ expect(count).to.be(3);
+ }, function () {
+ throw new Error('should not fail');
+ });
+ });
+});