INNER CODE UNIT · TypeScript
createFragment
SaltyAom/mobius · src/index.ts:819
export const createFragment = (schema: string) => {
const matches = schema.match(extractFragment)
if (!matches) return {}
const fragments: Record<string, Record<string, true>> = {}
if (matches) {
for (const match of matches) {
// @ts-ignore
const [, name, content] = extractFragment.exec(matches)!
const current: Record<string, true> = {}
for (const item of content.split(/(,|\n)/g))
current[item.trim()] = true
fragments[name] = current
}
}