import { plainSortObject } from './plainSortObject';

export const stableStringifyObject = (objectValue: object): string => {
  return JSON.stringify(objectValue, (_, value: unknown) => {
    if (typeof value === 'object' && value !== null) {
      return plainSortObject(value);
    }

    return value;
  });
};
