Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ripple-binary-codec

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ripple-binary-codec - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

distrib/npm/binary.js

34

distrib/npm/index.js
'use strict';
var assert = require('assert');
var coreTypes = require('@niq/ripple-core');
var coreTypes = require('./coretypes');
var quality = coreTypes.quality;

@@ -13,30 +13,40 @@ var _coreTypes$binary = coreTypes.binary;

exports.decode = function (binary) {
function decode(binary) {
assert(typeof binary === 'string', 'binary must be a hex string');
return binaryToJSON(binary);
};
}
exports.encode = function (json) {
function encode(json) {
assert(typeof json === 'object');
return bytesToHex(serializeObject(json));
};
}
exports.encodeForSigning = function (json) {
function encodeForSigning(json) {
assert(typeof json === 'object');
return bytesToHex(signingData(json));
};
}
exports.encodeForMultisigning = function (json, signer) {
function encodeForMultisigning(json, signer) {
assert(typeof json === 'object');
assert.equal(json.SigningPubKey, '');
return bytesToHex(multiSigningData(json, signer));
};
}
exports.encodeQuality = function (value) {
function encodeQuality(value) {
assert(typeof value === 'string');
return bytesToHex(quality.encode(value));
};
}
exports.decodeQuality = function (value) {
function decodeQuality(value) {
assert(typeof value === 'string');
return quality.decode(value).toString();
}
module.exports = {
decode: decode,
encode: encode,
encodeForSigning: encodeForSigning,
encodeForMultisigning: encodeForMultisigning,
encodeQuality: encodeQuality,
decodeQuality: decodeQuality
};
{
"name": "ripple-binary-codec",
"version": "0.0.3",
"version": "0.0.4",
"description": "ripple binary codec",

@@ -8,5 +8,3 @@ "files": [

"bin/*",
"build/*",
"test/*",
"Gulpfile.js"
"test/*"
],

@@ -18,3 +16,11 @@ "main": "distrib/npm/",

"dependencies": {
"@niq/ripple-core": "0.0.6"
"babel-runtime": "^5.8.25",
"bn.js": "^3.2.0",
"codecov.io": "^0.1.6",
"create-hash": "^1.1.2",
"decimal.js": "^4.0.2",
"hash.js": "^1.0.3",
"inherits": "^2.0.1",
"lodash": "^3.10.1",
"ripple-address-codec": "^2.0.1"
},

@@ -27,22 +33,15 @@ "devDependencies": {

"babel-loader": "^5.3.2",
"coveralls": "~2.10.0",
"eslint": "^1.2.1",
"eventemitter2": "^0.4.14",
"fs-extra": "^0.24.0",
"intercept-stdout": "^0.1.2",
"istanbul": "~0.3.5",
"lodash": "^3.10.0",
"map-stream": "~0.1.0",
"mocha": "~2.1.0",
"nock": "^0.34.1",
"ripple-lib": "^0.12.4",
"webpack": "~1.5.3",
"yargs": "~1.3.1"
"ripple-lib": "^0.12.9"
},
"scripts": {
"build": "gulp",
"compile": "babel --optional runtime -d distrib/npm/ src/",
"compile-with-source-maps": "babel --optional runtime -s -t -d distrib/npm/ src/",
"compile": "babel --optional runtime -d distrib/npm/ src/ && cp src/enums/definitions.json distrib/npm/enums",
"prepublish": "npm test && npm run lint && npm run compile",
"test": "istanbul test _mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/*.js test/*.js"
"codecov": "cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js",
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/*.js test/*.js examples/*.js"
},

@@ -60,4 +59,5 @@ "repository": {

"homepage": "https://github.com/ripple/ripple-binary-codec#readme",
"author": "ndudfield@gmail.com",
"license": "ISC",
"readmeFilename": "README.md"
}
'use strict';
const assert = require('assert-diff');
const {encodeQuality, decodeQuality} = require('../src');
const {quality, binary: {bytesToHex}} = require('../src/coretypes');

@@ -11,9 +11,9 @@ describe('Quality encode/decode', function() {

it('can decode', function() {
const decimal = decodeQuality(bookDirectory);
assert.equal(decimal, expectedQuality);
const decimal = quality.decode(bookDirectory);
assert.equal(decimal.toString(), expectedQuality);
});
it('can encode', function() {
const hex = encodeQuality(expectedQuality);
assert.equal(hex, bookDirectory.slice(-16));
const bytes = quality.encode(expectedQuality);
assert.equal(bytesToHex(bytes), bookDirectory.slice(-16));
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc