Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "uint32", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "a javascript library for dealing with (bitwise) uint32 operations", | ||
"homepage": "https://www.github.com/fxa/uint32.js", | ||
"main": "./uint32", | ||
"scripts": { | ||
@@ -9,3 +11,6 @@ "test": "jshint uint32.js test_uint32.js && mocha test_uint32", | ||
}, | ||
"repository": "https://github.com/fxa/uint32.js.git", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fxa/uin32.js.git" | ||
}, | ||
"keywords": [ | ||
@@ -16,5 +21,5 @@ "uint32", "bitwise", "binary", "shift", "rotate" | ||
"name": "Franz X Antesberger", | ||
"email": "github@franz-antesberger.de" | ||
"email": "info@franz-antesberger.de" | ||
}, | ||
"license": "MIT", | ||
"license": "Do, what You want", | ||
"dependencies": {}, | ||
@@ -25,3 +30,9 @@ "devDependencies": { | ||
"jshint": "latest" | ||
} | ||
}, | ||
"files": [ | ||
"README.md", | ||
"tests.html", | ||
"test_uint32.js", | ||
"uint32.js" | ||
] | ||
} |
@@ -16,8 +16,8 @@ uint32 | ||
var x = 0xFFFFFFFF; | ||
~~x === x; // false | ||
(x | 0) === x; // false | ||
(x & x) === x; // false | ||
(x ^ 0) === x; // false | ||
(x >> 0) === x; // false | ||
(x << 0) === x; // false | ||
~~x === x; // false! ~~x -> -1 | ||
(x | 0) === x; // false! x | 0 -> -1 | ||
(x & x) === x; // false! x & x -> -1 | ||
(x ^ 0) === x; // false! x ^ 0 -> -1 | ||
(x >> 0) === x; // false! x >> 0 -> -1 | ||
(x << 0) === x; // false! x << 0 -> -1 | ||
``` | ||
@@ -89,2 +89,5 @@ | ||
// function majority (x, y, z) | ||
// Arithmetic | ||
uint32.addMod32(0x80000001, 0x80000001); // 2 | ||
@@ -91,0 +94,0 @@ // That's all! Detailed specifications are in the tests! |
@@ -186,3 +186,22 @@ /* global describe, it, require, window */ | ||
}); | ||
describe('Arithmetic', function () { | ||
describe('addMod32', function () { | ||
it('should add values below 2^32', function () { | ||
expect(uint32.addMod32(0x40000000, 0x40000000)).to.be(0x80000000); | ||
}); | ||
it('should add an arbitrary number of arguments', function () { | ||
expect(uint32.addMod32(1, 2, 3)).to.be(6); | ||
expect(uint32.addMod32(1, 2, 3, 4)).to.be(10); | ||
expect(uint32.addMod32(1, 2, 3, 4, 5)).to.be(15); | ||
expect(uint32.addMod32(1, 2, 3, 4, 5, 6)).to.be(21); | ||
}); | ||
it('should add negative values', function () { | ||
expect(uint32.addMod32(-1, -1)).to.be(0xfffffffe); | ||
}); | ||
it('should calc mod32', function () { | ||
expect(uint32.addMod32(0x80000001, 0x80000001)).to.be(2); | ||
}); | ||
}); | ||
}); | ||
})(); |
@@ -171,3 +171,20 @@ /* jshint bitwise: false */ | ||
// | ||
// Arithmetic | ||
// | ||
/** | ||
* Adds the given values modulus 2^32. | ||
* @returns the sum of the given values modulus 2^32 | ||
*/ | ||
exporter.addMod32 = function (uint32val0/*, optionalValues*/) { | ||
var result = uint32val0; | ||
for (var index = 1; index < arguments.length; index += 1) { | ||
result += arguments[index]; | ||
} | ||
return result >>> 0; | ||
}; | ||
}) ((typeof module !== 'undefined') ? module.exports = {} : window.uint32 = {}); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
20299
351
1
102
0
1