fix(core): update
This commit is contained in:
parent
a6adf9b15e
commit
782eda7a6f
5
package-lock.json
generated
5
package-lock.json
generated
@ -5156,6 +5156,11 @@
|
||||
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
||||
"dev": true
|
||||
},
|
||||
"fast-xml-parser": {
|
||||
"version": "3.17.4",
|
||||
"resolved": "https://verdaccio.lossless.one/fast-xml-parser/-/fast-xml-parser-3.17.4.tgz",
|
||||
"integrity": "sha512-qudnQuyYBgnvzf5Lj/yxMcf4L9NcVWihXJg7CiU1L+oUCq8MUnFEfH2/nXR/W5uq+yvUN1h7z6s7vs2v1WkL1A=="
|
||||
},
|
||||
"fastparse": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://verdaccio.lossless.one/fastparse/-/fastparse-1.1.2.tgz",
|
||||
|
@ -20,7 +20,9 @@
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"fast-xml-parser": "^3.17.4"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
|
16
test/test.ts
16
test/test.ts
@ -1,8 +1,20 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartxml from '../ts/index';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(smartxml.standardExport);
|
||||
let testSmartxml: smartxml.SmartXml;
|
||||
|
||||
tap.test('should create ', async () => {
|
||||
testSmartxml = new smartxml.SmartXml();
|
||||
});
|
||||
|
||||
tap.test('should create an xml string', async () => {
|
||||
const xmlResult = testSmartxml.createXmlFromObject({
|
||||
hello: {
|
||||
wow: 'test'
|
||||
}
|
||||
});
|
||||
console.log(xmlResult);
|
||||
});
|
||||
|
||||
|
||||
tap.start();
|
||||
|
15
ts/index.ts
15
ts/index.ts
@ -1,3 +1,16 @@
|
||||
import * as plugins from './smartxml.plugins';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
export class SmartXml {
|
||||
constructor() {}
|
||||
|
||||
public parseXmlToObject<T = any>(xmlStringArg: string): T {
|
||||
const jsonObject = plugins.fastXmlParser.convertToJson(xmlStringArg);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
public createXmlFromObject(jsObject: any): string {
|
||||
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({});
|
||||
const xml = jsToXmlParser.parse(jsObject);
|
||||
return xml;
|
||||
}
|
||||
}
|
@ -1,2 +1,5 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
import * as fastXmlParser from 'fast-xml-parser';
|
||||
|
||||
export {
|
||||
fastXmlParser
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user