Comparing version 8.1.0 to 8.1.1
@@ -54,12 +54,27 @@ /** | ||
else if (_.isArray(valuePart)) { | ||
// multi-item arrays become pattern arrays | ||
if (valuePart.length > 1) { | ||
// empty arrays just become generic arrays | ||
if (valuePart.length === 0) { | ||
return valuePart; | ||
} | ||
// NON-empty arrays become pattern arrays | ||
// (any extra items beyond the first are folded together, in order to deduce the best pattern exemplar) | ||
else { | ||
// To do this, we union together all of the items in the array, | ||
// then use the result as our deduced pattern. | ||
var pattern = _.reduce(valuePart.slice(1), function (patternSoFar, item) { | ||
patternSoFar = union(patternSoFar, _recursivelyCoerceExemplar(item), true, false); // <= recursive step | ||
// meaning of `union` flags, in order: | ||
// • `true` (yes these are exemplars) | ||
// • `false` (no, don't use strict validation rules) | ||
return patternSoFar; | ||
}, _recursivelyCoerceExemplar(valuePart[0]) /* <= recursive step */); | ||
// If the narrowest common schema for the pattern is "===" (ref), that means | ||
// the schema for the entire pattern array is `['===']`. If that's the case, | ||
// we can simply think of it as `[]` (generic/heterogeneous array), since there's | ||
// no material guarantee of homogeneity anyways (and since that way you're less | ||
// likely to inadverently deduce any weird conclusions about mutability). | ||
// So for our purposes here: `['===']` is the same as `[]` | ||
return [ | ||
_.reduce(valuePart.slice(1), function (patternSoFar, item) { | ||
item = _recursivelyCoerceExemplar(item); // <= recursive step | ||
patternSoFar = union(patternSoFar, item, true, false); // <= flags are `true` (yes these are exemplars) and `false` (no, don't use strict validation rules) | ||
return patternSoFar; | ||
}, _recursivelyCoerceExemplar(valuePart[0]) /* <= recursive step */) | ||
pattern | ||
]; | ||
@@ -66,0 +81,0 @@ } |
{ | ||
"name": "rttc", | ||
"version": "8.1.0", | ||
"version": "8.1.1", | ||
"description": "Runtime type-checking for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
212793
4543