From b509732aa30770c7ff3c9177c3ee0e3653a540d6 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 30 Jan 2014 15:17:06 -0500 Subject: [PATCH] bignum in browser --- Gruntfile.js | 29 ++++++++++++++++++++++++----- Transaction.js | 1 + browser/sample.html | 12 ++++++++++++ main.js | 10 ++++++++++ package.json | 24 +++++++++++++++++------- 5 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 browser/sample.html create mode 100644 main.js diff --git a/Gruntfile.js b/Gruntfile.js index 861b57d9a..f458d0366 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,17 +4,36 @@ module.exports = function(grunt) { //Load NPM tasks grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-mocha-test'); // Project Configuration grunt.initConfig({ browserify: { - basic: { - src: ['main2.js'], - dest: 'browser/bundle.js' + client: { + src: ['main.js'], + dest: 'browser/bundle.js', + options: { + alias: ['browserify-bignum/bignumber.js:bignum'] + } } - } + }, + watch: { + scripts: { + files: ['**/*.js', '**/*.html', '!**/node_modules/**', '!**/bundle.js'], + tasks: ['browserify'/*, 'mochaTest'*/], + }, + }, + mochaTest: { + options: { + reporter: 'spec', + }, + src: ['test/*.js'], + }, + }); - grunt.registerTask('default', ['browserify']); + grunt.registerTask('default', ['watch']); }; + diff --git a/Transaction.js b/Transaction.js index 36bbbeb57..6695c97be 100644 --- a/Transaction.js +++ b/Transaction.js @@ -1,3 +1,4 @@ +'use strict'; require('classtool'); function spec(b) { diff --git a/browser/sample.html b/browser/sample.html new file mode 100644 index 000000000..b02b85da2 --- /dev/null +++ b/browser/sample.html @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/main.js b/main.js new file mode 100644 index 000000000..2c21a48cb --- /dev/null +++ b/main.js @@ -0,0 +1,10 @@ +//var Enc = require('./util/EncodedData').class(); +//require('base58-native'); + +var bignum = require('bignum'); + +var b = bignum('782910138827292261791972728324982') + .sub('182373273283402171237474774728373') + .div(8); +console.log(b); + diff --git a/package.json b/package.json index 4a24d0256..ddb9f1947 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,15 @@ "email": "stephen@bitpay.com" }, "contributors": [ - {"name": "Stefan Thomas", "email": "moon@justmoon.net"}, - {"name": "Jeff Garzik", "email": "jgarzik@bitpay.com"} - ], + { + "name": "Stefan Thomas", + "email": "moon@justmoon.net" + }, + { + "name": "Jeff Garzik", + "email": "jgarzik@bitpay.com" + } + ], "keywords": [ "bitcoin", "btc", @@ -25,16 +31,20 @@ "scripts": {}, "dependencies": { "classtool": "=1.0.0", - "base58-native": "=0.1.1", - "bindings": "=1.1.0", + "base58-native": "=0.1.3", + "bindings": "=1.1.1", "bufferput": "=0.1.1", "bignum": "=0.6.1", "binary": "=0.3.0", "step": "=0.0.4", "buffers": "=0.1.1", "buffertools": "=1.1.1", - "mocha": ">=1.15.1" + "mocha": ">=1.15.1", + "browserify-bignum": "1.3.0-2" + }, + "devDependencies": { + "grunt-contrib-watch": "~0.5.3", + "grunt-mocha-test": "~0.8.2" }, - "devDependencies": {}, "license": "MIT" }