From 600dc6e4bbd976832dc00f54f6ceb624f54ad607 Mon Sep 17 00:00:00 2001 From: Kagami Hiiragi Date: Sat, 13 Dec 2014 22:07:08 +0300 Subject: [PATCH] Add es6-promise dependency Since it needed only for node version. --- README.md | 6 ------ lib/crypto.js | 1 + package.json | 4 +++- test.js | 7 +++---- 4 files changed, 7 insertions(+), 11 deletions(-) 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(); });