main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 5 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
806 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | const SerializerMiddleware = require("./SerializerMiddleware");
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * @typedef {any} DeserializedType
|
---|
| 11 | * @typedef {any[]} SerializedType
|
---|
| 12 | * @extends {SerializerMiddleware<any, any[]>}
|
---|
| 13 | */
|
---|
| 14 | class SingleItemMiddleware extends SerializerMiddleware {
|
---|
| 15 | /**
|
---|
| 16 | * @param {DeserializedType} data data
|
---|
| 17 | * @param {object} context context object
|
---|
| 18 | * @returns {SerializedType|Promise<SerializedType>} serialized data
|
---|
| 19 | */
|
---|
| 20 | serialize(data, context) {
|
---|
| 21 | return [data];
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * @param {SerializedType} data data
|
---|
| 26 | * @param {object} context context object
|
---|
| 27 | * @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
---|
| 28 | */
|
---|
| 29 | deserialize(data, context) {
|
---|
| 30 | return data[0];
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | module.exports = SingleItemMiddleware;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.