Created
October 21, 2016 06:04
-
-
Save aakilfernandes/b8068b7e2d1ae14af2520f79968e550e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dittoFarm = new DittoFarm | |
dittoFarm(require(‘ditto-bigNumber)) | |
dittoFarm(require(‘ditto-ipfs)) | |
ditto.to.bignumber(‘add’, 3).to(‘hex’) | |
function dittoBigNumber(dittoFarm){ | |
this.registerMaker(‘prefixedhex’, ‘bignumber’, (prefixedhex) => { return new BigNumber(prefixedhex) }) | |
this.registerMaker(‘bignumber’, ‘prefixedhex’, (bignumber) => { return bignumber.toString(‘hex’) }) | |
} | |
function dittoPrefixedHex(dittoFarm){ | |
this.registerMaker(‘prefixedhex’, ‘hex’, (prefixedHex) => { return ditto.replace(‘0x’, ‘’) }) | |
this.registerMaker(‘hex’, ‘prefixedhex’, (hex) => { return ‘0x’+hex }) | |
} | |
function dittoHex(dittoFarm){ | |
this.registerMaker(‘hex’, ‘uint8Array’, (prefixedHex) => { return ditto.replace(‘0x’, ‘’) }) | |
this.registerMaker(‘uint8Array’, ‘hex’, (hex) => { return ‘0x’+hex }) | |
} | |
const file = new Ditto(‘hello world’, ‘ascii’) | |
file.to.prefixedHex() | |
const minimumOrder = new Ditto(’3dfa23e4000000000000000’, ‘hex’) | |
reallylargenumber.as.bignumber.mutate.divide(3).to.hex() //3dfa23e7000000000000000 | |
vendorMinimum.as.currency(‘usd’).do.convertTo(’eur’).to.prefixedHex() | |
greeting.as.unixfsMultihash().to.base64() | |
Ditto.register(bigNumberConvert’bignumber’,’hex’, [‘prefixedhex’], (bignumber) => { | |
return bignumber.toString(Ditto.covert(‘hex’, ‘prefixedhex’, hex)) | |
}, (hex) => { | |
canst | |
return new BigNumber( | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment