@znck/prop-types
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="0.5.1"></a> | ||
## [0.5.1](https://github.com/znck/vue-prop-types/compare/v0.5.0...v0.5.1) (2019-01-26) | ||
### Bug Fixes | ||
* Use Array.concat as fallback to Array.flat ([df7c646](https://github.com/znck/vue-prop-types/commit/df7c646)) | ||
<a name="0.5.0"></a> | ||
@@ -7,0 +17,0 @@ # [0.5.0](https://github.com/znck/vue-prop-types/compare/v0.4.3...v0.5.0) (2019-01-23) |
/** | ||
* @znck/prop-types v0.5.0 | ||
* @znck/prop-types v0.5.1 | ||
* (c) 2019 Rahul Kadyan <hi@znck.me> (https://znck.me) | ||
@@ -16,2 +16,6 @@ * @license MIT | ||
const typeValues = () => Object.values(TYPES); | ||
function flat(arr) { | ||
if (typeof arr.flat === 'function') return arr.flat(); | ||
return Array.prototype.concat.apply([], arr); | ||
} | ||
function runValidation(validator, value) { | ||
@@ -147,5 +151,5 @@ let strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
values = values.flat(); | ||
values = flat(values); | ||
ensureOne(values); | ||
const types = [...new Set(values.map(value => TYPES[typeof value] || Object))]; | ||
const types = Array.from(new Set(values.map(value => TYPES[typeof value] || Object))); | ||
const prop = this.create(types); | ||
@@ -166,5 +170,5 @@ const setOfValues = new Set(values); | ||
types = types.flat().map(normalizeType); | ||
types = flat(types).map(normalizeType); | ||
ensureOne(types); | ||
const prop = this.create(types.map(type => ensureArray(type.type)).flat()); | ||
const prop = this.create(flat(types.map(type => ensureArray(type.type)))); | ||
@@ -196,3 +200,3 @@ prop.validator = value => types.some(validator => runValidation(validator, value)); | ||
const prop = this.create(type); | ||
const types = expected.flat().map(normalizeType); | ||
const types = flat(expected).map(normalizeType); | ||
@@ -199,0 +203,0 @@ prop.validator = value => Object.values(value).every(item => types.some(type => runValidation(type, item))); |
/** | ||
* @znck/prop-types v0.5.0 | ||
* @znck/prop-types v0.5.1 | ||
* (c) 2019 Rahul Kadyan <hi@znck.me> (https://znck.me) | ||
@@ -18,2 +18,6 @@ * @license MIT | ||
const typeValues = () => Object.values(TYPES); | ||
function flat(arr) { | ||
if (typeof arr.flat === 'function') return arr.flat(); | ||
return Array.prototype.concat.apply([], arr); | ||
} | ||
function runValidation(validator, value) { | ||
@@ -149,5 +153,5 @@ let strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
values = values.flat(); | ||
values = flat(values); | ||
ensureOne(values); | ||
const types = [...new Set(values.map(value => TYPES[typeof value] || Object))]; | ||
const types = Array.from(new Set(values.map(value => TYPES[typeof value] || Object))); | ||
const prop = this.create(types); | ||
@@ -168,5 +172,5 @@ const setOfValues = new Set(values); | ||
types = types.flat().map(normalizeType); | ||
types = flat(types).map(normalizeType); | ||
ensureOne(types); | ||
const prop = this.create(types.map(type => ensureArray(type.type)).flat()); | ||
const prop = this.create(flat(types.map(type => ensureArray(type.type)))); | ||
@@ -198,3 +202,3 @@ prop.validator = value => types.some(validator => runValidation(validator, value)); | ||
const prop = this.create(type); | ||
const types = expected.flat().map(normalizeType); | ||
const types = flat(expected).map(normalizeType); | ||
@@ -201,0 +205,0 @@ prop.validator = value => Object.values(value).every(item => types.some(type => runValidation(type, item))); |
{ | ||
"name": "@znck/prop-types", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Fluent prop validation for Vue", | ||
@@ -5,0 +5,0 @@ "main": "dist/prop-types.js", |
/** | ||
* @znck/prop-types v0.5.0 | ||
* @znck/prop-types v0.5.1 | ||
* (c) 2019 Rahul Kadyan <hi@znck.me> (https://znck.me) | ||
@@ -4,0 +4,0 @@ * @license MIT |
@@ -13,3 +13,8 @@ export const TYPES = { | ||
export const typeValues = () => Object.values(TYPES) | ||
export function flat(arr) { | ||
if (typeof arr.flat === 'function') return arr.flat() | ||
return Array.prototype.concat.apply([], arr) | ||
} | ||
export function runValidation(validator, value, strict = false) { | ||
@@ -16,0 +21,0 @@ const types = ensureArray(validator.type) |
@@ -7,2 +7,3 @@ import { | ||
typeValues, | ||
flat | ||
} from './helpers' | ||
@@ -112,9 +113,7 @@ | ||
static oneOf(...values) { | ||
values = values.flat() | ||
values = flat(values) | ||
ensureOne(values) | ||
const types = [ | ||
...new Set(values.map(value => TYPES[typeof value] || Object)), | ||
] | ||
const types = Array.from(new Set(values.map(value => TYPES[typeof value] || Object))) | ||
const prop = this.create(types) | ||
@@ -131,7 +130,7 @@ const setOfValues = new Set(values) | ||
static oneOfType(...types) { | ||
types = types.flat().map(normalizeType) | ||
types = flat(types).map(normalizeType) | ||
ensureOne(types) | ||
const prop = this.create(types.map(type => ensureArray(type.type)).flat()) | ||
const prop = this.create(flat(types.map(type => ensureArray(type.type)))) | ||
@@ -155,3 +154,3 @@ prop.validator = value => | ||
const prop = this.create(type) | ||
const types = expected.flat().map(normalizeType) | ||
const types = flat(expected).map(normalizeType) | ||
@@ -158,0 +157,0 @@ prop.validator = value => |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41104
985