ripple-binary-codec
Advanced tools
Comparing version 0.0.3 to 0.0.4
'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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
873402
11
56
12781
0
0
4
9
3
2
+ Addedbabel-runtime@^5.8.25
+ Addedbn.js@^3.2.0
+ Addedcodecov.io@^0.1.6
+ Addedcreate-hash@^1.1.2
+ Addeddecimal.js@^4.0.2
+ Addedhash.js@^1.0.3
+ Addedinherits@^2.0.1
+ Addedlodash@^3.10.1
+ Addedripple-address-codec@^2.0.1
- Removed@niq/ripple-core@0.0.6
- Removed@niq/ripple-core@0.0.6(transitive)