@pbroom/color-kit/planeCompile
createPlaneQueryKey
Creates a deterministic cache key for a plane/query pair.
import { createPlaneQueryKey } from '@pbroom/color-kit/plane';compile.ts:168function createPlaneQueryKey(
plane: PlaneDefinition,
query: PlaneQuery,
): string;The plane is resolved first and both parts are serialized with sorted object keys, so equivalent definitions (defaults omitted or spelled out, properties in any order) produce the same key. The key starts with the serialized plane, so PlaneQueryCache.invalidateByPrefix() can drop every entry for one plane.
Parameters
- plane
PlaneDefinition - Plane the query runs against; a
Planeor anyPlaneDefinition. - query
PlaneQuery - Query payload.
Returns
stringThe key string.
Throws
- When the plane model is not supported.
- When the plane definition is otherwise invalid.
Example
import { createPlaneQueryKey, definePlane } from '@pbroom/color-kit/plane';
const a = createPlaneQueryKey({ fixed: { h: 264 } }, { kind: 'gamutBoundary' });
const b = createPlaneQueryKey(definePlane({ fixed: { h: 264, alpha: 1 } }), {
kind: 'gamutBoundary',
});
a === b; // → true
a.slice(0, 24); // → '{"fixed":{"alpha":1,"c":'Also exported from
@pbroom/color-kitthe same declaration, re-exported