Payment-Encoder
Payment-Encoder provides the encode/decode functions between a BeyondAsset payment Object to buffer
Installation
$ npm install beyondasset-payment-encoder
Encode
Params:
- paymentObject - A standard BeyondAsset payment object with the following properties:
// Skip input after reading asset skip: "Boolean" // Range or fixed value output range: "Boolean" // percent or fixed amount percent: "Boolean" // Output to send asset to - max value is 15 if range is false and 8191 if true output: "Number" // Total amount of units to send amountOfUnits: "Number"
Returns a new Buffer holding the encoded payment.
Example:
var paymentEncode = var paymentObject = skip: false range: false percent: true output: 1 amountOfUnits: 321321321 var code = paymentEncode console // Will print: <Buffer 21 80 99 37 cb 48>
Decode
Params:
- consume - takes a consumable buffer (You can use buffer-consumer like in the example to create one)
Returns a BeyondAsset payment Object
Example:
var paymentEncode = var consumer = var decode = paymentEncodevar codeBuffer = 0x820x760x0e0x1b0x48 console// Will print:// {// skip: false,// range: false,// percent: true,// output: 1,// amountOfUnits: 321321321// }
Testing
In order to test you need to install mocha globaly on your machine
$ cd /"module-path"/beyondasset-payment-Encoder$ mocha