Registry / serialization / json-mirror-compiler

json-mirror-compiler

JSON →
library0.4.12jsnpmunverified

json-mirror-compiler is a TypeScript library (v0.4.12, pre-1.0, monthly releases) that compiles JSON Mirror specifications into executable code. It provides a compile function to transform JSON Pointer-based schema definitions into runtime implementations. Key differentiator: focuses on mirror patterns for bidirectional data mapping, unlike other JSON Pointer tools that only resolve paths. Ships TypeScript types.

npm install json-mirror-compiler
INSTALL
IMPORT
SIG · JSON-MIRROR-COMPIL
J
json-mirror-compiler
serializationjavascriptv0.4.12
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.

compile
import { compile } from 'json-mirror-compiler'
const compile = require('json-mirror-compiler')
ESM-only package; no CommonJS support.
default export
import jsonMirrorCompiler from 'json-mirror-compiler'
const jsonMirrorCompiler = require('json-mirror-compiler')
Default export is available but undocumented; named import is preferred.
MirrorSpec type
import type { MirrorSpec } from 'json-mirror-compiler'
import { MirrorSpec } from 'json-mirror-compiler'
TypeScript type import recommended for type-only usage.

Demonstrates basic usage of the compile function with a simple mirror spec.

import { compile } from 'json-mirror-compiler'; const spec = { source: { jsonPointer: '/data' }, target: { jsonPointer: '/mirrored' } }; const compiledFn = compile(spec); const result = compiledFn({ data: { value: 42 } }); console.log(JSON.stringify(result)); // {"mirrored":{"value":42}}
Debug
Known issues
gotchaPackage is pre-1.0 (v0.4.12); API may change without major version bump.
fix
Pin exact version in package.json and review changelog before updating.
affects: <1.0.0
gotchaKnown breaking change in v0.4.0: Return type of compile changed from object to function.
fix
Update code to treat compile() output as a function rather than a static object.
affects: >=0.4.0 <0.5.0
gotchaESM-only package; CommonJS require will throw an error.
fix
Use ES import syntax or switch to a dynamic import if in a CommonJS context.
affects: >=0.1.0
gotchaTypeScript types shipped but may be incomplete in some versions.
fix
Check type definitions at node_modules/json-mirror-compiler/dist/index.d.ts; contribute fixes if needed.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'json-mirror-compiler'
Package not installed or mismatched version.
fix
Run `npm install json-mirror-compiler@0.4.12` and ensure node_modules includes it.
SyntaxError: The requested module 'json-mirror-compiler' does not provide an export named 'compile'
Using a CommonJS require() which doesn't work with ESM-only packages.
fix
Change to `import { compile } from 'json-mirror-compiler'`.
TypeError: compile is not a function
Using the return value of compile incorrectly (expecting object instead of function) since v0.4.0.
fix
Ensure you call the compiled function: compile(spec)(input) or const fn = compile(spec); fn(input).
Cannot read properties of undefined (reading 'jsonPointer')
Passing an incomplete spec object without source or target fields.
fix
Make sure spec has both 'source' and 'target' objects with 'jsonPointer' strings.
Upgrade
Version history
0.4.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
json-mirror-compiler — npm install json-mirror-compiler · libregistry