export function isCapiSearchResponse()

in packages/pressreader/src/typePredicates.ts [5:17]


export function isCapiSearchResponse(
	data: unknown,
): data is CapiSearchResponse {
	// Check that the candidate is an object
	return (
		data != null &&
		(typeof data === 'object' || typeof data === 'function') &&
		// this is a type predicate and casting is recommended by the docs: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
		// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- see comment above
		(data as CapiSearchResponse).response !== undefined &&
		Array.isArray((data as CapiSearchResponse).response.results)
	);
}