Skip to content

Commit f2a5bb2

Browse files
committed
refactor(root): remove lodash
Replace lodash.takewhile with native implementation.
1 parent 78e6bde commit f2a5bb2

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"adm-zip": "^0.5.9",
5656
"cross-env": "^7.0.2",
5757
"json5": "^2.2.0",
58-
"lodash": "^4.17.15",
5958
"rimraf": "^3.0.2",
6059
"yargs": "^17.7.2"
6160
},

rebuild-all.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { execSync } from "node:child_process";
22
import * as fs from "node:fs";
33
import path from "node:path";
44
import yargs from "yargs";
5-
import { takeWhile } from "lodash";
5+
import { takeWhile } from "./utils/common/index.js";
66

77
const args = yargs(process.argv.slice(2))
88
.usage("$0 [--ci --docker keyed/framework1 ... non-keyed/frameworkN]")
@@ -14,7 +14,7 @@ const args = yargs(process.argv.slice(2))
1414
.default("docker", false)
1515
.describe(
1616
"docker",
17-
"Copy package-lock back for docker build or build locally?"
17+
"Copy package-lock back for docker build or build locally?",
1818
).argv;
1919

2020
/*
@@ -49,7 +49,7 @@ console.log(
4949
"docker",
5050
useDocker,
5151
"restartWith",
52-
restartWithFramework
52+
restartWithFramework,
5353
);
5454

5555
const filesToDelete = [
@@ -78,7 +78,7 @@ function getFrameworks() {
7878
const framewokrs = keyedTypes.flatMap((type) =>
7979
fs
8080
.readdirSync(path.join("frameworks", type))
81-
.map((framework) => ({ name: framework, type }))
81+
.map((framework) => ({ name: framework, type })),
8282
);
8383

8484
return framewokrs;

utils/common/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { takeWhile } from "./takeWhile.js";

utils/common/takeWhile.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type Predicate<T> = (value: T, index: number, array: T[]) => boolean;
2+
3+
export function takeWhile<T>(array: T[], predicate: Predicate<T>): T[];

utils/common/takeWhile.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function takeWhile(array, predicate) {
2+
const result = [];
3+
for (let i = 0; i < array.length; i++) {
4+
const value = array[i];
5+
if (predicate(value, i, array)) {
6+
result.push(value);
7+
} else {
8+
break;
9+
}
10+
}
11+
return result;
12+
}
13+
14+
export { takeWhile };

0 commit comments

Comments
 (0)