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 0.1.2 to 0.1.3

16

index.js

@@ -7,6 +7,16 @@ "use strong";

const ordinals = [
"First", "Second", "Third", "Fourth", "Fifth", "Sixth",
"Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth"
"first", "second", "third", "fourth", "fifth", "sixth",
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"
];
function ordinalize(idx, noun) {
return ordinals[idx] ?
`${ordinals[idx]} ${noun}` :
`${noun} #${idx + 1}`;
}
function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}
/**

@@ -27,3 +37,3 @@ * Use like T(var1, T.number, var2, T.optional(T.string));

const message = [].concat(errors).join('\n');
throw new TypeError(`${ordinals[i/2]} variable: ${message}`);
throw new TypeError(`${capitalize(ordinalize(i/2, "object"))}: ${message}`);
}

@@ -30,0 +40,0 @@ }

2

package.json
{
"name": "notmytype",
"version": "0.1.2",
"version": "0.1.3",
"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",

@@ -25,3 +25,3 @@ "use strong";

T(new Buffer("hi"), T.string);
}, /First variable: Expected.*string.*got/);
}, /First object: Expected.*string.*got/);
});

@@ -32,5 +32,25 @@

T(3, T.number, new Buffer("hi"), T.string);
}, /Second variable: Expected.*string.*got/);
}, /Second object: Expected.*string.*got/);
});
it('throws error if given wrong type in thirteenth position', function() {
assert.throws(function() {
T(
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
3, T.number,
new Buffer("hi"), T.string
);
}, /Object #13: Expected.*string.*got/);
});
it("doesn't throw if given correct types", function() {

@@ -37,0 +57,0 @@ assert.strictEqual(undefined, T(3, T.number));

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