diff --git a/npmextra.json b/npmextra.json index 502eb9d..ccffa34 100644 --- a/npmextra.json +++ b/npmextra.json @@ -9,12 +9,23 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartyaml", - "description": "handle yaml in smart ways", + "description": "A module for smart handling of YAML data with support for converting between YAML strings and JavaScript objects.", "npmPackagename": "@push.rocks/smartyaml", - "license": "MIT" + "license": "MIT", + "keywords": [ + "YAML", + "JavaScript", + "data serialization", + "conversion", + "js-yaml", + "TypeScript", + "nodejs", + "parsing", + "stringify" + ] } }, - "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 3a6e8c7..63cf74a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartyaml", "version": "3.0.1", "private": false, - "description": "handle yaml in smart ways", + "description": "A module for smart handling of YAML data with support for converting between YAML strings and JavaScript objects.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -15,8 +15,15 @@ "url": "git+ssh://git@gitlab.com/pushrocks/smartyaml.git" }, "keywords": [ - "yaml", - "lossless" + "YAML", + "JavaScript", + "data serialization", + "conversion", + "js-yaml", + "TypeScript", + "nodejs", + "parsing", + "stringify" ], "author": "Lossless GmbH", "license": "MIT", 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 ecc055e..391be3b 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,134 @@ -# @pushrocks/smartyaml -handle yaml in smart ways +# @push.rocks/smartyaml +Handle YAML in smart ways. -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartyaml) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartyaml) -* [github.com (source mirror)](https://github.com/pushrocks/smartyaml) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartyaml/) +## Install +To use @push.rocks/smartyaml in your project, you need to install it using npm or yarn. Run the following command in your project directory: -## Status for master +```bash +npm install @push.rocks/smartyaml --save +``` +or if you prefer yarn: +```bash +yarn add @push.rocks/smartyaml +``` -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartyaml/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartyaml/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartyaml)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartyaml)](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/@pushrocks/smartyaml)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartyaml)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartyaml)](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) +This will add @push.rocks/smartyaml to your project's dependencies and enable you to start using the library to handle YAML data in a smart way. ## Usage -Use TypeScript for best in class instellisense. +To utilize @push.rocks/smartyaml in your TypeScript project, simply import the desired functionality from the package. This library streamlines YAML data handling by providing straightforward functions for converting YAML strings to objects and vice versa. Let's dive into how you can leverage these capabilities in your applications. -## Contribution +### Basic Conversion: YAML String to JavaScript Object -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). :) +Imagine you're building an application that needs to process configuration files stored in YAML format. With @push.rocks/smartyaml, converting these YAML strings into JavaScript objects for easy manipulation is a breeze. -For further information read the linked docs at the top of this readme. +First, here's how you import the function to convert a YAML string to a JavaScript object: -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +```typescript +import { yamlStringToObject } from '@push.rocks/smartyaml'; +``` -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +Assuming you have a YAML string like this: + +```yaml +name: John Doe +age: 30 +address: + street: 1234 Somewhere Street + city: Anytown + zip: '12345' +``` + +You can convert it to a JavaScript object as follows: + +```typescript +const yamlExample = ` +name: John Doe +age: 30 +address: + street: 1234 Somewhere Street + city: Anytown + zip: '12345' +`; + +async function convertYamlToObject() { + try { + const yamlObject = await yamlStringToObject(yamlExample); + console.log(yamlObject); + /* + * Output: + * { + * name: 'John Doe', + * age: 30, + * address: { street: '1234 Somewhere Street', city: 'Anytown', zip: '12345' } + * } + */ + } catch (error) { + console.error(`Error converting YAML to object: ${error}`); + } +} + +convertYamlToObject(); +``` + +### Converting JavaScript Objects back into YAML Strings + +Let's say you've now manipulated your configuration data, and you want to save these changes back in a YAML file. @push.rocks/smartyaml provides a handy function for that: + +```typescript +import { objectToYamlString } from '@push.rocks/smartyaml'; +``` + +Considering you have a JavaScript object like this: + +```typescript +const jsObject = { + name: 'John Doe', + age: 30, + address: { + street: '1234 Somewhere Street', + city: 'Anytown', + zip: '12345' + } +}; +``` + +You can convert it to a YAML string as follows: + +```typescript +async function convertObjectToYaml() { + try { + const yamlString = await objectToYamlString(jsObject); + console.log(yamlString); + /* + * Output: + * "name: John Doe\nage: 30\naddress:\n street: 1234 Somewhere Street\n city: Anytown\n zip: '12345'\n" + */ + } catch (error) { + console.error(`Error converting object to YAML: ${error}`); + } +} + +convertObjectToYaml(); +``` + +These simple examples illustrate how @push.rocks/smartyaml greatly simplifies the process of converting between YAML strings and JavaScript objects, making it a valuable tool for managing configuration files or any data stored in YAML format in your TypeScript project. + +## 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.