Skip to content

Commit 43eb808

Browse files
Fix bug
1 parent 6e9a721 commit 43eb808

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# json-bufferify
1+
# json-bufferify [![Travis](https://img.shields.io/travis/LangZhai/json-bufferify.svg)](https://travis-ci.org/LangZhai/json-bufferify/builds) [![npm (tag)](https://img.shields.io/npm/v/json-bufferify.svg)](https://www.npmjs.com/package/json-bufferify) [![npm](https://img.shields.io/npm/l/json-bufferify.svg)](http://www.gnu.org/licenses/lgpl.html) ![Github file size](https://img.shields.io/github/size/langzhai/json-bufferify/json-bufferify.js.svg)
22

33
This is a module to help you convert between JSON and ArrayBuffer, and you can run it in both Node.js and browser.
44

json-bufferify.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* json-bufferify 0.0.3
2+
* json-bufferify 0.0.4
33
* Date: 2017-07-06
44
* © 2017 LangZhai(智能小菜菜)
55
* This is licensed under the GNU LGPL, version 3 or later.

json-bufferify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* json-bufferify 0.0.3
2+
* json-bufferify 0.0.4
33
* Date: 2017-07-06
44
* © 2017 LangZhai(智能小菜菜)
55
* This is licensed under the GNU LGPL, version 3 or later.
@@ -42,7 +42,7 @@
4242
*/
4343
let encode = (offset, data) => {
4444
let arr = [],
45-
view = new DataView(new ArrayBuffer(_encode(1, arr, data)));
45+
view = new DataView(new ArrayBuffer(_encode(offset, arr, data)));
4646
arr.forEach(item => {
4747
view[`set${item.type}`](item.offset, item.val);
4848
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "json-bufferify",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"main": "json-bufferify.js",
55
"types": "json-bufferify.d.ts",
66
"description": "Convert JSON to ArrayBuffer and Revert ArrayBuffer to JSON.",
77
"author": "LangZhai (智能小菜菜)",
88
"license": "LGPL-3.0+",
99
"scripts": {
10-
"test": "echo \"Error: no test specified\" && exit 1"
10+
"test": "node test"
1111
},
1212
"repository": {
1313
"type": "git",

test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var bufferify = require('./json-bufferify'),
2+
obj = {name: 'string', sex: 'number', age: 'number'},
3+
view = bufferify.encode(10, {name: 'Bob', sex: 0, age: 25});
4+
5+
bufferify.decode(10, obj, view);
6+
console.log(obj);

0 commit comments

Comments
 (0)