@pbroom/color-kit/planeCompile

createPlaneQueryKey

Creates a deterministic cache key for a plane/query pair.

functionimport { createPlaneQueryKey } from '@pbroom/color-kit/plane';compile.ts:168
function 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

planePlaneDefinition
Plane the query runs against; a Plane or any PlaneDefinition.
queryPlaneQuery
Query payload.

Returns

stringThe key string.

Throws

  • When the plane model is not supported.
  • When the plane definition is otherwise invalid.

Example

TypeScript
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