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 2.0.4 to 2.0.5

16

lib/helpers/types.js

@@ -21,2 +21,18 @@ /**

// *
'*': {
is: function(v) {
return !_.isUndefined(v);
},
to: function(v) {
if(_.isUndefined(v)) {
throw new Error('E_runtimeInputTypeCoercionError');
}
return v;
},
getBase: function (){
return undefined;
}
},
// Boolean

@@ -23,0 +39,0 @@ boolean: {

87

lib/helpers/validate-recursive.js

@@ -42,7 +42,11 @@ /**

// "*" (allow anything)
if (expected === '*'){
return actual;
}
// // "*" (allow anything)
// if (expected === '*'){
// // Except if this is `undefined`, it's a E_INVALID_TYPE error
// // (i.e. won't matter if coercing, but will cause failure when validating)
// if (_.isUndefined(actual)){}
// return actual;
// }
// Normalize: [] or ['*'] or "array" (allow any array)

@@ -85,77 +89,2 @@ if (expected === 'array' || (_.isArray(expected) && (expected.length === 0 || expected[0] === '*'))) {

// console.log('expected = %s || actual = %s (%s)',expected, actual, typeof actual);
// // For most actual values, we want to ensure it is pseudo-JSON-serializable.
// // We say "pseudo" because we would rather not allow `null` for now,
// // which is technically allowed in JSON. TODO: expand this comment to reflect reality
// //
// //
// // So specifically, we'll ensure that `actual` is pseudo-JSON-serializable,
// // unless one of the following is true:
// // - the `ensureSerializable` flag is disabled
// // - we're expecting a "machine", "buffer", or "stream" and the mystery meat looks right enough
// //
// // Notes:
// // + this can be disabled by setting the `ensureSerializable` argument to false (i.e. for performance)
// // + this will strip all functions
// // + cloning buffers breaks them-- also it is potentially a huge waste of RAM)
// // + cloning streams is a bad idea because it disregards the state they're in, event listeners, etc.)
// if (ensureSerializable &&
// expected !== 'machine' &&
// expected !== 'buffer' &&
// expected !== 'stream'
// ) {
// // console.log('ensuring actual value is serializable as JSON...');
// // Formerly we did this: (but not anymore)
// // ================================================================
// // If we're not expecting a buffer, but it looks like we got one actually,
// // don't serialize it to JSON and back.
// // (it will end up looking like an array, which is confusing)
// // !(expected !== 'buffer' && _.isObject(actual) && actual instanceof Buffer)
// // ================================================================
// try {
// actual = JSON.parse(JSON.stringify(actual));
// }
// catch (e){
// // Build an E_INVALID_TYPE error
// var newErr = (function (){
// var msg = util.format(
// 'An invalid value was specified: \n' + util.inspect(actual, false, null) + '\n\n' +
// 'This doesn\'t match the specified type: \n' + util.inspect(expected, false, null)
// );
// if (meta && meta.keyName) {
// msg = "For key `"+meta.keyName+"`: " + msg;
// }
// var err = new Error(msg);
// if (meta && meta.keyName) {
// err.inputKey = meta.keyName;
// }
// err.actual = util.inspect(actual, false, null);
// err.expected = util.inspect(expected, false, null);
// err.code = 'E_INVALID_TYPE';
// // if not expecting a dictionary or an array, and actual value is not
// // a dictionary or array, then this is just a "minor" thing.
// // No big deal, you know.
// if (!isExpectingDictionary && !isExpectingArray && !_.isObject(actual)) {
// err.minor = true;
// }
// return err;
// })();
// // Don't bother tracking minor errors unless we're in `strict` mode.
// if (!newErr.minor || (strict && newErr.minor)) {
// errors.push(newErr);
// }
// actual = {};
// }
// }
// // TODO: probably should clone machine defs as well.
// // console.log('(4) actual =',actual);
// Default the coercedValue to the actual value.

@@ -162,0 +91,0 @@ var coercedValue = actual;

{
"name": "rttc",
"version": "2.0.4",
"version": "2.0.5",
"description": "Runtime type-checking for JavaScript.",

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

@@ -1,7 +0,4 @@

var expandSuite = require('./helpers/expand-suite');
// Export the array of tests below.
module.exports = [
// Take the array of tests below, extend them with some derivative
// tests automatically, and export the result.
module.exports = expandSuite([
////////////////////////////////////////////

@@ -468,2 +465,2 @@ // STRINGS

]);
];

@@ -1,8 +0,5 @@

var expandSuite = require('./helpers/expand-suite');
// Export the array of tests below
module.exports = [
// Take the array of tests below, extend them with some derivative
// tests automatically, and export the result.
module.exports = expandSuite([
////////////////////////////////////////////

@@ -283,3 +280,3 @@ // STRINGS

{ example: '*', actual: undefined, result: undefined, },
{ example: '*', actual: undefined, error: true },

@@ -310,4 +307,4 @@ { example: '*', actual: NaN, result: NaN, },

]);
];
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