UNPKG

groq

Version:

Tagged template literal for Sanity.io GROQ-queries

1 lines 1.98 kB
{"version":3,"file":"groq.cjs","sources":["../src/define.ts","../src/groq.ts","../src/_exports.cts.ts"],"sourcesContent":["/**\n * Define a GROQ query. This is a no-op, but it helps editor integrations\n * understand that a string represents a GROQ query in order to provide syntax highlighting\n * and other features.\n *\n * Ideally the `groq` template tag would be used, but we cannot infer types from it until\n * microsoft/TypeScript#33304 is resolved. Otherwise, there is no difference between this\n * and the `groq` template tag.\n *\n * @param query - The GROQ query\n * @returns The same string as the input\n * @public\n */\nexport function defineQuery<const Q extends string>(query: Q): Q {\n return query\n}\n","/**\n * Pass-through groq template tag. This is a no-op, but it helps editor integrations\n * understand that a string represents a GROQ query in order to provide syntax highlighting\n * and other features.\n *\n * @param strings - Template string parts\n * @param keys - Template string keys\n * @returns The same string as the input\n * @public\n */\nexport function groq(strings: TemplateStringsArray, ...keys: any[]): string {\n const lastIndex = strings.length - 1\n return (\n strings.slice(0, lastIndex).reduce((acc, str, i) => {\n return acc + str + keys[i]\n }, '') + strings[lastIndex]\n )\n}\n","import {defineQuery} from './define'\nimport {groq} from './groq'\n\nmodule.exports = groq\n\nObject.assign(module.exports, {defineQuery})\n\n/**\n * This is just to fix the typegen for the CJS export, as TS won't pick up on `module.exports` syntax when the package.json has `type: \"module\"`\n */\nexport type {groq as default, defineQuery}\n"],"names":[],"mappings":";AAaO,SAAS,YAAoC,OAAa;AAC/D,SAAO;AACT;ACLO,SAAS,KAAK,YAAkC,MAAqB;AAC1E,QAAM,YAAY,QAAQ,SAAS;AACnC,SACE,QAAQ,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,KAAK,KAAK,MACrC,MAAM,MAAM,KAAK,CAAC,GACxB,EAAE,IAAI,QAAQ,SAAS;AAE9B;ACdA,OAAO,UAAU;AAEjB,OAAO,OAAO,OAAO,SAAS,EAAC,aAAY;"}