From 8a49bec48b96fd9b1318b7f888da3479e0fe6dec Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Thu, 1 Oct 2015 06:55:23 +0700 Subject: [PATCH] Use encode/decode --- packages/ripple-binary-codec/src/index.js | 4 ++-- packages/ripple-binary-codec/test/binary-json-test.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ripple-binary-codec/src/index.js b/packages/ripple-binary-codec/src/index.js index cdc97d72..aef9ddf6 100644 --- a/packages/ripple-binary-codec/src/index.js +++ b/packages/ripple-binary-codec/src/index.js @@ -4,12 +4,12 @@ const assert = require('assert'); const coreTypes = require('@niq/ripple-core-types'); const {binary: {bytesToHex, binaryToJSON, serializeObject}} = coreTypes; -exports.binaryToJSON = function(binary) { +exports.decode = function(binary) { assert(typeof binary === 'string'); return binaryToJSON(binary); }; -exports.jsonToBinary = function (json) { +exports.encode = function(json) { assert(typeof json === 'object'); return bytesToHex(serializeObject(json)); }; diff --git a/packages/ripple-binary-codec/test/binary-json-test.js b/packages/ripple-binary-codec/test/binary-json-test.js index edf14cba..848982a4 100644 --- a/packages/ripple-binary-codec/test/binary-json-test.js +++ b/packages/ripple-binary-codec/test/binary-json-test.js @@ -2,7 +2,7 @@ const assert = require('assert'); const fixtures = require('./fixtures/codec-fixtures.json'); -const {binaryToJSON, jsonToBinary} = require('../src'); +const {decode, encode} = require('../src'); function json(object) { return JSON.stringify(object); @@ -14,11 +14,11 @@ describe('ripple-binary-codec', function() { entries.forEach((t, test_n) => { it(`${name}[${test_n}] can encode ${json(t.json)} to ${t.binary}`, () => { - assert.equal(t.binary, jsonToBinary(t.json)); + assert.equal(t.binary, encode(t.json)); }); it(`${name}[${test_n}] can decode ${t.binary} to ${json(t.json)}`, () => { - const decoded = binaryToJSON(t.binary); + const decoded = decode(t.binary); assert.deepEqual(t.json, decoded); }); });