diff options
author | Rebecca Turner <me@re-becca.org> | 2018-05-24 23:31:26 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-05-24 23:31:38 +0300 |
commit | 0483f5c5deaf18c968a128657923103e49f4e67a (patch) | |
tree | 210f154da2f60938471d96a844dcb32cbda09e2a /node_modules/err-code | |
parent | 6c294614d800cb95a49ef1c422fbdde65b0731a2 (diff) |
Flatten dependencies and add dev deps to git
Diffstat (limited to 'node_modules/err-code')
-rw-r--r-- | node_modules/err-code/.editorconfig | 12 | ||||
-rw-r--r-- | node_modules/err-code/.eslintrc.json | 7 | ||||
-rw-r--r-- | node_modules/err-code/.npmignore | 2 | ||||
-rw-r--r-- | node_modules/err-code/.travis.yml | 5 | ||||
-rw-r--r-- | node_modules/err-code/README.md | 72 | ||||
-rw-r--r-- | node_modules/err-code/bower.json | 30 | ||||
-rw-r--r-- | node_modules/err-code/index.js | 22 | ||||
-rw-r--r-- | node_modules/err-code/index.umd.js | 26 | ||||
-rw-r--r-- | node_modules/err-code/package.json | 64 | ||||
-rw-r--r-- | node_modules/err-code/test/.eslintrc.json | 5 | ||||
-rw-r--r-- | node_modules/err-code/test/test.js | 92 |
11 files changed, 337 insertions, 0 deletions
diff --git a/node_modules/err-code/.editorconfig b/node_modules/err-code/.editorconfig new file mode 100644 index 000000000..829280bee --- /dev/null +++ b/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/node_modules/err-code/.eslintrc.json b/node_modules/err-code/.eslintrc.json new file mode 100644 index 000000000..f34b41d96 --- /dev/null +++ b/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/node_modules/err-code/.npmignore b/node_modules/err-code/.npmignore new file mode 100644 index 000000000..a22dcdd47 --- /dev/null +++ b/node_modules/err-code/.npmignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.* diff --git a/node_modules/err-code/.travis.yml b/node_modules/err-code/.travis.yml new file mode 100644 index 000000000..f85680370 --- /dev/null +++ b/node_modules/err-code/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.12" + - "4" + - "5" diff --git a/node_modules/err-code/README.md b/node_modules/err-code/README.md new file mode 100644 index 000000000..e0234e90a --- /dev/null +++ b/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/node_modules/err-code/bower.json b/node_modules/err-code/bower.json new file mode 100644 index 000000000..a39cb702c --- /dev/null +++ b/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/node_modules/err-code/index.js b/node_modules/err-code/index.js new file mode 100644 index 000000000..1a0a69f62 --- /dev/null +++ b/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/node_modules/err-code/index.umd.js b/node_modules/err-code/index.umd.js new file mode 100644 index 000000000..d1dbdf733 --- /dev/null +++ b/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/node_modules/err-code/package.json b/node_modules/err-code/package.json new file mode 100644 index 000000000..254e00a72 --- /dev/null +++ b/node_modules/err-code/package.json @@ -0,0 +1,64 @@ +{ + "_from": "err-code@^1.0.0", + "_id": "err-code@1.1.2", + "_inBundle": false, + "_integrity": "sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA=", + "_location": "/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": [ + "/promise-retry" + ], + "_resolved": "https://registry.npmjs.org/err-code/-/err-code-1.1.2.tgz", + "_shasum": "06e0116d3028f6aef4806849eb0ea6a748ae6960", + "_spec": "err-code@^1.0.0", + "_where": "/Users/rebecca/code/npm/node_modules/promise-retry", + "author": { + "name": "IndigoUnited", + "email": "hello@indigounited.com", + "url": "http://indigounited.com" + }, + "bugs": { + "url": "https://github.com/IndigoUnited/js-err-code/issues/" + }, + "bundleDependencies": false, + "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", + "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/node_modules/err-code/test/.eslintrc.json b/node_modules/err-code/test/.eslintrc.json new file mode 100644 index 000000000..f9fbb2d6c --- /dev/null +++ b/node_modules/err-code/test/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "env": { + "mocha": true + } +}
\ No newline at end of file diff --git a/node_modules/err-code/test/test.js b/node_modules/err-code/test/test.js new file mode 100644 index 000000000..81b2b26d3 --- /dev/null +++ b/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'); + }); +}); |