Skip to content

Commit eea9ee0

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 15456d6 commit eea9ee0

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
@@ -63,6 +63,7 @@ export const defineVocabulary: (id: string, keywords: { [keyword: string]: strin
6363
export const loadDialect: (dialectId: string, dialect: { [vocabularyId: string]: boolean }, allowUnknownKeywords?: boolean) => void;
6464
export const unloadDialect: (dialectId: string) => void;
6565
export const hasDialect: (dialectId: string) => boolean;
66+
export const loadSchemaDialects: () => string[];
6667

6768
export type Keyword<A> = {
6869
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 } 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
@@ -86,3 +86,7 @@ export const unloadDialect = (dialectId) => {
8686
delete _allowUnknownKeywords[dialectId];
8787
delete _dialects[dialectId];
8888
};
89+
90+
export const loadSchemaDialects = () => {
91+
return Object.keys(_dialects).filter((key) => hasDialect(key));
92+
};

0 commit comments

Comments
 (0)