Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quit using lodash #841

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"@types/ajv": "^1.0.0",
"@types/axios": "^0.14.0",
"@types/downloadjs": "^1.4.2",
"@types/lodash": "^4.14.167",
"@types/node": "^14.14.22",
"@types/prop-types": "^15.7.4",
"@types/qs": "^6.9.6",
Expand Down
3 changes: 1 addition & 2 deletions src/components/configure/keycodekey/KeyGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
KeyLabelLangs,
} from '../../../services/labellang/KeyLabelLangs';
import { mods2Number } from '../customkey/Modifiers';
import _ from 'lodash';
import { MOD_LEFT, MOD_RIGHT } from '../../../services/hid/Constraints';

export type Key = {
Expand Down Expand Up @@ -98,7 +97,7 @@ export const genKey = (keymap: IKeymap, lang?: KeyboardLabelLang): Key => {

let newKeymap: IKeymap = keymap;
if (0 < keytop.keywords.length) {
newKeymap = _.cloneDeep(keymap) as IKeymap;
newKeymap = structuredClone(keymap) as IKeymap;
newKeymap.keycodeInfo.keywords = newKeymap.keycodeInfo.keywords.concat(
keytop.keywords
);
Expand Down
9 changes: 4 additions & 5 deletions src/components/configure/macroeditor/MacroEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Tap,
KeyDelayPair,
} from '../../../services/macro/Macro';
import lodash from 'lodash';
import FlashButton, { FlashButtonState } from '../../common/flash/FlashButton';
import { KeycodeCompositionFactory } from '../../../services/hid/Composition';
import { MacroDropSpacer } from './MacroDropSpacer';
Expand Down Expand Up @@ -60,7 +59,7 @@ export default class MacroEditor extends React.Component<
indexInHold: number,
newKeyDelayPair: KeyDelayPair
) {
const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!);
const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!);
if (Number.isNaN(indexInHold)) {
// TODO: Set delay.
const tap: Tap = {
Expand All @@ -85,7 +84,7 @@ export default class MacroEditor extends React.Component<
}

private addTapKeys(index: number, newKeyDelayPairs: KeyDelayPair[]) {
const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!);
const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!);
const taps: Tap[] = newKeyDelayPairs.map((v) => {
// TODO: Set delay.
return { keyDelayPair: v, type: MacroTap };
Expand All @@ -95,7 +94,7 @@ export default class MacroEditor extends React.Component<
}

private popKey() {
const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!);
const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!);
this.props.updateMacroKeys!(macroKeys.slice(0, -1));
}

Expand Down Expand Up @@ -129,7 +128,7 @@ export default class MacroEditor extends React.Component<
if (fromIndex === toIndex && fromIndexInHold === toIndexInHold) {
return;
}
const macroKeys: MacroKey[] = lodash.cloneDeep(this.props.macroKeys!);
const macroKeys: MacroKey[] = structuredClone(this.props.macroKeys!);
const srcMacroKey: MacroKey = macroKeys[fromIndex];
const dstMacroKey: MacroKey = macroKeys[toIndex];
if (fromIndex === toIndex && isHold(srcMacroKey)) {
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5938,7 +5938,6 @@ __metadata:
"@types/ajv": "npm:^1.0.0"
"@types/axios": "npm:^0.14.0"
"@types/downloadjs": "npm:^1.4.2"
"@types/lodash": "npm:^4.14.167"
"@types/node": "npm:^14.14.22"
"@types/prop-types": "npm:^15.7.4"
"@types/qs": "npm:^6.9.6"
Expand Down
Loading