Skip to content

Commit

Permalink
synopsis
Browse files Browse the repository at this point in the history
  • Loading branch information
kawanet committed Oct 17, 2018
1 parent e10ca8c commit bb35dc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### ES6

```js
import {MsgExt} from "msg-interface";
import {MsgExt, msgToBuffer} from "msg-interface";

class MsgExtDate extends MsgExt {
static from(date) {
Expand All @@ -23,14 +23,16 @@ MsgExtDate.prototype.type = 0x0D;

const now = Date.UTC(2018, 0, 2, 3, 4, 5);
const msg = MsgExtDate.from(now);
const buffer = msg.toMsgpack(); // => <Buffer d7 01 42 76 15 28 a3 60 80 00>
const buffer = msgToBuffer(msg); // => <Buffer d7 01 42 76 15 28 a3 60 80 00>
const dt = msg.toDate(); // => 2018-01-02T03:04:05.000Z
```

### ES5

```js
var MsgExt = require("msg-interface").MsgExt;
var MsgInterface = require("msg-interface");
var MsgExt = MsgInterface.MsgExt;
var msgToBuffer = MsgInterface.msgToBuffer;

function MsgExtDate(payload) {
MsgExt.call(this, payload);
Expand All @@ -52,7 +54,7 @@ MsgExtDate.prototype.toDate = function() {

var now = Date.UTC(2018, 0, 2, 3, 4, 5);
var msg = MsgExtDate.from(now);
var buffer = msg.toMsgpack(); // => <Buffer d7 01 42 76 15 28 a3 60 80 00>
var buffer = msgToBuffer(msg); // => <Buffer d7 01 42 76 15 28 a3 60 80 00>
var dt = msg.toDate(); // => 2018-01-02T03:04:05.000Z
```

Expand Down
3 changes: 2 additions & 1 deletion test/90.synopsis.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var assert = require("assert");
var MsgInterface = require("../");
var MsgExt = MsgInterface.MsgExt;
var msgToBuffer = MsgInterface.msgToBuffer;

var TITLE = __filename.split("/").pop();

Expand Down Expand Up @@ -34,7 +35,7 @@ describe(TITLE, function() {
assert.equal(msg.buffer.length, 8);
assert.equal(msg.msgpackLength, 10);

var buffer = MsgInterface.msgToBuffer(msg); // => <Buffer d7 01 42 76 15 28 a3 60 80 00>
var buffer = msgToBuffer(msg); // => <Buffer d7 01 42 76 15 28 a3 60 80 00>
assert.equal(atos(buffer), "d7-0d-42-76-0b-4d-37-48-80-00");

var dt = msg.toDate(); // => 2018-01-02T03:04:05.000Z
Expand Down

0 comments on commit bb35dc0

Please sign in to comment.