File tree Expand file tree Collapse file tree 6 files changed +25
-21
lines changed
Expand file tree Collapse file tree 6 files changed +25
-21
lines changed Original file line number Diff line number Diff line change 4141 "@types/jest" : " ^29.5.12" ,
4242 "cheminfo-build" : " ^1.2.0" ,
4343 "eslint" : " ^8.57.0" ,
44- "eslint-config-cheminfo-typescript" : " ^12.2 .0" ,
44+ "eslint-config-cheminfo-typescript" : " ^12.4 .0" ,
4545 "he" : " ^1.2.0" ,
4646 "iobuffer" : " ^5.3.2" ,
4747 "jest" : " ^29.7.0" ,
4848 "pako" : " ^2.1.0" ,
4949 "prettier" : " ^3.2.5" ,
50- "rimraf" : " ^5.0.5 " ,
50+ "rimraf" : " ^5.0.7 " ,
5151 "ts-jest" : " ^29.1.2" ,
52- "typescript" : " ^5.3.3 " ,
52+ "typescript" : " ^5.4.5 " ,
5353 "uint8-base64" : " ^0.1.1"
5454 },
5555 "dependencies" : {
56- "dynamic-typing" : " ^1.0.0 "
56+ "dynamic-typing" : " ^1.0.1 "
5757 }
5858}
Original file line number Diff line number Diff line change 11__tests__
2- .npmignore
3- .DS_Store
2+ .npmignore
Original file line number Diff line number Diff line change 1+ export type XMLNodeValue = string | Uint8Array | number | boolean ;
2+
13export class XMLNode {
24 public tagName : string ;
35 public parent ?: XMLNode ;
46 public children : Record < string , XMLNode [ ] > ;
57 public attributes ?: Record < string , XMLNode | boolean > ;
6- public value ?: string | Uint8Array ;
8+ public value ?: XMLNodeValue ;
79 public startIndex : number ;
810 public constructor (
911 tagName : string ,
1012 parent ?: XMLNode ,
11- value ?: Uint8Array | string ,
13+ value ?: Uint8Array | string | undefined | number ,
1214 ) {
1315 this . tagName = tagName ;
1416 this . parent = parent ;
15- this . children = Object . create ( { } ) ; //child tags
16- this . attributes = Object . create ( { } ) ; //attributes map
17+ this . children = Object . create ( null ) ; //child tags
18+ this . attributes = Object . create ( null ) ; //attributes map
1719 this . value = value ; //text only
1820 this . startIndex = - 1 ;
1921 }
Original file line number Diff line number Diff line change 1- export function concat (
2- a ?: string | ArrayLike < number > | undefined ,
3- b ?: string | ArrayLike < number > ,
4- ) {
1+ import { XMLNodeValue } from '../../XMLNode' ;
2+
3+ export function concat ( a ?: XMLNodeValue , b ?: XMLNodeValue ) {
54 if ( a === undefined ) {
65 a = typeof b === 'string' ? '' : new Uint8Array ( 0 ) ;
76 }
Original file line number Diff line number Diff line change 1- /* eslint-disable @typescript-eslint/no-explicit-any */
2- import { XMLNode } from './XMLNode' ;
1+ import { parseString } from 'dynamic-typing' ;
2+
3+ import { XMLNode , XMLNodeValue } from './XMLNode' ;
34import { ParseOptions } from './traversable/defaultOptions' ;
45import { isTagNameInArrayMode , merge , isEmptyObject } from './util' ;
56
6- // eslint-disable-next-line @typescript-eslint/no-var-requires
7- const { parseString } = require ( 'dynamic-typing' ) ;
8-
97/**
108 *
119 * @param {* } node
@@ -17,7 +15,7 @@ export function traversableToJSON(
1715 node : XMLNode ,
1816 options : ParseOptions ,
1917 parentTagName ?: string ,
20- ) : string | Uint8Array | Record < string , string | Uint8Array > {
18+ ) : XMLNodeValue | Record < string , XMLNodeValue > {
2119 const {
2220 dynamicTypingNodeValue,
2321 tagValueProcessor,
@@ -43,7 +41,12 @@ export function traversableToJSON(
4341 }
4442
4543 // otherwise create a textnode if node has some text
46- if ( node . value !== undefined && node . value . length !== 0 ) {
44+ if (
45+ node . value !== undefined &&
46+ ( typeof node . value === 'number' ||
47+ typeof node . value === 'boolean' ||
48+ node . value . length !== 0 )
49+ ) {
4750 const asArray = isTagNameInArrayMode (
4851 node . tagName ,
4952 arrayMode ,
Original file line number Diff line number Diff line change 44 "esModuleInterop" : true ,
55 "moduleResolution" : " node" ,
66 "outDir" : " lib" ,
7+ "skipLibCheck" : true ,
78 "sourceMap" : true ,
89 "strict" : true ,
910 "target" : " es2022"
You can’t perform that action at this time.
0 commit comments