Skip to content

Commit

Permalink
fix: change to deep copy
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Mar 27, 2022
1 parent c9649ac commit 0a9c817
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/ignore-case.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Shallow copy and change all keys to lowercase
// Deep copy and change all keys to lowercase
type TData = Record<string, any>;

export default function ignoreCase(data: TData): TData {
if (!data) return data;

const newData = {} as TData;

Object.keys(data).forEach((key) => {
newData[key.toLowerCase()] = data[key];
Object.entries(data).forEach(([key, value]) => {
newData[key.toLowerCase()] = JSON.parse(JSON.stringify(value));
});

return newData;
Expand Down

0 comments on commit 0a9c817

Please sign in to comment.