Socket
Socket
Sign inDemoInstall

rttc

Package Overview
Dependencies
1
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.8.0 to 9.8.1

4

lib/coerce-exemplar.js

@@ -48,3 +48,5 @@ /**

* @param {boolean} useStrict
* If set, the schemas will be unioned using strict validation rules.
* If set, the pattern exemplar for any multi-item arrays within the provided value will be
* determined by coercing and unioning the array items using strict validation rules (e.g. `32 ∪ 'foo' <=> '*'`).
* Otherwise, loose validation rules will be used instead (e.g. `32 ∪ 'foo' <=> 'foo`).
* > The default value for this flag will be changed to `false` in a future release.

@@ -51,0 +53,0 @@ * @default true

{
"name": "rttc",
"version": "9.8.0",
"version": "9.8.1",
"description": "Runtime type-checking for JavaScript.",

@@ -36,3 +36,3 @@ "main": "index.js",

"dependencies": {
"lodash": "3.8.0"
"lodash": "3.10.1"
},

@@ -39,0 +39,0 @@ "devDependencies": {

@@ -956,13 +956,33 @@ # RTTC

##### .sample(typeSchema, [n=2])
Given a type schema, return an array of up to `n` unique sample values that would validate against it (in random order). `n` defaults to 2 if left undefined.
### Convenience
> Simple convenience methods that wrap up one or more of the other `rttc` methods for a particular use case.
##### .getBaseVal(exemplar)
A convenience method to return the base value for the given exemplar. This is effectively the same thing as calling `rttc.infer()` to get the exemplar's type schema, then coercing `undefined` to match it (i.e. passing the type schema to `rttc.coerce()` without a second argument).
```js
rttc.getBaseVal(exemplar);
// ... is just a shorcut for doing:
rttc.coerce(rttc.infer(exemplar), undefined);
```
##### .cast(exemplar, actualValue)
A convenience method that calls `rttc.infer()` on the provided exemplar to get the type schema, then uses it to `rttc.coerce()` the `actualValue` provided.
```js
rttc.cast(exemplar, actualValue);
// ... is just a shorcut for doing:
rttc.coerce(rttc.infer(exemplar), actualValue);
```
### Experimental

@@ -973,2 +993,7 @@

##### .sample(typeSchema, [n=2])
Given a type schema, return an array of up to `n` unique sample values that would validate against it (in random order). `n` defaults to 2 if left undefined.
##### .isSpecific(typeSchemaOrExemplar, [recursive=false], [isExemplar=false])

@@ -1023,26 +1048,4 @@

##### .getBaseVal(exemplar)
A convenience method to return the base value for the given exemplar. This is effectively the same thing as calling `rttc.infer()` to get the exemplar's type schema, then coercing `undefined` to match it (i.e. passing the type schema to `rttc.coerce()` without a second argument).
```js
rttc.getBaseVal(exemplar);
// ... is just a shorcut for doing:
rttc.coerce(rttc.infer(exemplar), undefined);
```
##### .cast(exemplar, actualValue)
A convenience method that calls `rttc.infer()` on the provided exemplar to get the type schema, then uses it to `rttc.coerce()` the `actualValue` provided.
```js
rttc.cast(exemplar, actualValue);
// ... is just a shorcut for doing:
rttc.coerce(rttc.infer(exemplar), actualValue);
```
## License

@@ -1049,0 +1052,0 @@

@@ -869,3 +869,3 @@ // ██████╗ ████████╗████████╗ ██████╗ ███████╗██████╗ ███████╗ ██████╗

actual: {},
result: { id: 0, title: '', body: '', votes: 0, resolved: false, something: undefined },
result: { id: 0, title: '', body: '', votes: 0, resolved: false, something: null },
isNew: true

@@ -876,3 +876,3 @@ },

actual: {a:23,b:'asdg',c:true,d: {x:32,y:'sagd',z: [{a:2,b:'gsda',c:false}]}, e: [2]},
result: { id: 0, title: '', body: '', votes: 0, resolved: false, something: undefined },
result: { id: 0, title: '', body: '', votes: 0, resolved: false, something: null },
isNew: true

@@ -924,3 +924,3 @@ },

actual: [{a:23,b:'asdg',c:true,d: {x:32,y:'sagd',z: [{a:2,b:'gsda',c:false}]}, e: [2]}],
result: [{ id: 0, title: '', body: '', votes: 0, resolved: false, something: undefined }],
result: [{ id: 0, title: '', body: '', votes: 0, resolved: false, something: null }],
isNew: true

@@ -927,0 +927,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc