Skip to content

Commit 80b7f29

Browse files
authored
Export the underlying XdrReader and XdrWriter object (#116)
* Add raw Reader/Writer export, better Array check * Upgrade dependencies
1 parent d605e5c commit 80b7f29

File tree

5 files changed

+415
-399
lines changed

5 files changed

+415
-399
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ project adheres to [Semantic Versioning](http://semver.org/).
66

77
## Unreleased
88

9+
## [v3.1.0](https://github.com/stellar/js-xdr/compare/v3.0.1...v3.1.0)
10+
11+
### Added
12+
* The raw, underlying `XdrReader` and `XdrWriter` types are now exposed by the library for reading without consuming the entire stream ([#116](https://github.com/stellar/js-xdr/pull/116)).
13+
14+
### Fixed
15+
* Added additional type checks for passing a bytearray-like object to `XdrReader`s and improves the error with details ([#116](https://github.com/stellar/js-xdr/pull/116)).
16+
917

1018
## [v3.0.1](https://github.com/stellar/js-xdr/compare/v3.0.0...v3.0.1)
1119

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stellar/js-xdr",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"description": "Read/write XDR encoded data structures (RFC 4506)",
55
"main": "lib/xdr.js",
66
"browser": "dist/xdr.js",
@@ -48,17 +48,17 @@
4848
"ui": "bdd"
4949
},
5050
"devDependencies": {
51-
"@babel/core": "^7.23.3",
52-
"@babel/eslint-parser": "^7.23.3",
53-
"@babel/preset-env": "^7.23.3",
54-
"@babel/register": "^7.22.15",
51+
"@babel/core": "^7.23.9",
52+
"@babel/eslint-parser": "^7.23.9",
53+
"@babel/preset-env": "^7.23.9",
54+
"@babel/register": "^7.23.7",
5555
"babel-loader": "^9.1.3",
5656
"buffer": "^6.0.3",
5757
"chai": "^4.3.10",
58-
"eslint": "^8.53.0",
58+
"eslint": "^8.56.0",
5959
"eslint-config-airbnb-base": "^15.0.0",
6060
"eslint-config-prettier": "^8.8.0",
61-
"eslint-plugin-import": "^2.29.0",
61+
"eslint-plugin-import": "^2.29.1",
6262
"eslint-plugin-node": "^11.1.0",
6363
"eslint-plugin-prefer-import": "^0.0.1",
6464
"eslint-plugin-prettier": "^4.2.1",
@@ -74,8 +74,8 @@
7474
"prettier": "^2.8.7",
7575
"sinon": "^15.2.0",
7676
"sinon-chai": "^3.7.0",
77-
"terser-webpack-plugin": "^5.3.7",
78-
"webpack": "^5.89.0",
77+
"terser-webpack-plugin": "^5.3.10",
78+
"webpack": "^5.90.0",
7979
"webpack-cli": "^5.0.2"
8080
}
8181
}

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export * from './types';
22
export * from './config';
3+
4+
export { XdrReader } from './serialization/xdr-reader';
5+
export { XdrWriter } from './serialization/xdr-writer';

src/serialization/xdr-reader.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ export class XdrReader {
1010
*/
1111
constructor(source) {
1212
if (!Buffer.isBuffer(source)) {
13-
if (source instanceof Array) {
13+
if (
14+
source instanceof Array ||
15+
Array.isArray(source) ||
16+
ArrayBuffer.isView(source)
17+
) {
1418
source = Buffer.from(source);
1519
} else {
16-
throw new XdrReaderError('source not specified');
20+
throw new XdrReaderError(`source invalid: ${source}`);
1721
}
1822
}
1923

0 commit comments

Comments
 (0)