ast-monkey
Version:
Traverse and edit AST
69 lines (66 loc) • 1.41 kB
TypeScript
export { traverse } from "ast-monkey-traverse";
declare const version: string;
type JsonValue =
| string
| number
| boolean
| null
| undefined
| JsonObject
| JsonArray;
type JsonObject = {
[Key in string]?: JsonValue;
};
type JsonArray = JsonValue[];
interface Finding {
index: number;
key: string;
val: any;
path: number[];
}
interface FindOpts {
key: null | string;
val: any;
only?: undefined | null | "any" | "array" | "object";
}
declare function find(input: JsonValue, opts: FindOpts): Finding[];
interface GetOpts {
index: number;
only?: undefined | null | "any" | "array" | "object";
}
declare function get(input: JsonValue, opts: GetOpts): JsonValue;
interface SetOpts {
key: null | string;
val: any;
index: number;
}
declare function set(input: JsonValue, opts: SetOpts): JsonValue;
interface DropOpts {
index: number;
}
declare function drop(input: JsonValue, opts: DropOpts): JsonValue;
interface DelOpts {
key: null | string;
val: any;
only?: undefined | null | "any" | "array" | "object";
}
declare function del(input: JsonValue, opts: DelOpts): JsonValue;
declare function arrayFirstOnly(input: JsonValue): JsonValue;
export {
type DelOpts,
type DropOpts,
type FindOpts,
type Finding,
type GetOpts,
type JsonArray,
type JsonObject,
type JsonValue,
type SetOpts,
arrayFirstOnly,
del,
drop,
find,
get,
set,
version,
};