added unit testing, and started implementing unit tests...phew

This commit is contained in:
Josh Burman
2019-03-12 22:28:02 -04:00
parent 74aad4a957
commit e8c2539f1b
3489 changed files with 464813 additions and 88 deletions

2
node_modules/enabled/.npmignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
coverage

20
node_modules/enabled/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,20 @@
language: node_js
node_js:
- "0.12"
- "0.10"
- "0.8"
- "iojs"
before_install:
- "npm install -g npm@1.4.x"
script:
- "npm run test-travis"
after_script:
- "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
matrix:
fast_finish: true
notifications:
irc:
channels:
- "irc.freenode.org#bigpipe"
on_success: change
on_failure: change

20
node_modules/enabled/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2015 Arnout Kazemier, Martijn Swaagman, the Contributors.
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.

63
node_modules/enabled/README.md generated vendored Normal file
View File

@ -0,0 +1,63 @@
# enabled
[![From bigpipe.io][from]](http://bigpipe.io)[![Version npm][version]](http://browsenpm.org/package/enabled)[![Build Status][build]](https://travis-ci.org/bigpipe/enabled)[![Dependencies][david]](https://david-dm.org/bigpipe/enabled)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/enabled?branch=master)
[from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square
[version]: http://img.shields.io/npm/v/enabled.svg?style=flat-square
[build]: http://img.shields.io/travis/bigpipe/enabled/master.svg?style=flat-square
[david]: https://img.shields.io/david/bigpipe/enabled.svg?style=flat-square
[cover]: http://img.shields.io/coveralls/bigpipe/enabled/master.svg?style=flat-square
Enabled is a small utility that can check if certain namespace are enabled by
environment variables which are automatically transformed to regular expressions
for matching.
## Installation
The module is release in the public npm registry and can be used in browsers and
servers as it uses plain ol ES3 to make the magic work.
```
npm install --save enabled
```
## Usage
First of all make sure you've required the module using:
```js
'use strict';
var enabled = require('enabled');
```
The returned `enabled` function accepts 2 arguments.
1. `name` **string**, The namespace that should match.
2. `variables` **array**, **optional**, Names of the `env` variable that it
should use for matching. If no argument is supplied it will default to
`diagnostics` and `debug`.
#### Examples
```js
process.env.DEBUG = 'foo';
enabled('foo') // true;
enabled('bar') // false;
// can use wildcards
process.env.DEBUG = 'foob*';
enabled('foobar') // true;
enabled('barfoo') // false;
process.env.DEBUG = 'foobar,-shizzle,nizzle';
enabled('foobar') // true;
enabled('shizzle-my-nizzle') // false;
enabled('nizzle') // true;
```
## License
MIT

46
node_modules/enabled/index.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
'use strict';
var env = require('env-variable');
/**
* Checks if a given namespace is allowed by the environment variables.
*
* @param {String} name namespace that should be included.
* @param {Array} variables
* @returns {Boolean}
* @api public
*/
module.exports = function enabled(name, variables) {
var envy = env()
, variable
, i = 0;
variables = variables || ['diagnostics', 'debug'];
for (; i < variables.length; i++) {
if ((variable = envy[variables[i]])) break;
}
if (!variable) return false;
variables = variable.split(/[\s,]+/);
i = 0;
for (; i < variables.length; i++) {
variable = variables[i].replace('*', '.*?');
if ('-' === variable.charAt(0)) {
if ((new RegExp('^'+ variable.substr(1) +'$')).test(name)) {
return false;
}
continue;
}
if ((new RegExp('^'+ variable +'$')).test(name)) {
return true;
}
}
return false;
};

68
node_modules/enabled/package.json generated vendored Normal file
View File

@ -0,0 +1,68 @@
{
"_from": "enabled@1.0.x",
"_id": "enabled@1.0.2",
"_inBundle": false,
"_integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=",
"_location": "/enabled",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "enabled@1.0.x",
"name": "enabled",
"escapedName": "enabled",
"rawSpec": "1.0.x",
"saveSpec": null,
"fetchSpec": "1.0.x"
},
"_requiredBy": [
"/diagnostics"
],
"_resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz",
"_shasum": "965f6513d2c2d1c5f4652b64a2e3396467fc2f93",
"_spec": "enabled@1.0.x",
"_where": "/Users/josh.burman/Projects/braid/node_modules/diagnostics",
"author": {
"name": "Arnout Kazemier"
},
"bugs": {
"url": "https://github.com/bigpipe/enabled/issues"
},
"bundleDependencies": false,
"dependencies": {
"env-variable": "0.0.x"
},
"deprecated": false,
"description": "Check if a certain debug flag is enabled.",
"devDependencies": {
"assume": "1.3.x",
"istanbul": "0.4.x",
"mocha": "2.3.x",
"pre-commit": "1.1.x"
},
"homepage": "https://github.com/bigpipe/enabled#readme",
"keywords": [
"enabled",
"debug",
"diagnostics",
"flag",
"env",
"variable",
"localstorage"
],
"license": "MIT",
"main": "index.js",
"name": "enabled",
"repository": {
"type": "git",
"url": "git://github.com/bigpipe/enabled.git"
},
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js",
"test": "mocha test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js",
"watch": "mocha --watch test.js"
},
"version": "1.0.2"
}

63
node_modules/enabled/test.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
describe('enabled', function () {
'use strict';
var assume = require('assume')
, enabled = require('./');
beforeEach(function () {
process.env.DEBUG = '';
process.env.DIAGNOSTICS = '';
});
it('uses the `debug` env', function () {
process.env.DEBUG = 'bigpipe';
assume(enabled('bigpipe')).to.be.true();
assume(enabled('false')).to.be.false();
});
it('uses the `diagnostics` env', function () {
process.env.DIAGNOSTICS = 'bigpipe';
assume(enabled('bigpipe')).to.be.true();
assume(enabled('false')).to.be.false();
});
it('supports wildcards', function () {
process.env.DEBUG = 'b*';
assume(enabled('bigpipe')).to.be.true();
assume(enabled('bro-fist')).to.be.true();
assume(enabled('ro-fist')).to.be.false();
});
it('is disabled by default', function () {
process.env.DEBUG = '';
assume(enabled('bigpipe')).to.be.false();
process.env.DEBUG = 'bigpipe';
assume(enabled('bigpipe')).to.be.true();
});
it('can ignore loggers using a -', function () {
process.env.DEBUG = 'bigpipe,-primus,sack,-other';
assume(enabled('bigpipe')).to.be.true();
assume(enabled('sack')).to.be.true();
assume(enabled('primus')).to.be.false();
assume(enabled('other')).to.be.false();
assume(enabled('unknown')).to.be.false();
});
it('supports multiple ranges', function () {
process.env.DEBUG = 'bigpipe*,primus*';
assume(enabled('bigpipe:')).to.be.true();
assume(enabled('bigpipes')).to.be.true();
assume(enabled('primus:')).to.be.true();
assume(enabled('primush')).to.be.true();
assume(enabled('unknown')).to.be.false();
});
});