es-toolkit 0.0.1 → 1.0.0-dev.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +31 -0
- package/dist/array/chunk.d.ts +21 -5
- package/dist/array/difference.d.ts +20 -4
- package/dist/array/differenceBy.d.ts +23 -5
- package/dist/array/differenceWith.d.ts +19 -5
- package/dist/array/drop.d.ts +13 -4
- package/dist/array/dropRight.d.ts +13 -4
- package/dist/array/dropRightWhile.d.ts +15 -4
- package/dist/array/dropWhile.d.ts +15 -4
- package/dist/array/groupBy.d.ts +31 -1
- package/dist/array/groupBy.spec.d.ts +1 -0
- package/dist/array/index.js +437 -224
- package/dist/array/intersection.d.ts +13 -6
- package/dist/array/intersectionBy.d.ts +17 -8
- package/dist/array/intersectionWith.d.ts +18 -8
- package/dist/array/partition.d.ts +19 -5
- package/dist/array/sample.d.ts +10 -3
- package/dist/array/shuffle.d.ts +11 -4
- package/dist/array/takeRight.d.ts +0 -2
- package/dist/array/union.d.ts +13 -6
- package/dist/array/unionBy.d.ts +0 -3
- package/dist/array/unionWith.d.ts +15 -9
- package/dist/array/uniq.d.ts +9 -8
- package/dist/array/xor.d.ts +0 -2
- package/dist/array/zip.d.ts +18 -6
- package/dist/array/zipWith.d.ts +26 -3
- package/dist/function/debounce.d.ts +4 -4
- package/dist/function/index.js +4 -5
- package/dist/function/once.d.ts +0 -1
- package/dist/index.js +651 -248
- package/dist/math/clamp.d.ts +16 -8
- package/dist/math/index.js +114 -29
- package/dist/math/round.d.ts +11 -8
- package/dist/math/sum.d.ts +10 -9
- package/dist/object/index.js +122 -12
- package/dist/object/omit.d.ts +13 -4
- package/dist/object/omitBy.d.ts +19 -1
- package/dist/object/omitBy.spec.d.ts +1 -0
- package/dist/object/pick.d.ts +13 -4
- package/dist/object/pickBy.d.ts +19 -1
- package/dist/object/pickBy.spec.d.ts +1 -0
- package/dist/predicate/index.js +58 -10
- package/dist/predicate/isNil.d.ts +17 -3
- package/dist/predicate/isNotNil.d.ts +7 -3
- package/dist/predicate/isNull.d.ts +17 -2
- package/dist/predicate/isUndefined.d.ts +17 -2
- package/dist/promise/delay.d.ts +17 -4
- package/dist/promise/index.js +16 -3
- package/esm/array/_virtual/_rollupPluginBabelHelpers.mjs +1 -37
- package/esm/array/chunk.mjs +28 -25
- package/esm/array/difference.mjs +20 -4
- package/esm/array/differenceBy.mjs +23 -5
- package/esm/array/differenceWith.mjs +19 -5
- package/esm/array/drop.mjs +13 -4
- package/esm/array/dropRight.mjs +13 -4
- package/esm/array/dropRightWhile.mjs +15 -4
- package/esm/array/dropWhile.mjs +15 -4
- package/esm/array/groupBy.mjs +51 -2
- package/esm/array/intersection.mjs +13 -6
- package/esm/array/intersectionBy.mjs +17 -8
- package/esm/array/intersectionWith.mjs +18 -8
- package/esm/array/partition.mjs +19 -5
- package/esm/array/sample.mjs +10 -3
- package/esm/array/shuffle.mjs +12 -5
- package/esm/array/takeRight.mjs +0 -2
- package/esm/array/union.mjs +14 -10
- package/esm/array/unionBy.mjs +0 -3
- package/esm/array/unionWith.mjs +16 -11
- package/esm/array/uniq.mjs +28 -9
- package/esm/array/xor.mjs +0 -2
- package/esm/array/zip.mjs +18 -6
- package/esm/array/zipWith.mjs +26 -3
- package/esm/function/debounce.mjs +4 -4
- package/esm/function/once.mjs +0 -1
- package/esm/math/_virtual/_rollupPluginBabelHelpers.mjs +66 -0
- package/esm/math/clamp.mjs +15 -7
- package/esm/math/round.mjs +11 -8
- package/esm/math/sum.mjs +25 -14
- package/esm/object/_virtual/_rollupPluginBabelHelpers.mjs +37 -1
- package/esm/object/omit.mjs +13 -4
- package/esm/object/omitBy.mjs +32 -2
- package/esm/object/pick.mjs +13 -4
- package/esm/object/pickBy.mjs +32 -2
- package/esm/predicate/isNil.mjs +17 -3
- package/esm/predicate/isNotNil.mjs +7 -3
- package/esm/predicate/isNull.mjs +17 -2
- package/esm/predicate/isUndefined.mjs +17 -2
- package/esm/promise/delay.mjs +16 -3
- package/package.json +17 -3
- package/.vscode/extensions.json +0 -7
- package/.vscode/settings.json +0 -10
- package/.yarn/sdks/eslint/bin/eslint.js +0 -20
- package/.yarn/sdks/eslint/lib/api.js +0 -20
- package/.yarn/sdks/eslint/lib/unsupported-api.js +0 -20
- package/.yarn/sdks/eslint/package.json +0 -14
- package/.yarn/sdks/integrations.yml +0 -5
- package/.yarn/sdks/prettier/bin/prettier.cjs +0 -20
- package/.yarn/sdks/prettier/index.cjs +0 -20
- package/.yarn/sdks/prettier/package.json +0 -7
- package/.yarn/sdks/typescript/bin/tsc +0 -20
- package/.yarn/sdks/typescript/bin/tsserver +0 -20
- package/.yarn/sdks/typescript/lib/tsc.js +0 -20
- package/.yarn/sdks/typescript/lib/tsserver.js +0 -225
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -225
- package/.yarn/sdks/typescript/lib/typescript.js +0 -20
- package/.yarn/sdks/typescript/package.json +0 -10
- package/babel.config.js +0 -6
- package/coverage/.tmp/coverage-0.json +0 -1
- package/coverage/.tmp/coverage-1.json +0 -1
- package/coverage/.tmp/coverage-10.json +0 -1
- package/coverage/.tmp/coverage-11.json +0 -1
- package/coverage/.tmp/coverage-12.json +0 -1
- package/coverage/.tmp/coverage-13.json +0 -1
- package/coverage/.tmp/coverage-14.json +0 -1
- package/coverage/.tmp/coverage-15.json +0 -1
- package/coverage/.tmp/coverage-16.json +0 -1
- package/coverage/.tmp/coverage-17.json +0 -1
- package/coverage/.tmp/coverage-18.json +0 -1
- package/coverage/.tmp/coverage-19.json +0 -1
- package/coverage/.tmp/coverage-2.json +0 -1
- package/coverage/.tmp/coverage-20.json +0 -1
- package/coverage/.tmp/coverage-21.json +0 -1
- package/coverage/.tmp/coverage-22.json +0 -1
- package/coverage/.tmp/coverage-23.json +0 -1
- package/coverage/.tmp/coverage-24.json +0 -1
- package/coverage/.tmp/coverage-25.json +0 -1
- package/coverage/.tmp/coverage-26.json +0 -1
- package/coverage/.tmp/coverage-27.json +0 -1
- package/coverage/.tmp/coverage-28.json +0 -1
- package/coverage/.tmp/coverage-29.json +0 -1
- package/coverage/.tmp/coverage-3.json +0 -1
- package/coverage/.tmp/coverage-30.json +0 -1
- package/coverage/.tmp/coverage-4.json +0 -1
- package/coverage/.tmp/coverage-5.json +0 -1
- package/coverage/.tmp/coverage-6.json +0 -1
- package/coverage/.tmp/coverage-7.json +0 -1
- package/coverage/.tmp/coverage-8.json +0 -1
- package/coverage/.tmp/coverage-9.json +0 -1
- package/rollup.config.js +0 -5
- package/src/array/chunk.spec.ts +0 -27
- package/src/array/chunk.ts +0 -24
- package/src/array/difference.spec.ts +0 -10
- package/src/array/difference.ts +0 -11
- package/src/array/differenceBy.spec.ts +0 -9
- package/src/array/differenceBy.ts +0 -14
- package/src/array/differenceWith.spec.ts +0 -8
- package/src/array/differenceWith.ts +0 -14
- package/src/array/drop.spec.ts +0 -9
- package/src/array/drop.ts +0 -9
- package/src/array/dropRight.spec.ts +0 -9
- package/src/array/dropRight.ts +0 -9
- package/src/array/dropRightWhile.spec.ts +0 -16
- package/src/array/dropRightWhile.ts +0 -13
- package/src/array/dropWhile.spec.ts +0 -14
- package/src/array/dropWhile.ts +0 -10
- package/src/array/groupBy.ts +0 -3
- package/src/array/index.ts +0 -30
- package/src/array/intersection.spec.ts +0 -11
- package/src/array/intersection.ts +0 -15
- package/src/array/intersectionBy.spec.ts +0 -9
- package/src/array/intersectionBy.ts +0 -18
- package/src/array/intersectionWith.spec.ts +0 -9
- package/src/array/intersectionWith.ts +0 -18
- package/src/array/partition.spec.ts +0 -23
- package/src/array/partition.ts +0 -21
- package/src/array/sample.spec.ts +0 -11
- package/src/array/sample.ts +0 -10
- package/src/array/shuffle.spec.ts +0 -11
- package/src/array/shuffle.ts +0 -18
- package/src/array/take.spec.ts +0 -25
- package/src/array/take.ts +0 -25
- package/src/array/takeRight.spec.ts +0 -25
- package/src/array/takeRight.ts +0 -29
- package/src/array/takeRightWhile.spec.ts +0 -16
- package/src/array/takeRightWhile.ts +0 -26
- package/src/array/takeWhile.spec.ts +0 -34
- package/src/array/takeWhile.ts +0 -31
- package/src/array/union.spec.ts +0 -10
- package/src/array/union.ts +0 -14
- package/src/array/unionBy.spec.ts +0 -12
- package/src/array/unionBy.ts +0 -35
- package/src/array/unionWith.spec.ts +0 -23
- package/src/array/unionWith.ts +0 -18
- package/src/array/uniq.spec.ts +0 -8
- package/src/array/uniq.ts +0 -16
- package/src/array/uniqBy.spec.ts +0 -8
- package/src/array/uniqBy.ts +0 -17
- package/src/array/uniqWith.spec.ts +0 -16
- package/src/array/uniqWith.ts +0 -29
- package/src/array/xor.spec.ts +0 -13
- package/src/array/xor.ts +0 -25
- package/src/array/xorBy.spec.ts +0 -16
- package/src/array/xorBy.ts +0 -29
- package/src/array/xorWith.spec.ts +0 -16
- package/src/array/xorWith.ts +0 -28
- package/src/array/zip.spec.ts +0 -14
- package/src/array/zip.ts +0 -34
- package/src/array/zipWith.spec.ts +0 -13
- package/src/array/zipWith.ts +0 -23
- package/src/function/debounce.spec.ts +0 -76
- package/src/function/debounce.ts +0 -42
- package/src/function/index.ts +0 -3
- package/src/function/once.spec.ts +0 -31
- package/src/function/once.ts +0 -34
- package/src/function/throttle.spec.ts +0 -32
- package/src/function/throttle.ts +0 -39
- package/src/index.ts +0 -6
- package/src/math/clamp.spec.ts +0 -18
- package/src/math/clamp.ts +0 -17
- package/src/math/index.ts +0 -3
- package/src/math/round.spec.ts +0 -53
- package/src/math/round.ts +0 -16
- package/src/math/sum.spec.ts +0 -29
- package/src/math/sum.ts +0 -17
- package/src/object/index.ts +0 -4
- package/src/object/omit.spec.ts +0 -10
- package/src/object/omit.ts +0 -15
- package/src/object/omitBy.ts +0 -3
- package/src/object/pick.spec.ts +0 -10
- package/src/object/pick.ts +0 -15
- package/src/object/pickBy.ts +0 -3
- package/src/predicate/index.ts +0 -4
- package/src/predicate/isNil.spec.ts +0 -23
- package/src/predicate/isNil.ts +0 -8
- package/src/predicate/isNotNil.spec.ts +0 -29
- package/src/predicate/isNotNil.ts +0 -14
- package/src/predicate/isNull.spec.ts +0 -23
- package/src/predicate/isNull.ts +0 -8
- package/src/predicate/isUndefined.spec.ts +0 -23
- package/src/predicate/isUndefined.ts +0 -8
- package/src/promise/delay.spec.ts +0 -13
- package/src/promise/delay.ts +0 -10
- package/src/promise/index.ts +0 -1
- package/tsconfig.json +0 -12
- package/vitest.config.mts +0 -13
package/esm/predicate/isNil.mjs
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Checks if a given value is null or undefined.
|
|
3
|
+
*
|
|
4
|
+
* This function tests whether the provided value is either `null` or `undefined`.
|
|
5
|
+
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
|
|
6
|
+
*
|
|
7
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} x - The value to test for null or undefined.
|
|
10
|
+
* @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* * const value1 = null;
|
|
14
|
+
* const value2 = undefined;
|
|
15
|
+
* const value3 = 42;
|
|
16
|
+
* const result1 = isNil(value1); // true
|
|
17
|
+
* const result2 = isNil(value2); // true
|
|
18
|
+
* const result3 = isNil(value3); // false
|
|
5
19
|
*/
|
|
6
20
|
function isNil(x) {
|
|
7
21
|
return x == null || x == undefined;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @name isNotNil
|
|
3
2
|
* Checks if the given value is not null nor undefined.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* The main use of this function is to be used with TypeScript as a type predicate.
|
|
5
|
+
*
|
|
6
|
+
* @param {T | null | undefined} x - The value to test if it is not null nor undefined.
|
|
7
|
+
* @returns {x is T} True if the value is not null nor undefined, false otherwise.
|
|
8
|
+
*
|
|
6
9
|
* @example
|
|
7
10
|
* // Here the type of `arr` is (number | undefined)[]
|
|
8
11
|
* const arr = [1, undefined, 3];
|
|
9
12
|
* // Here the type of `result` is number[]
|
|
10
13
|
* const result = arr.filter(isNotNil);
|
|
14
|
+
* // result will be [1, 3]
|
|
11
15
|
*/
|
|
12
16
|
function isNotNil(x) {
|
|
13
17
|
return x != null && x != undefined;
|
package/esm/predicate/isNull.mjs
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @name isNull
|
|
3
2
|
* Checks if the given value is null.
|
|
4
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This function tests whether the provided value is strictly equal to `null`.
|
|
5
|
+
* It returns `true` if the value is `null`, and `false` otherwise.
|
|
6
|
+
*
|
|
7
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} x - The value to test if it is null.
|
|
10
|
+
* @returns {x is null} True if the value is null, false otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* * const value1 = null;
|
|
14
|
+
* const value2 = undefined;
|
|
15
|
+
* const value3 = 42;
|
|
16
|
+
*
|
|
17
|
+
* console.log(isNull(value1)); // true
|
|
18
|
+
* console.log(isNull(value2)); // false
|
|
19
|
+
* console.log(isNull(value3)); // false
|
|
5
20
|
*/
|
|
6
21
|
function isNull(x) {
|
|
7
22
|
return x === null;
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @name isUndefined
|
|
3
2
|
* Checks if the given value is undefined.
|
|
4
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This function tests whether the provided value is strictly equal to `undefined`.
|
|
5
|
+
* It returns `true` if the value is `undefined`, and `false` otherwise.
|
|
6
|
+
*
|
|
7
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} x - The value to test if it is undefined.
|
|
10
|
+
* @returns {x is undefined} true if the value is undefined, false otherwise.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* * const value1 = undefined;
|
|
14
|
+
* const value2 = null;
|
|
15
|
+
* const value3 = 42;
|
|
16
|
+
*
|
|
17
|
+
* console.log(isUndefined(value1)); // true
|
|
18
|
+
* console.log(isUndefined(value2)); // false
|
|
19
|
+
* console.log(isUndefined(value3)); // false
|
|
5
20
|
*/
|
|
6
21
|
function isUndefined(x) {
|
|
7
22
|
return x === undefined;
|
package/esm/promise/delay.mjs
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Delays the execution of code for a specified number of milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* This function returns a Promise that resolves after the specified delay, allowing you to use it
|
|
5
|
+
* with async/await to pause execution.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} ms - The number of milliseconds to delay.
|
|
8
|
+
* @returns {Promise<void>} A Promise that resolves after the specified delay.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* async function foo() {
|
|
12
|
+
* console.log('Start');
|
|
13
|
+
* await delay(1000); // Delays execution for 1 second
|
|
14
|
+
* console.log('End');
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* foo();
|
|
5
18
|
*/
|
|
6
19
|
function delay(ms) {
|
|
7
20
|
return new Promise(function (resolve) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"description": "A state-of-the-art, high-performance JavaScript utility library
|
|
4
|
-
"version": "0.0.
|
|
3
|
+
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
+
"version": "1.0.0-dev.24+7203b563",
|
|
5
|
+
"workspaces": [
|
|
6
|
+
"docs"
|
|
7
|
+
],
|
|
5
8
|
"packageManager": "yarn@4.2.2",
|
|
6
9
|
"exports": {
|
|
7
10
|
".": {
|
|
@@ -34,6 +37,10 @@
|
|
|
34
37
|
},
|
|
35
38
|
"./package.json": "./package.json"
|
|
36
39
|
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist/**/*",
|
|
42
|
+
"esm/**/*"
|
|
43
|
+
],
|
|
37
44
|
"publishConfig": {
|
|
38
45
|
"access": "public",
|
|
39
46
|
"exports": {
|
|
@@ -72,14 +79,21 @@
|
|
|
72
79
|
"@babel/core": "^7.24.5",
|
|
73
80
|
"@babel/preset-env": "^7.24.5",
|
|
74
81
|
"@babel/preset-typescript": "^7.24.1",
|
|
75
|
-
"@
|
|
82
|
+
"@changesets/changelog-github": "^0.5.0",
|
|
83
|
+
"@changesets/cli": "^2.27.1",
|
|
84
|
+
"@toss/rollup-config": "0.2.0-canary.0",
|
|
76
85
|
"@types/babel__core": "^7",
|
|
77
86
|
"@types/babel__preset-env": "^7",
|
|
87
|
+
"@types/broken-link-checker": "^0",
|
|
88
|
+
"@types/lodash": "^4",
|
|
78
89
|
"@types/node": "^20.12.11",
|
|
79
90
|
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
80
91
|
"@typescript-eslint/parser": "^7.7.1",
|
|
81
92
|
"@vitest/coverage-istanbul": "^1.5.2",
|
|
93
|
+
"broken-link-checker": "^0.7.8",
|
|
82
94
|
"eslint": "^8.56.0",
|
|
95
|
+
"eslint-config-prettier": "^8.5.0",
|
|
96
|
+
"lodash": "^4.17.21",
|
|
83
97
|
"prettier": "^3.2.5",
|
|
84
98
|
"rollup": "^2.78.0",
|
|
85
99
|
"typescript": "^5.4.5",
|
package/.vscode/extensions.json
DELETED
package/.vscode/settings.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"search.exclude": {
|
|
3
|
-
"**/.yarn": true,
|
|
4
|
-
"**/.pnp.*": true
|
|
5
|
-
},
|
|
6
|
-
"eslint.nodePath": ".yarn/sdks",
|
|
7
|
-
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
|
|
8
|
-
"typescript.tsdk": ".yarn/sdks/typescript/lib",
|
|
9
|
-
"typescript.enablePromptUseWorkspaceTsdk": true
|
|
10
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require eslint/bin/eslint.js
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real eslint/bin/eslint.js your application uses
|
|
20
|
-
module.exports = absRequire(`eslint/bin/eslint.js`);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require eslint
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real eslint your application uses
|
|
20
|
-
module.exports = absRequire(`eslint`);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require eslint/use-at-your-own-risk
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real eslint/use-at-your-own-risk your application uses
|
|
20
|
-
module.exports = absRequire(`eslint/use-at-your-own-risk`);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "eslint",
|
|
3
|
-
"version": "8.57.0-sdk",
|
|
4
|
-
"main": "./lib/api.js",
|
|
5
|
-
"type": "commonjs",
|
|
6
|
-
"bin": {
|
|
7
|
-
"eslint": "./bin/eslint.js"
|
|
8
|
-
},
|
|
9
|
-
"exports": {
|
|
10
|
-
"./package.json": "./package.json",
|
|
11
|
-
".": "./lib/api.js",
|
|
12
|
-
"./use-at-your-own-risk": "./lib/unsupported-api.js"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require prettier/bin/prettier.cjs
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real prettier/bin/prettier.cjs your application uses
|
|
20
|
-
module.exports = absRequire(`prettier/bin/prettier.cjs`);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require prettier
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real prettier your application uses
|
|
20
|
-
module.exports = absRequire(`prettier`);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require typescript/bin/tsc
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real typescript/bin/tsc your application uses
|
|
20
|
-
module.exports = absRequire(`typescript/bin/tsc`);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require typescript/bin/tsserver
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real typescript/bin/tsserver your application uses
|
|
20
|
-
module.exports = absRequire(`typescript/bin/tsserver`);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
if (existsSync(absPnpApiPath)) {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
// Setup the environment to be able to require typescript/lib/tsc.js
|
|
15
|
-
require(absPnpApiPath).setup();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Defer to the real typescript/lib/tsc.js your application uses
|
|
20
|
-
module.exports = absRequire(`typescript/lib/tsc.js`);
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {existsSync} = require(`fs`);
|
|
4
|
-
const {createRequire} = require(`module`);
|
|
5
|
-
const {resolve} = require(`path`);
|
|
6
|
-
|
|
7
|
-
const relPnpApiPath = "../../../../.pnp.cjs";
|
|
8
|
-
|
|
9
|
-
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
10
|
-
const absRequire = createRequire(absPnpApiPath);
|
|
11
|
-
|
|
12
|
-
const moduleWrapper = tsserver => {
|
|
13
|
-
if (!process.versions.pnp) {
|
|
14
|
-
return tsserver;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const {isAbsolute} = require(`path`);
|
|
18
|
-
const pnpApi = require(`pnpapi`);
|
|
19
|
-
|
|
20
|
-
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
|
|
21
|
-
const isPortal = str => str.startsWith("portal:/");
|
|
22
|
-
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
|
|
23
|
-
|
|
24
|
-
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
|
|
25
|
-
return `${locator.name}@${locator.reference}`;
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
|
|
29
|
-
// doesn't understand. This layer makes sure to remove the protocol
|
|
30
|
-
// before forwarding it to TS, and to add it back on all returned paths.
|
|
31
|
-
|
|
32
|
-
function toEditorPath(str) {
|
|
33
|
-
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
|
|
34
|
-
if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
|
|
35
|
-
// We also take the opportunity to turn virtual paths into physical ones;
|
|
36
|
-
// this makes it much easier to work with workspaces that list peer
|
|
37
|
-
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
|
|
38
|
-
// file instances instead of the real ones.
|
|
39
|
-
//
|
|
40
|
-
// We only do this to modules owned by the the dependency tree roots.
|
|
41
|
-
// This avoids breaking the resolution when jumping inside a vendor
|
|
42
|
-
// with peer dep (otherwise jumping into react-dom would show resolution
|
|
43
|
-
// errors on react).
|
|
44
|
-
//
|
|
45
|
-
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
|
|
46
|
-
if (resolved) {
|
|
47
|
-
const locator = pnpApi.findPackageLocator(resolved);
|
|
48
|
-
if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
|
|
49
|
-
str = resolved;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
str = normalize(str);
|
|
54
|
-
|
|
55
|
-
if (str.match(/\.zip\//)) {
|
|
56
|
-
switch (hostInfo) {
|
|
57
|
-
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
|
|
58
|
-
// VSCode only adds it automatically for supported schemes,
|
|
59
|
-
// so we have to do it manually for the `zip` scheme.
|
|
60
|
-
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
|
|
61
|
-
//
|
|
62
|
-
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
|
|
63
|
-
//
|
|
64
|
-
// 2021-10-08: VSCode changed the format in 1.61.
|
|
65
|
-
// Before | ^zip:/c:/foo/bar.zip/package.json
|
|
66
|
-
// After | ^/zip//c:/foo/bar.zip/package.json
|
|
67
|
-
//
|
|
68
|
-
// 2022-04-06: VSCode changed the format in 1.66.
|
|
69
|
-
// Before | ^/zip//c:/foo/bar.zip/package.json
|
|
70
|
-
// After | ^/zip/c:/foo/bar.zip/package.json
|
|
71
|
-
//
|
|
72
|
-
// 2022-05-06: VSCode changed the format in 1.68
|
|
73
|
-
// Before | ^/zip/c:/foo/bar.zip/package.json
|
|
74
|
-
// After | ^/zip//c:/foo/bar.zip/package.json
|
|
75
|
-
//
|
|
76
|
-
case `vscode <1.61`: {
|
|
77
|
-
str = `^zip:${str}`;
|
|
78
|
-
} break;
|
|
79
|
-
|
|
80
|
-
case `vscode <1.66`: {
|
|
81
|
-
str = `^/zip/${str}`;
|
|
82
|
-
} break;
|
|
83
|
-
|
|
84
|
-
case `vscode <1.68`: {
|
|
85
|
-
str = `^/zip${str}`;
|
|
86
|
-
} break;
|
|
87
|
-
|
|
88
|
-
case `vscode`: {
|
|
89
|
-
str = `^/zip/${str}`;
|
|
90
|
-
} break;
|
|
91
|
-
|
|
92
|
-
// To make "go to definition" work,
|
|
93
|
-
// We have to resolve the actual file system path from virtual path
|
|
94
|
-
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
|
|
95
|
-
case `coc-nvim`: {
|
|
96
|
-
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
|
|
97
|
-
str = resolve(`zipfile:${str}`);
|
|
98
|
-
} break;
|
|
99
|
-
|
|
100
|
-
// Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
|
|
101
|
-
// We have to resolve the actual file system path from virtual path,
|
|
102
|
-
// everything else is up to neovim
|
|
103
|
-
case `neovim`: {
|
|
104
|
-
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
|
|
105
|
-
str = `zipfile://${str}`;
|
|
106
|
-
} break;
|
|
107
|
-
|
|
108
|
-
default: {
|
|
109
|
-
str = `zip:${str}`;
|
|
110
|
-
} break;
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return str;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function fromEditorPath(str) {
|
|
121
|
-
switch (hostInfo) {
|
|
122
|
-
case `coc-nvim`: {
|
|
123
|
-
str = str.replace(/\.zip::/, `.zip/`);
|
|
124
|
-
// The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
|
|
125
|
-
// So in order to convert it back, we use .* to match all the thing
|
|
126
|
-
// before `zipfile:`
|
|
127
|
-
return process.platform === `win32`
|
|
128
|
-
? str.replace(/^.*zipfile:\//, ``)
|
|
129
|
-
: str.replace(/^.*zipfile:/, ``);
|
|
130
|
-
} break;
|
|
131
|
-
|
|
132
|
-
case `neovim`: {
|
|
133
|
-
str = str.replace(/\.zip::/, `.zip/`);
|
|
134
|
-
// The path for neovim is in format of zipfile:///<pwd>/.yarn/...
|
|
135
|
-
return str.replace(/^zipfile:\/\//, ``);
|
|
136
|
-
} break;
|
|
137
|
-
|
|
138
|
-
case `vscode`:
|
|
139
|
-
default: {
|
|
140
|
-
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
|
|
141
|
-
} break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Force enable 'allowLocalPluginLoads'
|
|
146
|
-
// TypeScript tries to resolve plugins using a path relative to itself
|
|
147
|
-
// which doesn't work when using the global cache
|
|
148
|
-
// https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
|
|
149
|
-
// VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
|
|
150
|
-
// TypeScript already does local loads and if this code is running the user trusts the workspace
|
|
151
|
-
// https://github.com/microsoft/vscode/issues/45856
|
|
152
|
-
const ConfiguredProject = tsserver.server.ConfiguredProject;
|
|
153
|
-
const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
|
|
154
|
-
ConfiguredProject.prototype.enablePluginsWithOptions = function() {
|
|
155
|
-
this.projectService.allowLocalPluginLoads = true;
|
|
156
|
-
return originalEnablePluginsWithOptions.apply(this, arguments);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// And here is the point where we hijack the VSCode <-> TS communications
|
|
160
|
-
// by adding ourselves in the middle. We locate everything that looks
|
|
161
|
-
// like an absolute path of ours and normalize it.
|
|
162
|
-
|
|
163
|
-
const Session = tsserver.server.Session;
|
|
164
|
-
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
|
|
165
|
-
let hostInfo = `unknown`;
|
|
166
|
-
|
|
167
|
-
Object.assign(Session.prototype, {
|
|
168
|
-
onMessage(/** @type {string | object} */ message) {
|
|
169
|
-
const isStringMessage = typeof message === 'string';
|
|
170
|
-
const parsedMessage = isStringMessage ? JSON.parse(message) : message;
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
parsedMessage != null &&
|
|
174
|
-
typeof parsedMessage === `object` &&
|
|
175
|
-
parsedMessage.arguments &&
|
|
176
|
-
typeof parsedMessage.arguments.hostInfo === `string`
|
|
177
|
-
) {
|
|
178
|
-
hostInfo = parsedMessage.arguments.hostInfo;
|
|
179
|
-
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
|
|
180
|
-
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
|
|
181
|
-
// The RegExp from https://semver.org/ but without the caret at the start
|
|
182
|
-
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
183
|
-
) ?? []).map(Number)
|
|
184
|
-
|
|
185
|
-
if (major === 1) {
|
|
186
|
-
if (minor < 61) {
|
|
187
|
-
hostInfo += ` <1.61`;
|
|
188
|
-
} else if (minor < 66) {
|
|
189
|
-
hostInfo += ` <1.66`;
|
|
190
|
-
} else if (minor < 68) {
|
|
191
|
-
hostInfo += ` <1.68`;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
|
|
198
|
-
return typeof value === 'string' ? fromEditorPath(value) : value;
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
return originalOnMessage.call(
|
|
202
|
-
this,
|
|
203
|
-
isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
|
|
204
|
-
);
|
|
205
|
-
},
|
|
206
|
-
|
|
207
|
-
send(/** @type {any} */ msg) {
|
|
208
|
-
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
|
|
209
|
-
return typeof value === `string` ? toEditorPath(value) : value;
|
|
210
|
-
})));
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
return tsserver;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
if (existsSync(absPnpApiPath)) {
|
|
218
|
-
if (!process.versions.pnp) {
|
|
219
|
-
// Setup the environment to be able to require typescript/lib/tsserver.js
|
|
220
|
-
require(absPnpApiPath).setup();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Defer to the real typescript/lib/tsserver.js your application uses
|
|
225
|
-
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));
|