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

uint32

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uint32 - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

21

package.json
{
"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 = {});
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