@@ -35,7 +35,7 @@ class PHPSerialize extends Operation {
3535 run ( input , args ) {
3636 /**
3737 * Determines if a number is an integer
38- * @param {number } value
38+ * @param {number } value
3939 * @returns {boolean }
4040 */
4141 function isInteger ( value ) {
@@ -44,7 +44,7 @@ class PHPSerialize extends Operation {
4444
4545 /**
4646 * Serialize basic types
47- * @param {string | number | boolean } content
47+ * @param {string | number | boolean } content
4848 * @returns {string }
4949 */
5050 function serializeBasicTypes ( content ) {
@@ -54,83 +54,75 @@ class PHPSerialize extends Operation {
5454 "float" : "d" ,
5555 "boolean" : "b"
5656 } ;
57-
5857 /**
5958 * Booleans
6059 * cast to 0 or 1
6160 */
62- if ( typeof content === "boolean" ) {
63- return `${ basicTypes [ " boolean" ] } :${ content ? 1 : 0 } ` ;
61+ if ( typeof content === "boolean" ) {
62+ return `${ basicTypes . boolean } :${ content ? 1 : 0 } ` ;
6463 }
65-
6664 /**
6765 * Numbers
6866 */
69- if ( typeof content === "number" ) {
70- if ( isInteger ( content ) ) {
71- return `${ basicTypes [ "integer" ] } :${ content . toString ( ) } `
72- }
73- else {
74- return `${ basicTypes [ "float" ] } :${ content . toString ( ) } `
67+ if ( typeof content === "number" ) {
68+ if ( isInteger ( content ) ) {
69+ return `${ basicTypes . integer } :${ content . toString ( ) } ` ;
70+ } else {
71+ return `${ basicTypes . float } :${ content . toString ( ) } ` ;
7572 }
7673 }
77-
7874 /**
7975 * Strings
8076 */
8177 if ( typeof content === "string" )
82- return `${ basicTypes [ " string" ] } :${ content . length } :"${ content } "` ;
83-
78+ return `${ basicTypes . string } :${ content . length } :"${ content } "` ;
79+
8480 /** This should be unreachable */
8581 throw new OperationError ( `Encountered a non-implemented type: ${ typeof content } ` ) ;
8682 }
8783
8884 /**
8985 * Recursively serialize
90- * @param {* } object
86+ * @param {* } object
9187 * @returns {string }
9288 */
9389 function serialize ( object ) {
9490 /**
9591 * Null
9692 */
9793 if ( object == null ) {
98- return `N;`
94+ return `N;` ;
9995 }
100-
101- /**
102- * Basic types
103- */
104- if ( typeof object !== "object" ) {
96+
97+ if ( typeof object !== "object" ) {
98+ /**
99+ * Basic types
100+ */
105101 return `${ serializeBasicTypes ( object ) } ;` ;
106- }
107-
108- /**
109- * Arrays
110- */
111- else if ( object instanceof Array ) {
102+ } else if ( object instanceof Array ) {
103+ /**
104+ * Arrays
105+ */
112106 const serializedElements = [ ] ;
113-
107+
114108 for ( let i = 0 ; i < object . length ; i ++ ) {
115109 serializedElements . push ( `${ serialize ( i ) } ${ serialize ( object [ i ] ) } ` ) ;
116110 }
117-
118- return `a:${ object . length } :{${ serializedElements . join ( "" ) } }`
119- }
120-
121- /**
122- * Objects
123- * Note: the output cannot be guaranteed to be in the same order as the input
124- */
125- else if ( object instanceof Object ) {
111+
112+ return `a:${ object . length } :{${ serializedElements . join ( "" ) } }` ;
113+ } else if ( object instanceof Object ) {
114+ /**
115+ * Objects
116+ * Note: the output cannot be guaranteed to be in the same order as the input
117+ */
126118 const serializedElements = [ ] ;
127119 const keys = Object . keys ( object ) ;
128-
120+
129121 for ( const key of keys ) {
130122 serializedElements . push ( `${ serialize ( key ) } ${ serialize ( object [ key ] ) } ` ) ;
131123 }
132-
133- return `a:${ keys . length } :{${ serializedElements . join ( "" ) } }`
124+
125+ return `a:${ keys . length } :{${ serializedElements . join ( "" ) } }` ;
134126 }
135127
136128 /** This should be unreachable */
0 commit comments