MCPcopy Create free account
hub / github.com/Effect-TS/effect / negatedClassPattern

Function negatedClassPattern

packages/tools/ai-codegen/src/Generator.ts:171–175  ·  view source on GitHub ↗
(not: { readonly [x: string]: unknown })

Source from the content-addressed store, hash-verified

169
170/** Rewrites a negated character class as an anchored positive pattern. */
171const negatedClassPattern = (not: { readonly [x: string]: unknown }): string | undefined => {
172 if (Object.keys(not).length !== 1 || !Predicate.isString(not.pattern)) return undefined
173 const match = /^\[\^((?:[^\\[\]]|\\.)+)\]$/.exec(not.pattern)
174 return match === null ? undefined : `^[${match[1]}]*$`
175}
176
177/** Rewrites supported negations as positive constraints; leaves other forms for the importer to reject. */
178const rewriteNot = (js: JsonSchema.JsonSchema): JsonSchema.JsonSchema => {

Callers 1

rewriteNotFunction · 0.85

Calls 2

keysMethod · 0.80
execMethod · 0.45

Tested by

no test coverage detected