6 Commits

Author SHA1 Message Date
e75a939214 1.0.5 2020-10-25 22:19:44 +00:00
deda012e03 fix(core): update 2020-10-25 22:19:44 +00:00
933a5e0a45 1.0.4 2020-10-24 21:03:51 +00:00
bb339b8c85 fix(core): update 2020-10-24 21:03:51 +00:00
4fa7b5a4d2 1.0.3 2020-10-24 16:39:39 +00:00
782eda7a6f fix(core): update 2020-10-24 16:39:37 +00:00
5 changed files with 61 additions and 9 deletions

7
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartxml",
"version": "1.0.2",
"version": "1.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartxml",
"version": "1.0.2",
"version": "1.0.5",
"private": false,
"description": "a package for creating and parsing xml formated files",
"main": "dist_ts/index.js",
@@ -9,7 +9,7 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web && tsbundle npm)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
@@ -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"
],

View File

@@ -1,8 +1,34 @@
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;
let testXml = `
<hello>
<wow>nice</wow>
</hello>
`;
tap.test('should create an instance', async () => {
testSmartxml = new smartxml.SmartXml();
});
tap.test('should create an xml string', async () => {
const xmlResult = testSmartxml.createXmlFromObject({
hello: {
"@_xlmns:teststring": "hellothere",
"@_xlmns:testnumber": 10,
wow: 'test'
}
});
console.log(xmlResult);
});
tap.test('should parse an yml file', async () => {
const jsObject = testSmartxml.parseXmlToObject(testXml);
console.log(jsObject);
expect(typeof jsObject).to.equal('object');
expect(jsObject).property('hello').property('wow').to.equal('nice');
});
tap.start();

View File

@@ -1,3 +1,19 @@
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.parse(xmlStringArg);
return jsonObject;
}
public createXmlFromObject(jsObject: any): string {
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({
ignoreAttributes: false,
attributeNamePrefix: "@_"
});
const xml = jsToXmlParser.parse(jsObject);
return xml;
}
}

View File

@@ -1,2 +1,5 @@
const removeme = {};
export { removeme };
import * as fastXmlParser from 'fast-xml-parser';
export {
fastXmlParser
};