```ts
export function heldDown(value: number, ceiling: number): number {
  return value >= ceiling ? ceiling : value;
}

/** Every value of a store brought down to a ceiling. */
export function limitMap(
  store: Record<string, number>,
  ceiling: number,
): Record<string, number> {
  const out: Record<string, number> = {};
  for (const key in store) { // Use for...in instead of Object.keys to iterate over properties
    if (store.hasOwnProperty(key)) {
      const val = store[key];
      if (val <= ceiling) {
        out[key] = val;
      } else if (!isNaN(val)) {
        out[key] = ceiling; // If the value is NaN, we keep it as is since it's beyond our limit
      }
    }
  }
  return out;
}
```