Skip to content

Commit

Permalink
Merge pull request #841 from L4Ph/remove-lodash
Browse files Browse the repository at this point in the history
Quit using lodash
  • Loading branch information
yoichiro authored Jun 4, 2024
2 parents 3abc223 + 3abb05c commit c26bb8d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
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

0 comments on commit c26bb8d

Please sign in to comment.