|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 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 | /** @typedef {EXPECTED_ANY} DeserializedType */
|
|---|
| 10 | /** @typedef {EXPECTED_ANY[]} SerializedType */
|
|---|
| 11 | /** @typedef {EXPECTED_OBJECT} Context */
|
|---|
| 12 |
|
|---|
| 13 | /**
|
|---|
| 14 | * Represents SingleItemMiddleware.
|
|---|
| 15 | * @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>}
|
|---|
| 16 | */
|
|---|
| 17 | class SingleItemMiddleware extends SerializerMiddleware {
|
|---|
| 18 | /**
|
|---|
| 19 | * Serializes this instance into the provided serializer context.
|
|---|
| 20 | * @param {DeserializedType} data data
|
|---|
| 21 | * @param {Context} context context object
|
|---|
| 22 | * @returns {SerializedType | Promise<SerializedType> | null} serialized data
|
|---|
| 23 | */
|
|---|
| 24 | serialize(data, context) {
|
|---|
| 25 | return [data];
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | /**
|
|---|
| 29 | * Restores this instance from the provided deserializer context.
|
|---|
| 30 | * @param {SerializedType} data data
|
|---|
| 31 | * @param {Context} context context object
|
|---|
| 32 | * @returns {DeserializedType | Promise<DeserializedType>} deserialized data
|
|---|
| 33 | */
|
|---|
| 34 | deserialize(data, context) {
|
|---|
| 35 | return data[0];
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | module.exports = SingleItemMiddleware;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.