Skip to content

Commit

Permalink
Use the native structuredClone instead of lodash's deepClone
Browse files Browse the repository at this point in the history
  • Loading branch information
larsjohnsen committed Jun 29, 2024
1 parent c7a11ad commit 4b5c66c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/modules/backupAndRestore/__tests__/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import anyTest from 'ava';
import type { TestInterface } from 'ava';
/* eslint-enable ava/use-test */

import { cloneDeep } from 'lodash-es';
import { serialize, deserialize } from '../serialization.js';

const test: TestInterface<{ _realConsoleWarn: * }> = (anyTest: any);
Expand Down Expand Up @@ -106,6 +105,6 @@ test('roundtrip current schema version', t => {
e: '[1, 2, 3]',
f: { foo: 'bar' },
};
const clonedData = cloneDeep(data);
const clonedData = structuredClone(data);
t.deepEqual(deserialize(serialize(clonedData)), data);
});
4 changes: 2 additions & 2 deletions lib/modules/filteReddit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */

import { memoize, once, difference, zip, sortBy, isEmpty, cloneDeep, groupBy, pull } from 'lodash-es';
import { memoize, once, difference, zip, sortBy, isEmpty, groupBy, pull } from 'lodash-es';
import { markdown } from 'snudown-js';
import { Module } from '../core/module';
import * as Options from '../core/options';
Expand Down Expand Up @@ -815,7 +815,7 @@ export async function saveFilterlineStateAsDefault(type: string) {
if (!storage) throw new Error(`Could not find storage for type ${type}`);

const v: LineState = (await filterlineStorage.get(): any);
let { filters } = cloneDeep(v) || {};
let { filters } = structuredClone(v) || {};
if (isEmpty(filters)) filters = null;
await storage.set(filters);
Notifications.showNotification('Saved.', 1000);
Expand Down

0 comments on commit 4b5c66c

Please sign in to comment.