diff --git a/README.md b/README.md index 9c3bed0..4cb267d 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,6 @@ JavaScript Bitmessage library for both browserify and node. ## Usage -You need ES6 Promise available in order to use this module. Use some sort of ES6 runtime or just apply polyfill: - -```js -require("es6-promise").polyfill(); -``` - ```js var bitmessage = require("bitmessage"); ``` diff --git a/lib/crypto.js b/lib/crypto.js index 9ced6f0..debc832 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -7,6 +7,7 @@ "use strict"; +var Promise = require("es6-promise").Promise; // jshint ignore:line var crypto = require("crypto"); exports.sha512 = function(buf) { diff --git a/package.json b/package.json index 0a1331a..0a88059 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,10 @@ "homepage": "https://github.com/nekogrid/bitmessage", "devDependencies": { "chai": "*", - "es6-promise": "^2.0.1", "jshint": "*", "mocha": "*" + }, + "dependencies": { + "es6-promise": "^2.0.1" } } diff --git a/test.js b/test.js index 25e63e7..34d9898 100644 --- a/test.js +++ b/test.js @@ -1,11 +1,10 @@ var expect = require("chai").expect; -require("es6-promise").polyfill(); -var crypto = require("./lib/crypto"); +var bmcrypto = require("./lib/crypto"); -describe("crypto", function() { +describe("Bitmessage crypto", function() { it("should calculate sha512 hash for both node and browserify", function(done) { - crypto.sha512(new Buffer("test")).then(function(res) { + bmcrypto.sha512(new Buffer("test")).then(function(res) { expect(res.toString("hex")).to.equal("ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"); done(); });