Socket
Socket
Sign inDemoInstall

rttc

Package Overview
Dependencies
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rttc - npm Package Compare versions

Comparing version 8.1.0 to 8.1.1

29

lib/coerce-exemplar.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc