File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -20,14 +20,13 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2020import type { SerializerOptions } from '../../src/serialize/types'
2121import type { SimpleXml } from '../../src/serialize/xml/types'
2222
23+ /** @throws {@link Error } */
2324declare type ThrowError = ( ..._ : any [ ] ) => never
2425
2526declare type Stringify = ( element : SimpleXml . Element , options ?: SerializerOptions ) => string
26- export declare const stringify : Stringify | undefined
27- export declare const stringifyFallback : Stringify | ThrowError
27+ export declare const stringify : Stringify | ThrowError
2828
2929/*
3030declare type Parse = (xml: string) => SimpleXml.Element
31- export declare const parse: Parse | undefined
32- export declare const parseFallback: Parse | ThrowError
31+ export declare const parse: Parse | ThrowError
3332*/
Original file line number Diff line number Diff line change @@ -17,12 +17,20 @@ SPDX-License-Identifier: Apache-2.0
1717Copyright (c) OWASP Foundation. All Rights Reserved.
1818*/
1919
20+ module . exports . stringify = function ( ) {
21+ /* c8 ignore start */
22+ throw new Error (
23+ 'No stringifier available. Please install any of the optional xml libraries: ' +
24+ possibleStringifiers . join ( ', ' )
25+ )
26+ /* c8 ignore end */
27+ }
28+
2029const possibleStringifiers = [
2130 // prioritized list of possible implementations
2231 'xmlbuilder2'
2332]
2433
25- module . exports . stringify = undefined
2634for ( const file of possibleStringifiers ) {
2735 try {
2836 const possibleStringifier = require ( `./stringifiers/${ file } ` )
@@ -36,10 +44,3 @@ for (const file of possibleStringifiers) {
3644 }
3745 /* c8 ignore end */
3846}
39-
40- module . exports . stringifyFallback = module . exports . stringify ??
41- /* c8 ignore start */
42- function ( ) {
43- throw new Error ( 'No stringifier available. Please install one of the optional xml libraries.' )
44- }
45- /* c8 ignore end */
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
1717Copyright (c) OWASP Foundation. All Rights Reserved.
1818*/
1919
20- import { stringifyFallback } from '../../libs/universal-node-xml'
20+ import { stringify } from '../../libs/universal-node-xml'
2121import type { SerializerOptions } from './types'
2222import type { SimpleXml } from './xml/types'
2323import { XmlBaseSerializer } from './xmlBaseSerializer'
@@ -30,6 +30,6 @@ export class XmlSerializer extends XmlBaseSerializer {
3030 normalizedBom : SimpleXml . Element ,
3131 options : SerializerOptions = { }
3232 ) : string {
33- return stringifyFallback ( normalizedBom , options )
33+ return stringify ( normalizedBom , options )
3434 }
3535}
You can’t perform that action at this time.
0 commit comments