From 7ee8a85eb0c6e33c1eaf1330d7136de3e0c53798 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 5 Jan 2015 12:54:03 +1100 Subject: [PATCH 1/5] README: improve browserify instructions --- README.md | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e941e4f..be9c453 100644 --- a/README.md +++ b/README.md @@ -51,16 +51,33 @@ From the repo: ### Browser -From the repository: Compile `bitcoinjs-min.js` with the following command: +If you're familiar with how to use browserify, ignore this and proceed normally. +These steps are advisory only and allow you to use the API to its full extent. - $ npm run-script compile +[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps. -From NPM: - $ npm -g install bitcoinjs-lib browserify uglify-js - $ browserify -r bitcoinjs-lib -s bitcoin | uglifyjs > bitcoinjs.min.js +From your repository, create a `bitcoin.js` file -After loading this file in your browser, you will be able to use the global `bitcoin` object. +``` javascript +var bitcoin = { + base58: require('bs58'), + ecurve: require('ecurve'), + BigInteger: require('bigi'), + Buffer: require('buffer') +} + +var bitcoinjs = require('bitcoinjs-lib') +for (var a in bitcoinjs) bitcoin[a] = bitcoinjs[a] + +module.exports = bitcoin +``` + +Then, using browserify, compile `bitcoin.js` for use in the browser: + + $ browserify bitcoin.js -s bitcoin > dist/bitcoin.js + +You will then be able to load `dist/bitcoin.js` into your browser, with each of the dependencies above accessible from the global `bitcoin` object. ## Examples From 2047567703e04d49611fef864834b653e11e3797 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 5 Jan 2015 13:00:19 +1100 Subject: [PATCH 2/5] README: add note about browserify version --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be9c453..3c53f50 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ These steps are advisory only and allow you to use the API to its full extent. [Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps. - From your repository, create a `bitcoin.js` file ``` javascript @@ -79,6 +78,8 @@ Then, using browserify, compile `bitcoin.js` for use in the browser: You will then be able to load `dist/bitcoin.js` into your browser, with each of the dependencies above accessible from the global `bitcoin` object. +**NOTE**: See the package.json for the currently supported version of browserify used by this repository. + ## Examples From c11f50542ee86e2f5805fbf72f0ee3ba6e3a237b Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 5 Jan 2015 13:02:58 +1100 Subject: [PATCH 3/5] README: don't use a bitcoin namespace for other deps --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3c53f50..7eb776b 100644 --- a/README.md +++ b/README.md @@ -56,29 +56,27 @@ These steps are advisory only and allow you to use the API to its full extent. [Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps. -From your repository, create a `bitcoin.js` file +From your repository, create a `foobar.js` file ``` javascript -var bitcoin = { +var foobar = { base58: require('bs58'), + bitcoin: require('bitcoinjs-lib'), ecurve: require('ecurve'), BigInteger: require('bigi'), Buffer: require('buffer') } -var bitcoinjs = require('bitcoinjs-lib') -for (var a in bitcoinjs) bitcoin[a] = bitcoinjs[a] - -module.exports = bitcoin +module.exports = foobar ``` -Then, using browserify, compile `bitcoin.js` for use in the browser: +Then, using browserify, compile `foobar.js` for use in the browser: - $ browserify bitcoin.js -s bitcoin > dist/bitcoin.js + $ browserify foobar.js -s foobar > dist/foobar.js -You will then be able to load `dist/bitcoin.js` into your browser, with each of the dependencies above accessible from the global `bitcoin` object. +You will then be able to load `dist/foobar.js` into your browser, with each of the dependencies above accessible from the global `foobar` object. -**NOTE**: See the package.json for the currently supported version of browserify used by this repository. +**NOTE**: See our package.json for the currently supported version of browserify used by this repository. ## Examples From 75ca385e42e4f0fa5eabf060d239ecf5512a7ffd Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sun, 8 Feb 2015 11:59:59 +1100 Subject: [PATCH 4/5] README: no need to provide 'from the repo' require Alternatively, they could also just do the standard `require('./')` if they really wanted to do this. --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 7eb776b..21ae379 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,6 @@ If you are looking for the original, it is tagged as `0.1.3`. Unless you need it var bitcoin = require('bitcoinjs-lib') -From the repo: - - var bitcoin = require('./src/index.js') - ### Browser From 642315eabccacd34a71fa21ecf5ec48d59ec7693 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sun, 8 Feb 2015 16:11:28 +1100 Subject: [PATCH 5/5] README: remove dist/ and clarify installation of other packages --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21ae379..c957a58 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,14 @@ var foobar = { module.exports = foobar ``` -Then, using browserify, compile `foobar.js` for use in the browser: +Each of these included packages are seperate to `bitcoinjs-lib`, and must be installed separately. +They are however used in the bitcoinjs-lib public API. - $ browserify foobar.js -s foobar > dist/foobar.js +Using browserify, compile `foobar.js` for use in the browser: -You will then be able to load `dist/foobar.js` into your browser, with each of the dependencies above accessible from the global `foobar` object. + $ browserify foobar.js -s foobar > foobar.js + +You will then be able to load `foobar.js` into your browser, with each of the dependencies above accessible from the global `foobar` object. **NOTE**: See our package.json for the currently supported version of browserify used by this repository.