source: imaps-frontend/node_modules/ajv-keywords/src/definitions/_util.ts

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 666 bytes
Line 
1import type {DefinitionOptions} from "./_types"
2import type {SchemaObject, KeywordCxt, Name} from "ajv"
3import {_} from "ajv/dist/compile/codegen"
4
5const META_SCHEMA_ID = "http://json-schema.org/schema"
6
7export function metaSchemaRef({defaultMeta}: DefinitionOptions = {}): SchemaObject {
8 return defaultMeta === false ? {} : {$ref: defaultMeta || META_SCHEMA_ID}
9}
10
11export function usePattern(
12 {gen, it: {opts}}: KeywordCxt,
13 pattern: string,
14 flags = opts.unicodeRegExp ? "u" : ""
15): Name {
16 const rx = new RegExp(pattern, flags)
17 return gen.scopeValue("pattern", {
18 key: rx.toString(),
19 ref: rx,
20 code: _`new RegExp(${pattern}, ${flags})`,
21 })
22}
Note: See TracBrowser for help on using the repository browser.