This commit is contained in:
2018-05-16 10:10:23 +02:00
commit 79abc63edd
597 changed files with 93351 additions and 0 deletions

8
node_modules/test-value/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,8 @@
language: node_js
node_js:
- 4
- 5
- 6
- 7
- 8
- 9

21
node_modules/test-value/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-18 Lloyd Brookes <75pound@gmail.com>
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.

11
node_modules/test-value/README.hbs generated vendored Normal file
View File

@ -0,0 +1,11 @@
[![view on npm](http://img.shields.io/npm/v/test-value.svg)](https://www.npmjs.org/package/test-value)
[![npm module downloads](http://img.shields.io/npm/dt/test-value.svg)](https://www.npmjs.org/package/test-value)
[![Build Status](https://travis-ci.org/75lb/test-value.svg?branch=master)](https://travis-ci.org/75lb/test-value)
[![Dependency Status](https://david-dm.org/75lb/test-value.svg)](https://david-dm.org/75lb/test-value)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
{{>main}}
* * *
&copy; 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

45
node_modules/test-value/README.md generated vendored Normal file
View File

@ -0,0 +1,45 @@
[![view on npm](http://img.shields.io/npm/v/test-value.svg)](https://www.npmjs.org/package/test-value)
[![npm module downloads](http://img.shields.io/npm/dt/test-value.svg)](https://www.npmjs.org/package/test-value)
[![Build Status](https://travis-ci.org/75lb/test-value.svg?branch=master)](https://travis-ci.org/75lb/test-value)
[![Dependency Status](https://david-dm.org/75lb/test-value.svg)](https://david-dm.org/75lb/test-value)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
<a name="module_test-value"></a>
## test-value
**Example**
```js
const testValue = require('test-value')
```
* [test-value](#module_test-value)
* [testValue(value, test, [options])](#exp_module_test-value--testValue) ⇒ <code>boolean</code>
* [.where(test)](#module_test-value--testValue.where) ⇒ <code>function</code>
<a name="exp_module_test-value--testValue"></a>
### testValue(value, test, [options]) ⇒ <code>boolean</code> ⏏
**Kind**: Exported function
| Param | Type | Description |
| --- | --- | --- |
| value | <code>any</code> | a value to test |
| test | <code>any</code> | the test query |
| [options] | <code>object</code> | |
| [options.strict] | <code>boolean</code> | Treat an object like a value not a query. |
<a name="module_test-value--testValue.where"></a>
#### testValue.where(test) ⇒ <code>function</code>
Returns a callback suitable for use by `Array` methods like `some`, `filter`, `find` etc.
**Kind**: static method of [<code>testValue</code>](#exp_module_test-value--testValue)
| Param | Type | Description |
| --- | --- | --- |
| test | <code>any</code> | the test query |
* * *
&copy; 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

83
node_modules/test-value/index.js generated vendored Normal file
View File

@ -0,0 +1,83 @@
'use strict'
const arrayify = require('array-back')
const t = require('typical')
/**
* @module test-value
* @example
* const testValue = require('test-value')
*/
module.exports = testValue
/**
* @alias module:test-value
* @param {any} - a value to test
* @param {any} - the test query
* @param [options] {object}
* @param [options.strict] {boolean} - Treat an object like a value not a query.
* @returns {boolean}
*/
function testValue (value, test, options) {
options = options || {}
if (test !== Object.prototype && t.isPlainObject(test) && t.isObject(value) && !options.strict) {
return Object.keys(test).every(function (prop) {
let queryValue = test[prop]
/* get flags */
let isNegated = false
let isContains = false
if (prop.charAt(0) === '!') {
isNegated = true
} else if (prop.charAt(0) === '+') {
isContains = true
}
/* strip flag char */
prop = (isNegated || isContains) ? prop.slice(1) : prop
let objectValue = value[prop]
if (isContains) {
queryValue = arrayify(queryValue)
objectValue = arrayify(objectValue)
}
const result = testValue(objectValue, queryValue, options)
return isNegated ? !result : result
})
} else if (test !== Array.prototype && Array.isArray(test)) {
const tests = test
if (value === Array.prototype || !Array.isArray(value)) value = [ value ]
return value.some(function (val) {
return tests.some(function (test) {
return testValue(val, test, options)
})
})
/*
regexes queries will always return `false` for `null`, `undefined`, `NaN`.
This is to prevent a query like `/.+/` matching the string `undefined`.
*/
} else if (test instanceof RegExp) {
if ([ 'boolean', 'string', 'number' ].indexOf(typeof value) === -1) {
return false
} else {
return test.test(value)
}
} else if (test !== Function.prototype && typeof test === 'function') {
return test(value)
} else {
return test === value
}
}
/**
* Returns a callback suitable for use by `Array` methods like `some`, `filter`, `find` etc.
* @param {any} - the test query
* @returns {function}
*/
testValue.where = function (test) {
return function (value) {
return testValue(value, test)
}
}

59
node_modules/test-value/package.json generated vendored Normal file
View File

@ -0,0 +1,59 @@
{
"_from": "test-value@^3.0.0",
"_id": "test-value@3.0.0",
"_inBundle": false,
"_integrity": "sha512-sVACdAWcZkSU9x7AOmJo5TqE+GyNJknHaHsMrR6ZnhjVlVN9Yx6FjHrsKZ3BjIpPCT68zYesPWkakrNupwfOTQ==",
"_location": "/test-value",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "test-value@^3.0.0",
"name": "test-value",
"escapedName": "test-value",
"rawSpec": "^3.0.0",
"saveSpec": null,
"fetchSpec": "^3.0.0"
},
"_requiredBy": [
"/find-replace"
],
"_resolved": "https://registry.npmjs.org/test-value/-/test-value-3.0.0.tgz",
"_shasum": "9168c062fab11a86b8d444dd968bb4b73851ce92",
"_spec": "test-value@^3.0.0",
"_where": "/home/wn/workspace-node/PiAlive/node_modules/find-replace",
"author": {
"name": "Lloyd Brookes",
"email": "75pound@gmail.com"
},
"bugs": {
"url": "https://github.com/75lb/test-value/issues"
},
"bundleDependencies": false,
"dependencies": {
"array-back": "^2.0.0",
"typical": "^2.6.1"
},
"deprecated": false,
"description": "Test a value in a variety of ways",
"devDependencies": {
"jsdoc-to-markdown": "^3.0.2",
"test-runner": "^0.4.1"
},
"engines": {
"node": ">=4.0.0"
},
"homepage": "https://github.com/75lb/test-value#readme",
"keywords": [],
"license": "MIT",
"name": "test-value",
"repository": {
"type": "git",
"url": "git+https://github.com/75lb/test-value.git"
},
"scripts": {
"docs": "jsdoc2md -t README.hbs index.js > README.md; echo",
"test": "test-runner test.js"
},
"version": "3.0.0"
}

255
node_modules/test-value/test.js generated vendored Normal file
View File

@ -0,0 +1,255 @@
'use strict'
const TestRunner = require('test-runner')
const testValue = require('./')
const a = require('assert')
function TestClass () {
this.one = 1
}
const testClass = new TestClass()
const runner = new TestRunner()
const fixture = {
result: 'clive',
hater: true,
colour: 'red-ish',
deep: {
name: 'Zhana',
favourite: {
colour: [ 'white', 'red' ]
},
arr: [ 1, 2, 3 ]
},
nullVal: null,
boolTrue: true,
number: 5,
testClass: testClass,
arr: [ 1, 2, 3 ],
arrObjects: [
{ number: 1 },
{ number: 2 }
]
}
runner.test('testValue(obj, { property: primative })', function () {
a.strictEqual(testValue(fixture, { result: 'clive' }), true)
a.strictEqual(testValue(fixture, { hater: true }), true)
a.strictEqual(testValue(fixture, { result: 'clive', hater: true }), true)
a.strictEqual(testValue(fixture, { ibe: true }), false)
})
runner.test('testValue(obj, { !property: primative })', function () {
a.strictEqual(testValue(fixture, { '!result': 'clive' }), false)
a.strictEqual(testValue(fixture, { '!result': 'ian' }), true)
a.strictEqual(testValue(fixture, { '!result': 'ian', '!hater': false }), true)
})
runner.test('testValue(obj, { property: primative[] })', function () {
a.strictEqual(testValue(fixture, { arr: [ 1, 2, 3 ] }), true)
a.strictEqual(testValue(fixture, { arr: [ /1/ ] }), true)
a.strictEqual(testValue(fixture, { arr: [ /4/ ] }), false)
a.strictEqual(testValue(fixture, { colour: [ 1, 2, 3 ] }), false, 'querying a string with array')
a.strictEqual(testValue(fixture, { undefinedProperty: [ 1, 2, 3 ] }), false, 'querying undefined property')
a.strictEqual(testValue(fixture, { undefinedProperty: [ undefined ] }), true)
a.strictEqual(testValue(fixture, { undefinedProperty: [ null ] }), false)
})
runner.test('testValue(obj, { property: { property: primative[] } })', function () {
a.strictEqual(testValue(fixture, { deep: { arr: [ 1, 2 ] } }), true)
a.strictEqual(testValue(fixture, { deep: { arr: [ 3, 4 ] } }), true)
a.strictEqual(testValue(fixture, { deep: { favourite: { colour: [ 'white', 'red' ] } } }), true)
})
runner.test('testValue(obj, { property: undefined, property: regex })', function () {
a.strictEqual(testValue(fixture.deep, { undefinedProperty: undefined, name: /.+/ }), true)
})
runner.test('testValue(obj, { property: /regex/ })', function () {
a.strictEqual(testValue(fixture, { colour: /red/ }), true)
a.strictEqual(testValue(fixture, { colour: /black/ }), false)
a.strictEqual(testValue(fixture, { colour: /RED/i }), true)
a.strictEqual(testValue(fixture, { colour: /.+/ }), true)
a.strictEqual(testValue(fixture, { undefinedProperty: /.+/ }), false, 'testing undefined val')
a.strictEqual(testValue(fixture, { deep: /.+/ }), false, 'testing an object val')
a.strictEqual(testValue(fixture, { nullVal: /.+/ }), false, 'testing a null val')
a.strictEqual(testValue(fixture, { boolTrue: /true/ }), true, 'testing a boolean val')
a.strictEqual(testValue(fixture, { boolTrue: /addf/ }), false, 'testing a boolean val')
})
runner.test('testValue(obj, { !property: /regex/ })', function () {
a.strictEqual(testValue(fixture, { '!colour': /red/ }), false)
a.strictEqual(testValue(fixture, { '!colour': /black/ }), true)
a.strictEqual(testValue(fixture, { '!colour': /blue/ }), true)
})
runner.test('testValue(obj, { property: function })', function () {
a.strictEqual(testValue(fixture, { number: function (n) { return n < 4 } }), false, '< 4')
a.strictEqual(testValue(fixture, { number: function (n) { return n < 10 } }), true, '< 10')
})
runner.test('testValue(obj, { !property: function })', function () {
a.strictEqual(testValue(fixture, { '!number': function (n) { return n < 10 } }), false, '< 10')
})
runner.test('testValue(obj, { property: object })', function () {
a.strictEqual(testValue(fixture, { testClass: { one: 1 } }), true, 'querying a plain object')
a.strictEqual(testValue(fixture, { testClass: testClass }), true, 'querying an object instance')
})
runner.test('testValue(obj, { +property: primitive })', function () {
a.strictEqual(testValue(fixture, { arr: 1 }), false)
a.strictEqual(testValue(fixture, { '+arr': 1 }), true)
})
runner.test('testValue(obj, { property. { +property: query } })', function () {
a.strictEqual(testValue(fixture, { deep: { favourite: { '+colour': 'red' } } }), true)
a.strictEqual(testValue(fixture, { deep: { favourite: { '+colour': /red/ } } }), true)
a.strictEqual(testValue(fixture, { deep: { favourite: { '+colour': function (c) {
return c === 'red'
} } } }), true)
a.strictEqual(testValue(fixture, { deep: { favourite: { '+colour': /green/ } } }), false)
})
runner.test('testValue(obj, { +property: query })', function () {
a.strictEqual(testValue(fixture, { arrObjects: { number: 1 } }), false)
a.strictEqual(testValue(fixture, { '+arrObjects': { number: 1 } }), true)
})
runner.test('object deep exists, summary', function () {
const query = {
one: {
one: {
three: 'three',
'!four': 'four'
},
two: {
one: {
one: 'one'
},
'!two': undefined,
'!three': [ { '!one': { '!one': '110' } } ]
}
}
}
const obj1 = {
one: {
one: {
one: 'one',
two: 'two',
three: 'three'
},
two: {
one: {
one: 'one'
},
two: 2
}
}
}
const obj2 = {
one: {
one: {
one: 'one',
two: 'two'
},
two: {
one: {
one: 'one'
},
two: 2
}
}
}
const obj3 = {
one: {
one: {
one: 'one',
two: 'two',
three: 'three'
},
two: {
one: {
one: 'one'
},
two: 2,
three: [
{ one: { one: '100' } },
{ one: { one: '110' } }
]
}
}
}
const obj4 = {
one: {
one: {
one: 'one',
two: 'two',
three: 'three'
},
two: {
one: {
one: 'one'
},
two: 2,
three: [
{ one: { one: '100' } }
]
}
}
}
a.strictEqual(testValue(obj1, query), true, 'true obj1')
a.strictEqual(testValue(obj2, query), false, 'false obj2')
a.strictEqual(testValue(obj3, query), false, 'false in obj3')
a.strictEqual(testValue(obj4, query), true, 'true in obj4')
})
runner.test('testValue.where({ property: primative })', function () {
const arr = [
{ num: 1 }, { num: 2 }, { num: 3 }
]
a.strictEqual(arr.some(testValue.where({ num: 2 })), true)
a.strictEqual(arr.some(testValue.where({ num: 4 })), false)
a.deepEqual(arr.filter(testValue.where({ num: 2 })), [ { num: 2 } ])
a.deepEqual(arr.filter(testValue.where({ num: 4 })), [])
})
runner.test('testValue(val, object, { strict: true })', function () {
const obj1 = { one: 1 }
const query1 = { one: 1 }
const query2 = { two: 2 }
a.strictEqual(testValue(obj1, query1), true)
a.strictEqual(testValue(obj1, query1, { strict: true }), false)
a.strictEqual(testValue(obj1, query2), false)
a.strictEqual(testValue(obj1, query2, { strict: true }), false)
a.strictEqual(testValue(obj1, [ query1 ]), true)
a.strictEqual(testValue(obj1, [ query1 ], { strict: true }), false)
a.strictEqual(testValue(obj1, [ query2 ]), false)
a.strictEqual(testValue(obj1, [ query2 ], { strict: true }), false)
a.strictEqual(testValue(obj1, [ query1, query2 ]), true)
a.strictEqual(testValue(obj1, [ query1, query2 ], { strict: true }), false)
a.strictEqual(testValue(obj1, [ query1, query2, obj1 ], { strict: true }), true)
a.strictEqual(testValue(Object.getPrototypeOf([ 1, 2 ]), Array.prototype), true)
a.strictEqual(testValue(Object.getPrototypeOf([ 1, 2 ]), [ Array.prototype ]), true)
a.strictEqual(testValue(Object.getPrototypeOf([ 1, 2 ]), Array.prototype, { strict: true }), true)
a.strictEqual(testValue(Object.getPrototypeOf([ 1, 2 ]), [ Array.prototype ], { strict: true }), true)
function one () {}
a.strictEqual(testValue(one, Function.prototype), false)
a.strictEqual(testValue(Object.getPrototypeOf(one), Function.prototype), true)
a.strictEqual(testValue(Object.getPrototypeOf(one), [ Function.prototype ]), true)
a.strictEqual(testValue(Object.getPrototypeOf(one), Function.prototype, { strict: true }), true)
a.strictEqual(testValue(Object.getPrototypeOf(one), [ Function.prototype ], { strict: true }), true)
a.strictEqual(testValue({}, Object.prototype), false)
a.strictEqual(testValue(Object.getPrototypeOf({}), Object.prototype), true)
a.strictEqual(testValue(Object.getPrototypeOf({}), [ Object.prototype ]), true)
a.strictEqual(testValue(Object.getPrototypeOf({}), Object.prototype, { strict: true }), true)
a.strictEqual(testValue(Object.getPrototypeOf({}), [ Object.prototype ], { strict: true }), true)
})