Package Exports
- @mischnic/json-sourcemap
- @mischnic/json-sourcemap/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mischnic/json-sourcemap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@mischnic/json-sourcemap
Generate positions for values in JSON and JSON5 strings.
Inspired by and mostly API-compatible with https://github.com/epoberezkin/json-source-map.
Usage
type Position = {
line: number;
column: number;
pos: number;
};
type Mapping =
| {
value: Position;
valueEnd: Position;
}
| {
value: Position;
valueEnd: Position;
key?: Position;
keyEnd?: Position;
};
export function parse(
json: string,
reviver?: (key: any, value: any) => any,
options?: {
tabWidth?: number;
dialect?: "JSON5" | "JSON";
}
): {
data: any;
pointers: Record<string, Mapping>;
};The default tabWidth is 4.
The valueEnd and keyEnd positions are exclusive. line, column and pos are 0-based.