Registry / testing / synthdef-json-formatter

synthdef-json-formatter

JSON →
library1.0.0jsnpmunverified

A zero-dependency Node.js formatter for SuperCollider Synth Definition JSON files. Version 1.0.0 is stable with a single `format()` function that pretty-prints a synthdef object according to the SuperCollider Synth Definition File Format specification. Currently in maintenance mode with no active development. Differentiators: lightweight, no runtime dependencies, purely a pretty-printer for a niche audio file format.

npm install synthdef-json-formatter
INSTALL
IMPORT
SIG · SYNTHDEF-JSON-FORM
S
synthdef-json-formatter
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
const formatter = require('synthdef-json-formatter'); formatter.format(json)
import { format } from 'synthdef-json-formatter';
Package does not support ESM imports. Use CommonJS require.
default
const formatter = require('synthdef-json-formatter'); formatter.format(json)
const format = require('synthdef-json-formatter').default;
No default export. The require returns an object with a format method.
format
const { format } = require('synthdef-json-formatter');
const format = require('synthdef-json-formatter');
You can destructure format directly, as shown in correct import.

Formats a synthdef JSON object by calling the format function and printing the result.

const format = require('synthdef-json-formatter').format; const synthdef = { name: 'test', consts: [0], paramValues: [0.5, 440], paramIndices: [{ name: 'amp', index: 0, length: 1 }, { name: 'freq', index: 1, length: 1 }], units: [['Control', 1, 0, [], [1, 1]], ['SinOsc', 2, 0, [[0, 1], [-1, 0]], [2]]], variants: [{ name: 'default', values: [0.5, 440] }] }; console.log(format(synthdef));
Debug
Known issues
gotchaThe package only exports a single `format` function. Do not expect other exports or TypeScript types.
fix
Use CommonJS require and only call `.format()`.
affects: =1.0.0
deprecatedPackage is in maintenance mode; no updates or bug fixes are expected.
fix
Consider if formatting is still needed; look for alternatives or maintain your own fork.
affects: >=1.0.0
gotchaThe input JSON must strictly follow the SuperCollider Synth Definition File Format. Invalid structures produce no error and return garbled output.
fix
Validate your synthdef JSON against the SuperCollider specification before formatting.
affects: =1.0.0
Errors
Common errors & fixes
TypeError: formatter.format is not a function
Using ES import syntax (import { format } from ...) instead of CommonJS require.
fix
Use `const formatter = require('synthdef-json-formatter');`
Cannot find module 'synthdef-json-formatter'
Package not installed or incorrect path.
fix
Run `npm install synthdef-json-formatter` and ensure it's in node_modules.
JSON.parse: unexpected character at line 1 column 1 of the JSON data
Passing a raw string instead of a parsed object to format().
fix
Ensure input is a JavaScript object (parsed JSON), not a string.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
12
Resources
synthdef-json-formatter — npm install synthdef-json-formatter · libregistry