1.0.4 • Published 1 year ago

node-yaml-path v1.0.4

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
1 year ago

node-yaml-path

!CAUTION DEPRECATED: This package was replaced by https://www.npmjs.com/package/@alell/jsonpath-plus-q

Simple yaml-path to yaml library.

Using get

import { Document, parseDocument } from 'yaml'
import { get, set } from 'node-yaml-path'

const yaml = `
metadata: 
  annotations: 
    simple-annotation: "string value"
`
doc = parseDocument(content)
const path = '$.metadata.annotations.simple-annotation'
const result = get(path, doc)
console.log(result)
// > 'string value'

Using set

import { Document, parseDocument } from 'yaml'
import { get, set } from 'node-yaml-path'

const yaml = `
metadata: 
  annotations: 
    simple-annotation: "string value"
`

const newValue = 'new string value'
set(path, newValue, doc)
const newDoc = parseDocument(doc.toString())
const newResult = get(path, newDoc)
console.log(newResult)
// > 'new string value'

console.log(newDoc.toString())
// > '
//   metadata: 
//     annotations: 
//       simple-annotation: "new string value"
'
1.0.4

1 year ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago