From c9d6ffe7abdb66a1195e0cb5bff39a21b19478c1 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 18:35:03 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 14 +++-- package.json | 14 +++-- readme.hints.md | 1 + readme.md | 135 ++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 131 insertions(+), 33 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 28481a8..fbfa071 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,25 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartxml", - "description": "a package for creating and parsing xml formated files", + "description": "A package for creating and parsing XML formatted files.", "npmPackagename": "@push.rocks/smartxml", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "XML", + "parsing", + "XML creation", + "fast-xml-parser", + "TypeScript", + "data serialization" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 9d4c24b..5ba8920 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartxml", "version": "1.0.8", "private": false, - "description": "a package for creating and parsing xml formated files", + "description": "A package for creating and parsing XML formatted files.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", @@ -46,5 +46,13 @@ "url": "https://gitlab.com/push.rocks/smartxml/issues" }, "homepage": "https://gitlab.com/push.rocks/smartxml#readme", - "type": "module" -} + "type": "module", + "keywords": [ + "XML", + "parsing", + "XML creation", + "fast-xml-parser", + "TypeScript", + "data serialization" + ] +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 303efa0..7574f22 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,120 @@ # @push.rocks/smartxml -a package for creating and parsing xml formated files +a package for creating and parsing XML formatted files -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartxml) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartxml) -* [github.com (source mirror)](https://github.com/pushrocks/smartxml) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartxml/) +## Install -## Status for master +To start using @push.rocks/smartxml in your project, you'll first need to install it. This package is distributed via npm, so you can install it by running the following command in your project's root directory: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartxml/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartxml/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartxml)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartxml)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartxml)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartxml)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartxml)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +```sh +npm install @push.rocks/smartxml --save +``` ## Usage -Use TypeScript for best in class intellisense +### Getting Started -## Contribution +First, ensure that your project is set up to use TypeScript and ESM syntax. Then, you can import `SmartXml` from @push.rocks/smartxml as follows: -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +```typescript +import { SmartXml } from '@push.rocks/smartxml'; +``` -For further information read the linked docs at the top of this readme. +`SmartXml` provides two main functionalities: parsing XML formatted strings into JavaScript objects and vice versa, creating XML formatted strings from JavaScript objects. -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +### Parsing XML String to Object -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +To parse an XML string to a JavaScript object, you can use the `parseXmlToObject` method. This method takes an XML string as its argument and returns a JavaScript object. + +Here's a simple example: + +```typescript +const xmlString = ` + + Tove + Jani + Reminder + Don't forget me this weekend! + +`; + +const smartXml = new SmartXml(); +const resultObject = smartXml.parseXmlToObject(xmlString); + +console.log(resultObject); +``` + +### Creating XML String from Object + +Conversely, if you have a JavaScript object that you want to convert into an XML formatted string, you can use the `createXmlFromObject` method. This method accepts a JavaScript object and returns a string containing the XML representation of the object. + +Here's an example: + +```typescript +const noteObject = { + note: { + to: 'Tove', + from: 'Jani', + heading: 'Reminder', + body: 'Don\'t forget me this weekend!' + } +}; + +const smartXml = new SmartXml(); +const xmlString = smartXml.createXmlFromObject(noteObject); + +console.log(xmlString); +``` + +### Advanced Usage + +The `SmartXml` class is built on top of the `fast-xml-parser` library, which provides a lot of flexibility for both parsing and creation. For example, when creating XML from objects, you can control attributes, formatting, and more. + +Let's look at a more complex example that includes XML attributes: + +```typescript +const complexObject = { + note: { + "@_id": "12345", + "@_priority": "high", + to: 'Tove', + from: { "@_domain": "personal", "#text": 'Jani' }, + heading: { + "@_style": "bold", + "#text": 'Reminder' + }, + body: 'This is a special note for the weekend.' + } +}; + +const smartXml = new SmartXml(); +const complexXmlString = smartXml.createXmlFromObject(complexObject, { + format: true +}); + +console.log(complexXmlString); +``` + +This example demonstrates how to add attributes (using `"@_attributeName": "value"`) and mixed content (using `"#text": "text value"`) to your objects before converting them to XML. + +### Conclusion + +The `@push.rocks/smartxml` package offers a straightforward and powerful means to work with XML in your JavaScript or TypeScript projects. By integrating it, you can easily convert between XML strings and JavaScript objects, allowing for efficient data processing and transmission in scenarios where XML is the preferred format. Whether you're building web services, APIs, or need to handle configuration files in XML, `SmartXml` offers the necessary tools to get the job done with minimal hassle. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.