Skip to content

Commit

Permalink
Chore(inquirer): Completely drop lodash (#1443)
Browse files Browse the repository at this point in the history
Fix #1441
  • Loading branch information
SBoudrias authored Jun 27, 2024
1 parent d5f62c6 commit f59681b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
Binary file not shown.
Binary file not shown.
29 changes: 24 additions & 5 deletions packages/inquirer/lib/ui/prompt.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import get from 'lodash.get';
import set from 'lodash.set';

const _ = {
set,
get,
set: (obj, path = '', value) => {
let pointer = obj;
path.split('.').forEach((key, index, arr) => {
if (key === '__proto__' || key === 'constructor') return;

if (index === arr.length - 1) {
pointer[key] = value;
} else if (!(key in pointer)) {
pointer[key] = {};
}

pointer = pointer[key];
});
},
get: (obj, path = '', defaultValue) => {
const travel = (regexp) =>
String.prototype.split
.call(path, regexp)
.filter(Boolean)
.reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj);
const result = travel(/[,[\]]+?/) || travel(/[,.[\]]+?/);
return result === undefined || result === obj ? defaultValue : result;
},
};

import {
defer,
EMPTY,
Expand Down
2 changes: 0 additions & 2 deletions packages/inquirer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
"ansi-escapes": "^4.3.2",
"cli-width": "^4.1.0",
"external-editor": "^3.1.0",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"mute-stream": "1.0.0",
"ora": "^5.4.1",
"picocolors": "^1.0.1",
Expand Down
16 changes: 0 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4398,8 +4398,6 @@ __metadata:
ansi-escapes: "npm:^4.3.2"
cli-width: "npm:^4.1.0"
external-editor: "npm:^3.1.0"
lodash.get: "npm:^4.4.2"
lodash.set: "npm:^4.3.2"
mute-stream: "npm:1.0.0"
ora: "npm:^5.4.1"
picocolors: "npm:^1.0.1"
Expand Down Expand Up @@ -5155,13 +5153,6 @@ __metadata:
languageName: node
linkType: hard

"lodash.get@npm:^4.4.2":
version: 4.4.2
resolution: "lodash.get@npm:4.4.2"
checksum: 10/2a4925f6e89bc2c010a77a802d1ba357e17ed1ea03c2ddf6a146429f2856a216663e694a6aa3549a318cbbba3fd8b7decb392db457e6ac0b83dc745ed0a17380
languageName: node
linkType: hard

"lodash.ismatch@npm:^4.4.0":
version: 4.4.0
resolution: "lodash.ismatch@npm:4.4.0"
Expand All @@ -5176,13 +5167,6 @@ __metadata:
languageName: node
linkType: hard

"lodash.set@npm:^4.3.2":
version: 4.3.2
resolution: "lodash.set@npm:4.3.2"
checksum: 10/f0968109bca5625c8ce1f1beab758634484443604d3950477e46d8d2631562e5ceae4465b9ce8a393fd47f5a411329f9bacf956c7c95530af1290db1a20343ba
languageName: node
linkType: hard

"lodash@npm:^4.17.21":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
Expand Down

0 comments on commit f59681b

Please sign in to comment.