1.0.3 • Published 2 years ago

node-yaml-path v1.0.3

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 years ago

node-yaml-path

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'

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.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago