From 29047c248162d1044373e962d61b22f3271ddfa2 Mon Sep 17 00:00:00 2001 From: Jarmo van Lenthe Date: Sun, 12 Nov 2017 22:20:16 -0500 Subject: [PATCH] Add JSDoc to helper functions and reformat while true. --- src/core/operations/PhpSerialization.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/core/operations/PhpSerialization.js b/src/core/operations/PhpSerialization.js index 7b4298c2..adaa049a 100644 --- a/src/core/operations/PhpSerialization.js +++ b/src/core/operations/PhpSerialization.js @@ -26,7 +26,16 @@ const PhpSerialization = { * @returns {string} */ PhpDeserialize: function (input, args) { + /** + * Recursive method for deserializing. + * @returns {*} + */ function handleInput() { + /** + * Read `length` characters from the input, shifting them out the input. + * @param length + * @returns {string} + */ function read(length) { let result = ""; for (let idx = 0; idx < length; idx++) { @@ -39,9 +48,14 @@ const PhpSerialization = { return result; } + /** + * Read characters from the input until `until` is found. + * @param until + * @returns {string} + */ function readUntil(until) { let result = ""; - while (true) { + for(;;) { let char = read(1); if (char === until) { break; @@ -53,6 +67,11 @@ const PhpSerialization = { } + /** + * Read characters from the input that must be equal to `expect` + * @param expect + * @returns {string} + */ function expect(expect) { let result = read(expect.length); if (result !== expect) { @@ -61,6 +80,10 @@ const PhpSerialization = { return result; } + /** + * Helper function to handle deserialized arrays. + * @returns {Array} + */ function handleArray() { let items = parseInt(readUntil(":"), 10) * 2; expect("{");