@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
1 lines • 1.07 kB
Source Map (JSON)
{"version":3,"file":"appendFilters.cjs","sources":["../../../src/lib/appendFilters.ts"],"sourcesContent":["import { castArray } from \"./castArray\"\n\ninterface WithFilters {\n\tfilters?: string | string[]\n}\n\n/**\n * Adds one or more filters to an object with a `filters` property. Appended\n * filters are added to the end of the existing list.\n *\n * @typeParam T - Object to which filters will be append.\n *\n * @param objWithFilters - Object to append filters on the `filters` property.\n * @param filters - One or more filters to append.\n *\n * @returns The object with the appended filters.\n */\nexport const appendFilters = <T extends WithFilters>(\n\tobjWithFilters: T = {} as T,\n\tfilters: string | string[],\n): T & { filters: string[] } => {\n\treturn {\n\t\t...objWithFilters,\n\t\tfilters: [...(objWithFilters.filters || []), ...castArray(filters)],\n\t}\n}\n"],"names":["castArray"],"mappings":";;;AAiBO,MAAM,gBAAgB,CAC5B,iBAAoB,IACpB,YAC8B;AACvB,SAAA;AAAA,IACN,GAAG;AAAA,IACH,SAAS,CAAC,GAAI,eAAe,WAAW,CAAA,GAAK,GAAGA,UAAU,UAAA,OAAO,CAAC;AAAA;AAEpE;;"}