Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 10925311c2 | |||
| 536e3c52d4 | |||
| e42d8fd229 | |||
| 62b28f3feb | |||
| 329add7000 | |||
| be2082e728 | |||
| 2f3509aff6 | |||
| a866fce716 | |||
| dc8a3944d5 | |||
| 46602bcb44 | |||
| 343c7dbe8b | |||
| 3a2d1f67b2 | |||
| d59385c339 | |||
| 42abd689d3 |
-140
@@ -1,140 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- npm install -g @shipzone/npmci
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
|
},
|
||||||
|
"@git.zone/cli": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartyaml",
|
||||||
|
"shortDescription": "YAML parsing utilities",
|
||||||
|
"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",
|
||||||
|
"keywords": [
|
||||||
|
"YAML",
|
||||||
|
"JavaScript",
|
||||||
|
"data serialization",
|
||||||
|
"conversion",
|
||||||
|
"js-yaml",
|
||||||
|
"TypeScript",
|
||||||
|
"nodejs",
|
||||||
|
"parsing",
|
||||||
|
"stringify"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-05-01 - 3.0.5 - fix(build)
|
||||||
|
modernize package exports, tooling configuration, and test setup
|
||||||
|
|
||||||
|
- add an explicit package exports entry and include project metadata files in published output
|
||||||
|
- migrate npmextra configuration keys to the new scoped tool namespaces and add release registry settings
|
||||||
|
- update build and test tooling dependencies, switch tests to @git.zone/tstest, and align test file naming with the current runner
|
||||||
|
- tighten TypeScript settings with noImplicitAny and explicit typing for YAML stringification input
|
||||||
|
|
||||||
|
## 2026-03-01 - 3.0.4 - maintenance
|
||||||
|
Project metadata and CI-related housekeeping updates across the 3.0.4 release line.
|
||||||
|
|
||||||
|
- Removed `.gitlab-ci.yml`
|
||||||
|
- Updated project description
|
||||||
|
- Summarized trivial release-tag and metadata-only commits for 3.0.4
|
||||||
|
|
||||||
|
## 2024-04-30 - 3.0.1-3.0.3 - core
|
||||||
|
Patch release series with repeated core updates and minor configuration maintenance.
|
||||||
|
|
||||||
|
- Applied repeated `fix(core): update` changes in versions 3.0.1, 3.0.2, and 3.0.3
|
||||||
|
- Updated `tsconfig`
|
||||||
|
- Updated `npmextra.json` githost settings
|
||||||
|
- Summarized release-only commits for versions 3.0.1 through 3.0.3
|
||||||
|
|
||||||
|
## 2022-05-20 - 3.0.0 - core
|
||||||
|
Major runtime update introducing an ESM-based package structure.
|
||||||
|
|
||||||
|
- BREAKING CHANGE: switched package output to ESM
|
||||||
|
- Included follow-up core update in the 3.0.0 release line
|
||||||
|
- Summarized release-only commits for versions 2.0.5, 3.0.0, and 3.0.1
|
||||||
|
|
||||||
|
## 2020-10-26 - 2.0.3-2.0.4 - core
|
||||||
|
Patch release range focused on routine core maintenance updates.
|
||||||
|
|
||||||
|
- Applied repeated `fix(core): update` changes in versions 2.0.3 and 2.0.4
|
||||||
|
- Summarized release-only commits for versions 2.0.3 and 2.0.4
|
||||||
|
|
||||||
|
## 2018-08-27 - 2.0.2 - dependencies
|
||||||
|
Dependency cleanup to remove obsolete typings usage.
|
||||||
|
|
||||||
|
- Removed obsolete `typings-global` import from dependencies
|
||||||
|
- Summarized release-only commit for 2.0.2
|
||||||
|
|
||||||
|
## 2018-08-26 - 2.0.0-2.0.1 - CI
|
||||||
|
Release transition with package publishing configuration updates.
|
||||||
|
|
||||||
|
- Updated CI/npm publishing configuration via `npmextra` access level
|
||||||
|
- Summarized release-only commits for versions 2.0.0 and 2.0.1
|
||||||
|
|
||||||
|
## 2018-08-26 - 1.0.2 - scope
|
||||||
|
Major package identity update with accompanying project documentation improvements.
|
||||||
|
|
||||||
|
- BREAKING CHANGE: migrated to the new `@pushrocks` scope
|
||||||
|
- Improved tests
|
||||||
|
- Added README documentation
|
||||||
|
- Summarized release-only commit for 1.0.2
|
||||||
|
|
||||||
|
## 2017-05-25 - 1.0.0-1.0.1 - setup
|
||||||
|
Initial project setup and packaging metadata for the first public releases.
|
||||||
|
|
||||||
|
- Created the initial working version
|
||||||
|
- Added `npmextra.json`
|
||||||
|
- Summarized release-only commit for 1.0.1
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
+31
-9
@@ -1,17 +1,39 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@ship.zone/szci": {
|
||||||
"globalNpmTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"@git.zone/cli": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartyaml",
|
"gitrepo": "smartyaml",
|
||||||
"description": "handle yaml in smart ways",
|
"shortDescription": "YAML parsing utilities",
|
||||||
"npmPackagename": "@pushrocks/smartyaml",
|
"description": "A module for smart handling of YAML data with support for converting between YAML strings and JavaScript objects.",
|
||||||
"license": "MIT"
|
"npmPackagename": "@push.rocks/smartyaml",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"YAML",
|
||||||
|
"JavaScript",
|
||||||
|
"data serialization",
|
||||||
|
"conversion",
|
||||||
|
"js-yaml",
|
||||||
|
"TypeScript",
|
||||||
|
"nodejs",
|
||||||
|
"parsing",
|
||||||
|
"stringify"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+453
-453
File diff suppressed because it is too large
Load Diff
+27
-18
@@ -1,39 +1,46 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartyaml",
|
"name": "@push.rocks/smartyaml",
|
||||||
"version": "3.0.1",
|
"version": "3.0.5",
|
||||||
"private": false,
|
"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.",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist_ts/index.js"
|
||||||
|
},
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "tstest test/",
|
||||||
"build": "(tsbuild --web)"
|
"build": "tsbuild --web"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartyaml.git"
|
"url": "https://code.foss.global/push.rocks/smartyaml.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"yaml",
|
"YAML",
|
||||||
"lossless"
|
"JavaScript",
|
||||||
|
"data serialization",
|
||||||
|
"conversion",
|
||||||
|
"js-yaml",
|
||||||
|
"TypeScript",
|
||||||
|
"nodejs",
|
||||||
|
"parsing",
|
||||||
|
"stringify"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartyaml/issues"
|
"url": "https://code.foss.global/push.rocks/smartyaml/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartyaml#README",
|
"homepage": "https://code.foss.global/push.rocks/smartyaml",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/js-yaml": "^4.0.5",
|
"yaml": "^2.8.3"
|
||||||
"js-yaml": "^4.1.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.61",
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
"@gitzone/tsrun": "^1.2.32",
|
"@git.zone/tstest": "^3.6.3",
|
||||||
"@gitzone/tstest": "^1.0.71",
|
"@types/node": "^25.6.0"
|
||||||
"@pushrocks/tapbundle": "^5.0.3",
|
|
||||||
"@types/node": "^17.0.35"
|
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
@@ -47,6 +54,8 @@
|
|||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
|
".smartconfig.json",
|
||||||
|
"license",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
]
|
||||||
|
|||||||
Generated
+7552
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -1,39 +1,134 @@
|
|||||||
# @pushrocks/smartyaml
|
# @push.rocks/smartyaml
|
||||||
handle yaml in smart ways
|
Handle YAML in smart ways.
|
||||||
|
|
||||||
## Availabililty and Links
|
## Install
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartyaml)
|
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:
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartyaml)
|
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartyaml)
|
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartyaml/)
|
|
||||||
|
|
||||||
## 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
|
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.
|
||||||
-- | --
|
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
||||||
npm | [](https://lossless.cloud)
|
|
||||||
Snyk | [](https://lossless.cloud)
|
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
Code Style | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## 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)
|
```typescript
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
import { yamlStringToObject } from '@push.rocks/smartyaml';
|
||||||
|
```
|
||||||
|
|
||||||
[](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.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||||
|
|
||||||
import * as smartyaml from '../ts/index.js';
|
import * as smartyaml from '../ts/index.js';
|
||||||
|
|
||||||
@@ -25,4 +25,4 @@ tap.test('should allow dots in key', async () => {
|
|||||||
expect(testObject['myKey.with.dots']).toEqual('some');
|
expect(testObject['myKey.with.dots']).toEqual('some');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartyaml',
|
name: '@push.rocks/smartyaml',
|
||||||
version: '3.0.1',
|
version: '3.0.5',
|
||||||
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.'
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-6
@@ -1,15 +1,17 @@
|
|||||||
import * as plugins from './smartyaml.plugins.js';
|
import * as plugins from './smartyaml.plugins.js';
|
||||||
|
|
||||||
export let yamlStringToObject = async (
|
export let yamlStringToObject = async (
|
||||||
yamlStringArg,
|
yamlStringArg: string,
|
||||||
optionsArg: plugins.jsYaml.LoadOptions = {}
|
|
||||||
): Promise<any> => {
|
): Promise<any> => {
|
||||||
return plugins.jsYaml.load(yamlStringArg);
|
return plugins.yaml.parse(yamlStringArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
export let objectToYamlString = async (
|
export let objectToYamlString = async (
|
||||||
objectArg,
|
objectArg: unknown
|
||||||
optionsArg: plugins.jsYaml.DumpOptions = {}
|
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
return plugins.jsYaml.dump(objectArg);
|
return plugins.yaml.stringify(objectArg);
|
||||||
|
};
|
||||||
|
|
||||||
|
export let getYamlDocFromString = async (stringArg: string) => {
|
||||||
|
return plugins.yaml.parseDocument(stringArg);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import * as jsYaml from 'js-yaml';
|
import * as yaml from 'yaml';
|
||||||
|
|
||||||
export { jsYaml };
|
export { yaml };
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"types": ["node"]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user