Skip to content

Commit

Permalink
MsgExt does not inherit Msg
Browse files Browse the repository at this point in the history
  • Loading branch information
kawanet committed Oct 19, 2018
1 parent 366dd9a commit 8a0e981
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
16 changes: 14 additions & 2 deletions msg-ext.d.ts
@@ -1,8 +1,9 @@
// msg-ext
/// <reference types="node" />

import {Msg, MsgInterface} from "msg-interface";
import {MsgInterface} from "msg-interface";

export declare class MsgExt extends Msg implements MsgInterface {
export declare class MsgExt implements MsgInterface {
constructor(payload: Buffer, type?: number);
constructor(type: number, payload: Buffer);

Expand All @@ -15,4 +16,15 @@ export declare class MsgExt extends Msg implements MsgInterface {
* msgpack extension type number: -128 to +127
*/
type: number;

/**
* expected maximum length of msgpack representation in bytes
*/
msgpackLength: number;

/**
* write the msgpack representation to the buffer with an optional offset address
* @return {number} actual length of msgpack representation written
*/
writeMsgpackTo(buffer: Buffer, offset: number): number;
}
8 changes: 1 addition & 7 deletions msg-ext.js
@@ -1,7 +1,5 @@
"use strict";

var Msg = require("msg-interface").Msg;

exports.MsgExt = MsgExt;

/**
Expand All @@ -13,8 +11,6 @@ function MsgExt(payload, type) {
return new MsgExt(payload, type);
}

Msg.call(this);

if (!isNaN(payload) && Buffer.isBuffer(type)) {
return MsgExt.call(this, type, +payload);
}
Expand Down Expand Up @@ -42,15 +38,13 @@ function MsgExt(payload, type) {
}

(function(P) {
MsgExt.prototype = P;

P.type = void 0;

P.buffer = void 0;

P.writeMsgpackTo = writeMsgpackTo;

})(Object.create(Msg.prototype));
})(MsgExt.prototype);

var fixedToken = [];
fixedToken[1] = 0xd4;
Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,15 +1,16 @@
{
"name": "msg-ext",
"description": "msgpack ext type container",
"version": "1.0.0",
"version": "1.0.1",
"author": "@kawanet",
"bugs": {
"url": "https://github.com/kawanet/msg-ext/issues"
},
"dependencies": {
"msg-interface": "^1.0.0"
"msg-interface": "^1.1.0"
},
"devDependencies": {
"@types/node": "^10.12.0",
"coveralls": "^3.0.2",
"jshint": "^2.9.6",
"mocha": "^5.2.0",
Expand Down

0 comments on commit 8a0e981

Please sign in to comment.