New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

notmytype

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notmytype - npm Package Compare versions

Comparing version 1.2.3 to 2.0.0

18

assert.js

@@ -17,2 +17,4 @@ /**

const inspect = require('util').inspect;
function getFunctionName (f/*: any*/)/*: string*/ {

@@ -31,17 +33,5 @@ return f.displayName || f.name || `<function${f.length}>`;

let ctx = this.ctx ? this.ctx.join(' / ') : '';
ctx = ctx ? `, context: ${ctx}` : ', (no context)';
return `Expected an instance of ${this.expected.name}; got ${String(Failure.stringify(this.actual)) + ctx}`;
ctx = ctx ? `context: ${ctx}` : '(no context)';
return `Expected an instance of ${this.expected.name}; got ${inspect(this.actual)}, ${ctx}`;
}
static stringify(x/*: any*/)/*: string*/ {
try { // handle circular references
return JSON.stringify(x, function(k, v) {
if(typeof v === 'function') { return `[${getFunctionName(v)}, Function]`; } // handle functions
if(v instanceof RegExp) { return `[${String(v)}, RegExp]`; } // handle regexps
return v;
}, 2);
} catch (e) {
return String(x);
}
}
}

@@ -48,0 +38,0 @@

{
"name": "notmytype",
"version": "1.2.3",
"version": "2.0.0",
"description": "Type-check your function inputs with syntax like T(s, T.string, buf, Buffer, strings, T.list(T.string))",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/ludios/notmytype",

@@ -14,53 +14,2 @@ /**

describe('Failure.stringify', function() {
it('should stringify numbers', function() {
assert.strictEqual(
f.Failure.stringify(1),
'1'
);
});
it('should stringify strings', function() {
assert.strictEqual(
f.Failure.stringify('a'),
'"a"'
);
});
it('should stringify booleans', function() {
assert.strictEqual(
f.Failure.stringify(true),
'true'
);
});
it('should stringify objects', function() {
assert.strictEqual(
f.Failure.stringify({a: 1}),
'{\n "a": 1\n}'
);
});
it('should stringify arrays', function() {
assert.strictEqual(
f.Failure.stringify([1, 2, 3]),
'[\n 1,\n 2,\n 3\n]'
);
});
it('should stringify functions', function() {
assert.strictEqual(
f.Failure.stringify(Date),
'"[Date, Function]"'
);
});
it('should stringify regexps', function() {
assert.strictEqual(
f.Failure.stringify(/^a/),
'"[/^a/, RegExp]"'
);
});
});
describe('symbol', function() {

@@ -93,3 +42,3 @@ it('is() should return false if x is not a symbol', function() {

String(f.number.validate('a')),
'Expected an instance of number; got "a", (no context)'
"Expected an instance of number; got 'a', (no context)"
);

@@ -145,3 +94,3 @@ });

String(f.list(f.number).validate([1, 's'])),
'Expected an instance of number; got "s", context: Array<number> / 1'
"Expected an instance of number; got 's', context: Array<number> / 1"
);

@@ -169,3 +118,3 @@ });

String(f.optional(f.number).validate('s')),
'Expected an instance of number; got "s", context: number?'
"Expected an instance of number; got 's', context: number?"
);

@@ -200,3 +149,3 @@ });

String(f.maybe(f.number).validate('s')),
'Expected an instance of number; got "s", context: ?number'
"Expected an instance of number; got 's', context: ?number"
);

@@ -259,3 +208,3 @@ });

String(f.tuple([f.string, f.number]).validate(['s'])),
'Expected an instance of [string, number]; got [\n "s"\n], (no context)'
"Expected an instance of [string, number]; got [ 's' ], (no context)"
);

@@ -314,3 +263,3 @@ });

String(f.dict(f.string, f.number).validate({a: 's'})),
'Expected an instance of number; got "s", context: {[key: string]: number} / a'
"Expected an instance of number; got 's', context: {[key: string]: number} / a"
);

@@ -317,0 +266,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