From 44f1c35a520ee201d9099b8fffa226312d703274 Mon Sep 17 00:00:00 2001 From: Robert Plummer Date: Tue, 31 Aug 2021 12:31:10 -0400 Subject: [PATCH] chore: Add typings for typescripters --- package.json | 1 + src/jsonselect.d.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/jsonselect.d.ts diff --git a/package.json b/package.json index 4bb019e..f57c66e 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "url": "https://github.com/lloyd/JSONSelect.git" }, "main": "src/jsonselect", + "types": "src/jsonselect.d.ts", "engines": { "node": ">=0.4.7" }, diff --git a/src/jsonselect.d.ts b/src/jsonselect.d.ts new file mode 100644 index 0000000..47bc5ff --- /dev/null +++ b/src/jsonselect.d.ts @@ -0,0 +1,17 @@ +export interface IJsonSelectCompiled { + match: (selector: string, values: any, object: any) => T[]; + forEach: (selector: string, values: any, object: any, callback: (match: T) => void) => void; +} + +export type Callback = (match: T) => void; + +declare module 'JSONSelect' { + export function match(selector: string, values: any, object: any): T[]; + export function match(selector: string, values: any, object: any): any[]; + + export function forEach(selector: string, values: any, object: any, callback: Callback): void; + export function forEach(selector: string, values: any, object: any, callback: Callback): void; + + export function compile(selector: string): IJsonSelectCompiled; + export function compile(selector: string): IJsonSelectCompiled; +}