Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sqr

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqr - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.travis.yml

14

index.js

@@ -7,3 +7,10 @@ /**

function check(x) {
if (typeof x !== 'number') {
throw 'not a number!';
}
}
function sqr(x) {
check(x);
return x * x;

@@ -13,2 +20,3 @@ }

sqr.isSquare = function(y) {
check(y);
var x = Math.sqrt(y);

@@ -19,6 +27,6 @@ return x === (x|0);

sqr.nearest = function(y) {
check(y);
var x = Math.sqrt(y)|0,
x0 = x|0,
y1 = x0 * x0,
y2 = (1 + x0)*(1 + x0);
y1 = x * x,
y2 = (1 + x) * (1 + x);
return y - y1 > y2 - y ? y2 : y1;

@@ -25,0 +33,0 @@ };

{
"name": "sqr",
"version": "1.0.0",
"version": "1.0.1",
"description": "Calculates the square of numbers, and checks if they're square numbers",

@@ -18,3 +18,12 @@ "main": "index.js",

"tape": "^4.2.2"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/claudiopro/sqr.git"
},
"bugs": {
"url": "https://github.com/claudiopro/sqr/issues"
},
"homepage": "https://github.com/claudiopro/sqr#readme",
"tonicExampleFilename": "tonicExample.js"
}

@@ -12,3 +12,3 @@ /**

test('squares of integers', function (t) {
test('sqr calculates squares of integers', function (t) {
t.is(0, sqr(0));

@@ -21,3 +21,3 @@ t.is(4, sqr(2));

test('check squares of integers', function (t) {
test('isSquare detects squares of integers', function (t) {
t.true(isSquare(49));

@@ -42,3 +42,3 @@ t.true(isSquare(36));

test('nearest squares of integers', function (t) {
test('nearest finds nearest squares of integers', function (t) {
t.is(49, nearest(52));

@@ -68,1 +68,31 @@ t.is(36, nearest(39));

});
test('sqr throws if passed non numeric arguments', function (t) {
t.throws(sqr.bind(null, 'a'));
t.throws(sqr.bind(null, null));
t.throws(sqr.bind(null, undefined));
t.throws(sqr.bind(null, []));
t.throws(sqr.bind(null, {}));
t.end();
});
test('isSquare throws if passed non numeric arguments', function (t) {
t.throws(isSquare.bind(null, 'a'));
t.throws(isSquare.bind(null, null));
t.throws(isSquare.bind(null, undefined));
t.throws(isSquare.bind(null, []));
t.throws(isSquare.bind(null, {}));
t.end();
});
test('nearest throws if passed non numeric arguments', function (t) {
t.throws(nearest.bind(null, 'a'));
t.throws(nearest.bind(null, null));
t.throws(nearest.bind(null, undefined));
t.throws(nearest.bind(null, []));
t.throws(nearest.bind(null, {}));
t.end();
});

Sorry, the diff of this file is not supported yet

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