@@ -41,15 +41,15 @@ import {XmlAttribute, XmlDocument, XmlElement} from "xmlcreate";
4141function parseString ( str : string , parentElement : XmlAttribute | XmlElement ,
4242 options : Options ) : void
4343{
44- let requiresCdata = ( s : string ) => {
44+ const requiresCdata = ( s : string ) => {
4545 return ( options . cdataInvalidChars && ( s . indexOf ( "<" ) !== - 1
4646 || s . indexOf ( "&" ) !== - 1 ) )
4747 || options . cdataKeys . indexOf ( parentElement . name ) !== - 1
4848 || options . cdataKeys . indexOf ( "*" ) !== - 1 ;
4949 } ;
5050
5151 if ( parentElement instanceof XmlElement && requiresCdata ( str ) ) {
52- let cdataStrs = str . split ( "]]>" ) ;
52+ const cdataStrs = str . split ( "]]>" ) ;
5353 for ( let i = 0 ; i < cdataStrs . length ; i ++ ) {
5454 if ( requiresCdata ( cdataStrs [ i ] ) ) {
5555 parentElement . cdata ( cdataStrs [ i ] ) ;
@@ -78,7 +78,7 @@ function parseString(str: string, parentElement: XmlAttribute | XmlElement,
7878function parseAttribute ( name : string , value : string , parentElement : XmlElement ,
7979 options : Options ) : void
8080{
81- let attribute = parentElement . attribute ( name , "" ) ;
81+ const attribute = parentElement . attribute ( name , "" ) ;
8282 if ( isPrimitive ( value ) ) {
8383 parseString ( stringify ( value ) , attribute , options ) ;
8484 } else {
@@ -116,7 +116,7 @@ function parseObjectOrMapEntry(key: string, value: any,
116116 // Attributes key
117117 if ( key . indexOf ( options . attributeString ) === 0 ) {
118118 if ( isObject ( value ) ) {
119- for ( let subkey of Object . keys ( value ) ) {
119+ for ( const subkey of Object . keys ( value ) ) {
120120 parseAttribute ( subkey , value [ subkey ] , parentElement , options ) ;
121121 }
122122 } else {
@@ -163,7 +163,7 @@ function parseObjectOrMap(objectOrMap: any, parentElement: XmlElement,
163163 options ) ;
164164 } ) ;
165165 } else {
166- for ( let key of Object . keys ( objectOrMap ) ) {
166+ for ( const key of Object . keys ( objectOrMap ) ) {
167167 parseObjectOrMapEntry ( key , objectOrMap [ key ] , parentElement ,
168168 options ) ;
169169 }
@@ -194,7 +194,7 @@ function parseArrayOrSet(key: string, arrayOrSet: any,
194194 let arrayKey = key ;
195195 let arrayElement = parentElement ;
196196 if ( ! isUndefined ( arrayNameFunc ) ) {
197- let arrayNameFuncKey = arrayNameFunc ( arrayKey , arrayOrSet ) ;
197+ const arrayNameFuncKey = arrayNameFunc ( arrayKey , arrayOrSet ) ;
198198 if ( isString ( arrayNameFuncKey ) ) {
199199 arrayKey = arrayNameFuncKey ;
200200 arrayElement = parentElement . element ( key ) ;
@@ -228,7 +228,7 @@ function parseValue(key: string, value: any, parentElement: XmlElement,
228228{
229229 // If a handler for a particular type is user-defined, use that handler
230230 // instead of the defaults
231- let type = Object . prototype . toString . call ( value ) ;
231+ const type = Object . prototype . toString . call ( value ) ;
232232 let handler : ( ( value : any ) => any ) | undefined ;
233233 if ( options . typeHandlers . hasOwnProperty ( "*" ) ) {
234234 handler = options . typeHandlers [ "*" ] ;
@@ -260,14 +260,14 @@ function parseValue(key: string, value: any, parentElement: XmlElement,
260260 * @param value The value to convert to XML.
261261 * @param options Options for parsing the value into XML.
262262 *
263- * @returns { XmlDocument } An XML document corresponding to the specified value.
263+ * @returns An XML document corresponding to the specified value.
264264 *
265265 * @private
266266 */
267267function parseToDocument ( root : string , value : any ,
268268 options : Options ) : XmlDocument
269269{
270- let document : XmlDocument = new XmlDocument ( root ) ;
270+ const document : XmlDocument = new XmlDocument ( root ) ;
271271 if ( options . declaration . include ) {
272272 document . decl ( options . declaration ) ;
273273 }
@@ -287,10 +287,10 @@ function parseToDocument(root: string, value: any,
287287 * @param options Options for parsing the object and formatting the resulting
288288 * XML.
289289 *
290- * @returns { string } An XML string representation of the specified object.
290+ * @returns An XML string representation of the specified object.
291291 */
292292export function parse ( root : string , object : any , options ?: IOptions ) : string {
293- let opts : Options = new Options ( options ) ;
294- let document = parseToDocument ( root , object , opts ) ;
293+ const opts : Options = new Options ( options ) ;
294+ const document = parseToDocument ( root , object , opts ) ;
295295 return document . toString ( opts . format ) ;
296296}
0 commit comments