Skip to content

parse/stringify PipeWire SPA JSON in JavaScript

License

Notifications You must be signed in to change notification settings

EHfive/spa-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPA JSON

PipeWire SPA(Simple Plugin API) JSON in JavaScript

Install

$ # Yarn
$ yarn add spa-json
$ # or NPM
$ npm i spa-json

Usage

import { parse, stringify } from 'spa-json'

const obj = parse(`
context.properties = {
  core.daemon = true
  core.name = pipewire-0
  default.clock.rate = 48000
  default.clock.allowed-rates = [
    44100 48000 96000
  ]
}

context.modules = [
  # ...
]

# ...
`)

const text = stringify(obj)

// import assert from 'assert'
// assert.deepEqual(parse(text), obj)

The api is basically the same as JSON.parse() and JSON.stringify() except we have a noWrap as the 4th parameter of stringify() by which strips top-level wrapper { }.

For detailed documentation, see type definitions.

For example usage, see test/parse.js and test/stringify.js.

TODO

  • implement stringify()
  • maybe add AST support for better config manipulating

About

parse/stringify PipeWire SPA JSON in JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published