MCPcopy
hub / github.com/ajv-validator/ajv / usePattern

Function usePattern

lib/vocabularies/code.ts:95–105  ·  view source on GitHub ↗
({gen, it: {opts}}: KeywordCxt, pattern: string)

Source from the content-addressed store, hash-verified

93const newRegExp = _`new RegExp`
94
95export function usePattern({gen, it: {opts}}: KeywordCxt, pattern: string): Name {
96 const u = opts.unicodeRegExp ? "u" : ""
97 const {regExp} = opts.code
98 const rx = regExp(pattern, u)
99
100 return gen.scopeValue("pattern", {
101 key: rx.toString(),
102 ref: rx,
103 code: _`${regExp.code === "new RegExp" ? newRegExp : useFunc(gen, regExp)}(${pattern}, ${u})`,
104 })
105}
106
107export function validateArray(cxt: KeywordCxt): Name {
108 const {gen, data, keyword, it} = cxt

Callers 3

validatePropertiesFunction · 0.90
isAdditionalFunction · 0.90
codeFunction · 0.90

Calls 4

_Function · 0.90
useFuncFunction · 0.90
scopeValueMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…