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.3 to 8.1.4

12

lib/coerce-exemplar.js

@@ -14,6 +14,10 @@ /**

*
* If `allowSpecialSyntax` is set, '->', '*', and '===' take on their traditional special meaning.
* Otherwise, they will be replaced with strings ('an arrow symbol', 'a star symbol', '3 equal signs')
*
* @param {*} value
* @param {Boolean} allowSpecialSyntax
* @return {*}
*/
module.exports = function coerceExemplar (value) {
module.exports = function coerceExemplar (value, allowSpecialSyntax) {

@@ -45,9 +49,9 @@ // Top-level `undefined` becomes `===`

else if (typeInfo('json').isExemplar(valuePart)) {
return typeInfo('json').getExemplarDescription();
return allowSpecialSyntax ? valuePart : typeInfo('json').getExemplarDescription();
}
else if (typeInfo('ref').isExemplar(valuePart)) {
return typeInfo('ref').getExemplarDescription();
return allowSpecialSyntax ? valuePart : typeInfo('ref').getExemplarDescription();
}
else if (typeInfo('lamda').isExemplar(valuePart)) {
return typeInfo('lamda').getExemplarDescription();
return allowSpecialSyntax ? valuePart : typeInfo('lamda').getExemplarDescription();
}

@@ -54,0 +58,0 @@ // arrays need a recursive step

{
"name": "rttc",
"version": "8.1.3",
"version": "8.1.4",
"description": "Runtime type-checking for JavaScript.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -460,3 +460,3 @@ # rttc

##### .coerceExemplar(value)
##### .coerceExemplar(value, [allowSpecialSyntax=false])

@@ -478,7 +478,5 @@ Convert a normal value into an exemplar representative of the _most specific_ type schema which would accept it. In most cases, this leaves the value untouched-- however it does take care of a few special cases:

If the `allowSpecialSyntax` flag is enabled, then `*`, `->`, and `===` will take on their traditional meaning instead of being replaced with strings (e.g. "a star symbol").
```js
rttc.coerceExemplar({x:'*'})
// => { x: 'a star symbol' }
rttc.coerceExemplar([{a:null}, {b: [[74,39,'surprise string!']] }])

@@ -489,2 +487,8 @@ // => [ {} ]

// => [ 'surprise string!' ]
rttc.coerceExemplar({x:'*'})
// => { x: 'a star symbol' }
rttc.coerceExemplar({x:'*'}, true)
// => { x: '*' }
```

@@ -491,0 +495,0 @@

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