Skip to content

Commit e12537e

Browse files
unix-unicornAzzam1503
authored andcommitted
loadSchemaDialects function
Made a simple function to expose the _dialects object keys and filtering with hasDialect to make sure that we get the loaded schema dialects for json-schema LSP Project Co-authored-by: Azzam Uddin <[email protected]>
1 parent 3c36ca9 commit e12537e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/experimental.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const defineVocabulary: (id: string, keywords: Record<string, string>) =>
6565
export const loadDialect: (dialectId: string, dialect: Record<string, boolean>, allowUnknownKeywords?: boolean) => void;
6666
export const unloadDialect: (dialectId: string) => void;
6767
export const hasDialect: (dialectId: string) => boolean;
68+
export const loadSchemaDialects: () => string[];
6869

6970
export type Keyword<A> = {
7071
id: string;

lib/experimental.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export { compile, interpret, BASIC, DETAILED } from "./core.js";
22
export {
33
addKeyword, getKeyword, getKeywordByName, getKeywordName, getKeywordId,
44
defineVocabulary,
5-
loadDialect, unloadDialect, hasDialect
5+
loadDialect, unloadDialect, hasDialect, loadSchemaDialects
66
} from "./keywords.js";
77
export { getSchema, toSchema, canonicalUri, buildSchemaDocument } from "./schema.js";
88
export { default as Validation } from "./keywords/validation.js";

lib/keywords.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ export const unloadDialect = (dialectId) => {
9292
delete _dialects[dialectId];
9393
}
9494
};
95+
96+
export const loadSchemaDialects = () => {
97+
return Object.keys(_dialects).filter((key) => hasDialect(key));
98+
};

0 commit comments

Comments
 (0)