-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
<a name="0.x.0"></a> | ||
# 0.x.0 (2017-xx-xx) | ||
|
||
# New | ||
|
||
# Changes | ||
|
||
|
||
|
||
|
||
|
||
|
||
<a name="0.6.0"></a> | ||
# 0.6.0 (2017-03-31) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
|
||
"use strict"; | ||
|
||
const avro = require("avsc"); | ||
const BaseSerializer = require("./base"); | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* moleculer | ||
* Copyright (c) 2017 Ice Services (https://github.com/ice-services/moleculer) | ||
* MIT Licensed | ||
*/ | ||
|
||
"use strict"; | ||
|
||
const BaseSerializer = require("./base"); | ||
|
||
const PSON = require("pson"); | ||
|
||
/** | ||
* MessagePack serializer for Moleculer | ||
* | ||
* https://github.com/dcodeIO/PSON | ||
* | ||
* @class PsonSerializer | ||
*/ | ||
class PsonSerializer extends BaseSerializer { | ||
|
||
/** | ||
* Creates an instance of PsonSerializer. | ||
* | ||
* @memberOf PsonSerializer | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.pson = new PSON.ProgressivePair(); | ||
} | ||
|
||
/** | ||
* Serializer a JS object to string or Buffer | ||
* | ||
* @param {Object} obj | ||
* @returns {String|Buffer} | ||
* | ||
* @memberOf Serializer | ||
*/ | ||
serialize(obj) { | ||
const res = this.pson.encode(obj).compact(); | ||
return res; | ||
} | ||
|
||
/** | ||
* Deserialize string/Buffer to JS object | ||
* | ||
* @param {String|Buffer} str | ||
* @returns {Object} | ||
* | ||
* @memberOf Serializer | ||
*/ | ||
deserialize(str) { | ||
const res = this.pson.decode(str); | ||
return res; | ||
} | ||
} | ||
|
||
module.exports = PsonSerializer; |