@d-es-ign/stryker-js-util 9.6.0
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/LICENSE +201 -0
- package/README.md +13 -0
- package/dist/src/child-process-as-promised.d.ts +5 -0
- package/dist/src/child-process-as-promised.d.ts.map +1 -0
- package/dist/src/child-process-as-promised.js +6 -0
- package/dist/src/child-process-as-promised.js.map +1 -0
- package/dist/src/deep-merge.d.ts +10 -0
- package/dist/src/deep-merge.d.ts.map +1 -0
- package/dist/src/deep-merge.js +25 -0
- package/dist/src/deep-merge.js.map +1 -0
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +27 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/find-unserializables.d.ts +6 -0
- package/dist/src/find-unserializables.d.ts.map +1 -0
- package/dist/src/find-unserializables.js +60 -0
- package/dist/src/find-unserializables.js.map +1 -0
- package/dist/src/i.d.ts +8 -0
- package/dist/src/i.d.ts.map +1 -0
- package/dist/src/i.js +2 -0
- package/dist/src/i.js.map +1 -0
- package/dist/src/immutable.d.ts +12 -0
- package/dist/src/immutable.d.ts.map +1 -0
- package/dist/src/immutable.js +32 -0
- package/dist/src/immutable.js.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/known-keys.d.ts +8 -0
- package/dist/src/known-keys.d.ts.map +1 -0
- package/dist/src/known-keys.js +2 -0
- package/dist/src/known-keys.js.map +1 -0
- package/dist/src/noop-logger.d.ts +15 -0
- package/dist/src/noop-logger.d.ts.map +1 -0
- package/dist/src/noop-logger.js +39 -0
- package/dist/src/noop-logger.js.map +1 -0
- package/dist/src/not-empty.d.ts +2 -0
- package/dist/src/not-empty.d.ts.map +1 -0
- package/dist/src/not-empty.js +4 -0
- package/dist/src/not-empty.js.map +1 -0
- package/dist/src/platform.d.ts +9 -0
- package/dist/src/platform.d.ts.map +1 -0
- package/dist/src/platform.js +11 -0
- package/dist/src/platform.js.map +1 -0
- package/dist/src/primitive.d.ts +2 -0
- package/dist/src/primitive.d.ts.map +1 -0
- package/dist/src/primitive.js +2 -0
- package/dist/src/primitive.js.map +1 -0
- package/dist/src/require-resolve.d.ts +11 -0
- package/dist/src/require-resolve.d.ts.map +1 -0
- package/dist/src/require-resolve.js +18 -0
- package/dist/src/require-resolve.js.map +1 -0
- package/dist/src/split.d.ts +2 -0
- package/dist/src/split.d.ts.map +1 -0
- package/dist/src/split.js +15 -0
- package/dist/src/split.js.map +1 -0
- package/dist/src/string-utils.d.ts +41 -0
- package/dist/src/string-utils.d.ts.map +1 -0
- package/dist/src/string-utils.js +47 -0
- package/dist/src/string-utils.js.map +1 -0
- package/dist/src/stryker-error.d.ts +5 -0
- package/dist/src/stryker-error.d.ts.map +1 -0
- package/dist/src/stryker-error.js +9 -0
- package/dist/src/stryker-error.js.map +1 -0
- package/dist/src/task.d.ts +23 -0
- package/dist/src/task.d.ts.map +1 -0
- package/dist/src/task.js +56 -0
- package/dist/src/task.js.map +1 -0
- package/dist/src/test-files-provided.d.ts +4 -0
- package/dist/src/test-files-provided.d.ts.map +1 -0
- package/dist/src/test-files-provided.js +4 -0
- package/dist/src/test-files-provided.js.map +1 -0
- package/package.json +43 -0
- package/src/child-process-as-promised.ts +6 -0
- package/src/deep-merge.ts +29 -0
- package/src/errors.ts +31 -0
- package/src/find-unserializables.ts +71 -0
- package/src/i.ts +7 -0
- package/src/immutable.ts +58 -0
- package/src/index.ts +16 -0
- package/src/known-keys.ts +11 -0
- package/src/noop-logger.ts +38 -0
- package/src/not-empty.ts +3 -0
- package/src/platform.ts +10 -0
- package/src/primitive.ts +1 -0
- package/src/require-resolve.ts +19 -0
- package/src/split.ts +16 -0
- package/src/string-utils.ts +76 -0
- package/src/stryker-error.ts +12 -0
- package/src/task.ts +71 -0
- package/src/test-files-provided.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;IACnB;;;;OAIG;uBACgB,OAAO;CAG3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB;;;;OAIG;IACH,eAAe;QACb,OAAO,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC;IACrC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../src/primitive.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.js","sourceRoot":"","sources":["../../src/primitive.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Require a module from the current working directory (or a different base dir)
|
|
3
|
+
* @see https://nodejs.org/api/modules.html#modules_require_resolve_paths_request
|
|
4
|
+
*/
|
|
5
|
+
export declare function requireResolve(id: string, from?: string): unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a module from the current working directory (or a different base dir)
|
|
8
|
+
* @see https://nodejs.org/api/modules.html#modules_require_resolve_paths_request
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveFromCwd(id: string, cwd?: string): string;
|
|
11
|
+
//# sourceMappingURL=require-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-resolve.d.ts","sourceRoot":"","sources":["../../src/require-resolve.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,SAAgB,GAAG,OAAO,CAGxE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,SAAgB,GAAG,MAAM,CAGtE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
/**
|
|
3
|
+
* Require a module from the current working directory (or a different base dir)
|
|
4
|
+
* @see https://nodejs.org/api/modules.html#modules_require_resolve_paths_request
|
|
5
|
+
*/
|
|
6
|
+
export function requireResolve(id, from = process.cwd()) {
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
return require(resolveFromCwd(id, from));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a module from the current working directory (or a different base dir)
|
|
12
|
+
* @see https://nodejs.org/api/modules.html#modules_require_resolve_paths_request
|
|
13
|
+
*/
|
|
14
|
+
export function resolveFromCwd(id, cwd = process.cwd()) {
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
return require.resolve(id, { paths: [cwd] });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=require-resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-resolve.js","sourceRoot":"","sources":["../../src/require-resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;IAC7D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAC5D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/split.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EACrB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAC9C,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAYZ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function split(values, predicate) {
|
|
2
|
+
const left = [];
|
|
3
|
+
const right = [];
|
|
4
|
+
let index = 0;
|
|
5
|
+
for (const value of values) {
|
|
6
|
+
if (predicate(value, index++)) {
|
|
7
|
+
left.push(value);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
right.push(value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return [left, right];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../src/split.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CACnB,MAAmB,EACnB,SAA+C;IAE/C,MAAM,IAAI,GAAQ,EAAE,CAAC;IACrB,MAAM,KAAK,GAAQ,EAAE,CAAC;IACtB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { KnownKeys } from './known-keys.js';
|
|
2
|
+
import { Primitive } from './primitive.js';
|
|
3
|
+
type OnlyObject<T> = Exclude<T, Primitive>;
|
|
4
|
+
/**
|
|
5
|
+
* Consolidates multiple consecutive white spaces into a single space.
|
|
6
|
+
* @param str The string to be normalized
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeWhitespaces(str: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes line endings as unix style.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeLineEndings(text: string): string;
|
|
13
|
+
export interface PropertyPathOverloads<T> {
|
|
14
|
+
(key: KnownKeys<T>): string;
|
|
15
|
+
<TProp1 extends KnownKeys<T>>(key: TProp1, key2: KnownKeys<OnlyObject<T[TProp1]>>): string;
|
|
16
|
+
<TProp1 extends KnownKeys<T>, TProp2 extends KnownKeys<OnlyObject<T[TProp1]>>>(key: TProp1, key2: TProp2, key3: KnownKeys<OnlyObject<OnlyObject<T[TProp1]>[TProp2]>>): string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Given a base type, allows type safe access to the name of a property.
|
|
20
|
+
* @param prop The property name
|
|
21
|
+
*/
|
|
22
|
+
export declare function propertyPath<T>(): PropertyPathOverloads<T>;
|
|
23
|
+
/**
|
|
24
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
|
25
|
+
*/
|
|
26
|
+
export declare function escapeRegExpLiteral(input: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
|
29
|
+
*/
|
|
30
|
+
export declare function escapeRegExp(input: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes relative or absolute file names to be in posix format (forward slashes '/')
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeFileName(fileName: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a URL to the page where you can report a bug.
|
|
37
|
+
* @param titleSuggestion The title to be prefilled in.
|
|
38
|
+
*/
|
|
39
|
+
export declare function strykerReportBugUrl(titleSuggestion: string): string;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=string-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../src/string-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,KAAK,UAAU,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC,MAAM,SAAS,SAAS,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACrC,MAAM,CAAC;IACV,CACE,MAAM,SAAS,SAAS,CAAC,CAAC,CAAC,EAC3B,MAAM,SAAS,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAE/C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACzD,MAAM,CAAC;CACX;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,KAAK,qBAAqB,CAAC,CAAC,CAAC,CAI1D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAInE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidates multiple consecutive white spaces into a single space.
|
|
3
|
+
* @param str The string to be normalized
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeWhitespaces(str) {
|
|
6
|
+
return str.replace(/\s+/g, ' ').trim();
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes line endings as unix style.
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeLineEndings(text) {
|
|
12
|
+
return text.replace(/\r\n/g, '\n');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Given a base type, allows type safe access to the name of a property.
|
|
16
|
+
* @param prop The property name
|
|
17
|
+
*/
|
|
18
|
+
export function propertyPath() {
|
|
19
|
+
const fn = ((...args) => args.join('.'));
|
|
20
|
+
return fn;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
|
24
|
+
*/
|
|
25
|
+
export function escapeRegExpLiteral(input) {
|
|
26
|
+
return input.replace(/[.*+\-?^${}()|[\]\\/]/g, '\\$&'); // $& means the whole matched string
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
|
30
|
+
*/
|
|
31
|
+
export function escapeRegExp(input) {
|
|
32
|
+
return input.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes relative or absolute file names to be in posix format (forward slashes '/')
|
|
36
|
+
*/
|
|
37
|
+
export function normalizeFileName(fileName) {
|
|
38
|
+
return fileName.replace(/\\/g, '/');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a URL to the page where you can report a bug.
|
|
42
|
+
* @param titleSuggestion The title to be prefilled in.
|
|
43
|
+
*/
|
|
44
|
+
export function strykerReportBugUrl(titleSuggestion) {
|
|
45
|
+
return `https://github.com/stryker-mutator/stryker-js/issues/new?assignees=&labels=%F0%9F%90%9B+Bug&template=bug_report.md&title=${encodeURIComponent(titleSuggestion)}`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=string-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../../src/string-utils.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAkBD;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,EAAE,GAA6B,CAAC,CAAC,GAAG,IAAc,EAAE,EAAE,CAC1D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAwC,CAAC;IACzD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC,oCAAoC;AAC9F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC,CAAC,oCAAoC;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,eAAuB;IACzD,OAAO,4HAA4H,kBAAkB,CACnJ,eAAe,CAChB,EAAE,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stryker-error.d.ts","sourceRoot":"","sources":["../../src/stryker-error.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAa,SAAQ,KAAK;aAGnB,UAAU,CAAC,EAAE,OAAO;gBADpC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,OAAO,YAAA;CAMvC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { errorToString } from './errors.js';
|
|
2
|
+
export class StrykerError extends Error {
|
|
3
|
+
innerError;
|
|
4
|
+
constructor(message, innerError) {
|
|
5
|
+
super(`${message}${innerError ? `. Inner error: ${errorToString(innerError)}` : ''}`);
|
|
6
|
+
this.innerError = innerError;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=stryker-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stryker-error.js","sourceRoot":"","sources":["../../src/stryker-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGnB;IAFlB,YACE,OAAe,EACC,UAAoB;QAEpC,KAAK,CACH,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,kBAAkB,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/E,CAAC;QAJc,eAAU,GAAV,UAAU,CAAU;IAKtC,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a promise in a Task api for convenience.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Task<T = void> {
|
|
5
|
+
protected _promise: Promise<T>;
|
|
6
|
+
private resolveFn;
|
|
7
|
+
private rejectFn;
|
|
8
|
+
private _isCompleted;
|
|
9
|
+
constructor();
|
|
10
|
+
get promise(): Promise<T>;
|
|
11
|
+
get isCompleted(): boolean;
|
|
12
|
+
resolve: (result: PromiseLike<T> | T) => void;
|
|
13
|
+
reject: (reason: any) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A task that can expire after the given time.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExpirableTask<T = void> extends Task<T | typeof ExpirableTask.TimeoutExpired> {
|
|
19
|
+
static readonly TimeoutExpired: unique symbol;
|
|
20
|
+
constructor(timeoutMS: number);
|
|
21
|
+
static timeout<K>(promise: Promise<K>, ms: number): Promise<K | typeof ExpirableTask.TimeoutExpired>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/task.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,IAAI,CAAC,CAAC,GAAG,IAAI;IACxB,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,YAAY,CAAS;;IAS7B,IAAW,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAE/B;IAED,IAAW,WAAW,IAAI,OAAO,CAEhC;IAEM,OAAO,GAAI,QAAQ,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,KAAG,IAAI,CAGjD;IAEK,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAGlC;CACH;AAED;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,IAAI,CAAE,SAAQ,IAAI,CAC/C,CAAC,GAAG,OAAO,aAAa,CAAC,cAAc,CACxC;IACC,gBAAuB,cAAc,EAAE,OAAO,MAAM,CACzB;gBAEf,SAAS,EAAE,MAAM;WAKf,OAAO,CAAC,CAAC,EACrB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,CAAC,GAAG,OAAO,aAAa,CAAC,cAAc,CAAC;CAkBpD"}
|
package/dist/src/task.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a promise in a Task api for convenience.
|
|
3
|
+
*/
|
|
4
|
+
export class Task {
|
|
5
|
+
_promise;
|
|
6
|
+
resolveFn;
|
|
7
|
+
rejectFn;
|
|
8
|
+
_isCompleted = false;
|
|
9
|
+
constructor() {
|
|
10
|
+
this._promise = new Promise((resolve, reject) => {
|
|
11
|
+
this.resolveFn = resolve;
|
|
12
|
+
this.rejectFn = reject;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
get promise() {
|
|
16
|
+
return this._promise;
|
|
17
|
+
}
|
|
18
|
+
get isCompleted() {
|
|
19
|
+
return this._isCompleted;
|
|
20
|
+
}
|
|
21
|
+
resolve = (result) => {
|
|
22
|
+
this._isCompleted = true;
|
|
23
|
+
this.resolveFn(result);
|
|
24
|
+
};
|
|
25
|
+
reject = (reason) => {
|
|
26
|
+
this._isCompleted = true;
|
|
27
|
+
this.rejectFn(reason);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A task that can expire after the given time.
|
|
32
|
+
*/
|
|
33
|
+
export class ExpirableTask extends Task {
|
|
34
|
+
static TimeoutExpired = Symbol('TimeoutExpired');
|
|
35
|
+
constructor(timeoutMS) {
|
|
36
|
+
super();
|
|
37
|
+
this._promise = ExpirableTask.timeout(this._promise, timeoutMS);
|
|
38
|
+
}
|
|
39
|
+
static timeout(promise, ms) {
|
|
40
|
+
const sleep = new Promise((res, rej) => {
|
|
41
|
+
const timer = setTimeout(() => res(ExpirableTask.TimeoutExpired), ms);
|
|
42
|
+
promise
|
|
43
|
+
.then((result) => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
res(result);
|
|
46
|
+
})
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
50
|
+
rej(error);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return sleep;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/task.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,IAAI;IACL,QAAQ,CAAa;IACvB,SAAS,CAAuC;IAChD,QAAQ,CAAyB;IACjC,YAAY,GAAG,KAAK,CAAC;IAE7B;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;YACzB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAEM,OAAO,GAAG,CAAC,MAA0B,EAAQ,EAAE;QACpD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC;IAEK,MAAM,GAA0B,CAAC,MAAW,EAAQ,EAAE;QAC3D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,OAAO,aAAwB,SAAQ,IAE5C;IACQ,MAAM,CAAU,cAAc,GACnC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAE3B,YAAY,SAAiB;QAC3B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAEM,MAAM,CAAC,OAAO,CACnB,OAAmB,EACnB,EAAU;QAEV,MAAM,KAAK,GAAG,IAAI,OAAO,CACvB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACX,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;YACtE,OAAO;iBACJ,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBACf,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,GAAG,CAAC,MAAM,CAAC,CAAC;YACd,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACxB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,2EAA2E;gBAC3E,GAAG,CAAC,KAAK,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;QACP,CAAC,CACF,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-files-provided.d.ts","sourceRoot":"","sources":["../../src/test-files-provided.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B,GAAG,OAAO,CAEV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-files-provided.js","sourceRoot":"","sources":["../../src/test-files-provided.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,OAEjC;IACC,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@d-es-ign/stryker-js-util",
|
|
3
|
+
"version": "9.6.0",
|
|
4
|
+
"description": "Contains utilities for Stryker, the mutation testing framework for JavaScript and friends",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/src",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/src/index.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/stryker-mutator/stryker-js.git",
|
|
17
|
+
"directory": "packages/util"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"stryker",
|
|
21
|
+
"utils"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"author": "Nico Jansen <jansennico@gmail.com>",
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/stryker-mutator/stryker-js/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/stryker-mutator/stryker-js/tree/master/packages/util#readme",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@d-es-ign/stryker-js-test-helpers": "9.6.0",
|
|
34
|
+
"@types/node": "24.10.13"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "c8 npm run test:all",
|
|
38
|
+
"test:all": "npm run test:unit && npm run test:integration",
|
|
39
|
+
"test:unit": "mocha \"dist/test/unit/**/*.js\"",
|
|
40
|
+
"test:integration": "mocha \"dist/test/integration/**/*.js\"",
|
|
41
|
+
"stryker": "node ../core/bin/stryker.js run"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type DeepPartial<T> = {
|
|
2
|
+
[P in keyof T]?: T[P] extends Record<string, any> ? DeepPartial<T[P]> : T[P];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param defaults
|
|
8
|
+
* @param overrides
|
|
9
|
+
*/
|
|
10
|
+
export function deepMerge<T>(defaults: T, overrides: DeepPartial<T>): void {
|
|
11
|
+
Object.keys(overrides)
|
|
12
|
+
.filter((key) => key !== '__proto__')
|
|
13
|
+
.forEach((key) => {
|
|
14
|
+
const defaultValue = (defaults as any)[key];
|
|
15
|
+
const overrideValue = (overrides as any)[key];
|
|
16
|
+
if (overrideValue !== undefined) {
|
|
17
|
+
if (
|
|
18
|
+
defaultValue === undefined ||
|
|
19
|
+
typeof defaultValue !== 'object' ||
|
|
20
|
+
typeof overrideValue !== 'object' ||
|
|
21
|
+
Array.isArray(defaultValue)
|
|
22
|
+
) {
|
|
23
|
+
(defaults as any)[key] = overrideValue;
|
|
24
|
+
} else {
|
|
25
|
+
deepMerge(defaultValue, overrideValue as DeepPartial<T>);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function isErrnoException(
|
|
2
|
+
error: unknown,
|
|
3
|
+
): error is NodeJS.ErrnoException {
|
|
4
|
+
return (
|
|
5
|
+
error instanceof Error &&
|
|
6
|
+
typeof (error as NodeJS.ErrnoException).code === 'string'
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function errorToString(error: unknown): string {
|
|
11
|
+
if (!error) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
if (error instanceof Error) {
|
|
15
|
+
if (isErrnoException(error)) {
|
|
16
|
+
return `${error.name}: ${error.code} (${error.syscall}) ${error.stack}`;
|
|
17
|
+
}
|
|
18
|
+
const message = `${error.name}: ${error.message}`;
|
|
19
|
+
if (error.stack) {
|
|
20
|
+
return `${message}\n${error.stack.toString()}`;
|
|
21
|
+
} else {
|
|
22
|
+
return message;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- Ignore as error is most likely a string. Don't use JSON.stringify as circular graphs could cause an error
|
|
26
|
+
return String(error);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const ERROR_CODES = Object.freeze({
|
|
30
|
+
NoSuchFileOrDirectory: 'ENOENT',
|
|
31
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { notEmpty } from './not-empty.js';
|
|
2
|
+
|
|
3
|
+
export interface UnserializableDescription {
|
|
4
|
+
path: string[];
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function findUnserializables(
|
|
9
|
+
thing: unknown,
|
|
10
|
+
): UnserializableDescription[] | undefined {
|
|
11
|
+
switch (typeof thing) {
|
|
12
|
+
case 'number':
|
|
13
|
+
return !isFinite(thing)
|
|
14
|
+
? [
|
|
15
|
+
{
|
|
16
|
+
reason: `Number value \`${thing}\` has no JSON representation`,
|
|
17
|
+
path: [],
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
: undefined;
|
|
21
|
+
case 'string':
|
|
22
|
+
case 'boolean':
|
|
23
|
+
case 'undefined':
|
|
24
|
+
return;
|
|
25
|
+
case 'bigint':
|
|
26
|
+
case 'function':
|
|
27
|
+
case 'symbol':
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
path: [],
|
|
31
|
+
reason: `Primitive type "${typeof thing}" has no JSON representation`,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
case 'object': {
|
|
35
|
+
// Either a plain object, null, array or instance of a class
|
|
36
|
+
if (thing === null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(thing)) {
|
|
40
|
+
const things = thing
|
|
41
|
+
.flatMap((child, index) =>
|
|
42
|
+
findUnserializables(child)?.map((description) => {
|
|
43
|
+
description.path.unshift(index.toString());
|
|
44
|
+
return description;
|
|
45
|
+
}),
|
|
46
|
+
)
|
|
47
|
+
.filter(notEmpty);
|
|
48
|
+
return things.length ? things : undefined;
|
|
49
|
+
}
|
|
50
|
+
const thingProto = Object.getPrototypeOf(thing);
|
|
51
|
+
if (thingProto === Object.prototype || thingProto === null) {
|
|
52
|
+
const things = Object.entries(thing)
|
|
53
|
+
.flatMap(([key, val]) =>
|
|
54
|
+
findUnserializables(val)?.map((description) => {
|
|
55
|
+
description.path.unshift(key);
|
|
56
|
+
return description;
|
|
57
|
+
}),
|
|
58
|
+
)
|
|
59
|
+
.filter(notEmpty);
|
|
60
|
+
return things.length ? things : undefined;
|
|
61
|
+
}
|
|
62
|
+
const protoClassName = thing.constructor.name || '<anonymous class>';
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
path: [],
|
|
66
|
+
reason: `Value is an instance of "${protoClassName}", this detail will get lost in translation during serialization`,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/i.ts
ADDED
package/src/immutable.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Primitive } from './primitive.js';
|
|
2
|
+
|
|
3
|
+
type ImmutablePrimitive = Primitive | ((...args: any[]) => any);
|
|
4
|
+
|
|
5
|
+
export type Immutable<T> = T extends ImmutablePrimitive
|
|
6
|
+
? T
|
|
7
|
+
: T extends Array<infer U>
|
|
8
|
+
? ImmutableArray<U>
|
|
9
|
+
: T extends Map<infer K, infer V>
|
|
10
|
+
? ImmutableMap<K, V>
|
|
11
|
+
: T extends Set<infer M>
|
|
12
|
+
? ImmutableSet<M>
|
|
13
|
+
: T extends RegExp
|
|
14
|
+
? Readonly<RegExp>
|
|
15
|
+
: ImmutableObject<T>;
|
|
16
|
+
|
|
17
|
+
export type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
18
|
+
export type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
19
|
+
export type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
20
|
+
export type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
|
|
21
|
+
|
|
22
|
+
export function deepFreeze<T>(target: T): Immutable<T> {
|
|
23
|
+
switch (typeof target) {
|
|
24
|
+
case 'object':
|
|
25
|
+
if (Array.isArray(target)) {
|
|
26
|
+
return Object.freeze((target as any[]).map(deepFreeze)) as Immutable<T>;
|
|
27
|
+
}
|
|
28
|
+
if (target instanceof Map) {
|
|
29
|
+
return Object.freeze(
|
|
30
|
+
new Map(
|
|
31
|
+
[...target.entries()].map(([k, v]) => [
|
|
32
|
+
deepFreeze(k),
|
|
33
|
+
deepFreeze(v),
|
|
34
|
+
]),
|
|
35
|
+
),
|
|
36
|
+
) as unknown as Immutable<T>;
|
|
37
|
+
}
|
|
38
|
+
if (target instanceof RegExp) {
|
|
39
|
+
return Object.freeze(target) as Immutable<T>;
|
|
40
|
+
}
|
|
41
|
+
if (target === null) {
|
|
42
|
+
return null as Immutable<T>;
|
|
43
|
+
}
|
|
44
|
+
if (target instanceof Set) {
|
|
45
|
+
return Object.freeze(
|
|
46
|
+
new Set([...target.values()].map(deepFreeze)),
|
|
47
|
+
) as unknown as Immutable<T>;
|
|
48
|
+
}
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
...Object.entries(target).reduce<any>((result, [prop, val]) => {
|
|
51
|
+
result[prop] = deepFreeze(val);
|
|
52
|
+
return result;
|
|
53
|
+
}, {}),
|
|
54
|
+
});
|
|
55
|
+
default:
|
|
56
|
+
return target as Immutable<T>;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { childProcessAsPromised } from './child-process-as-promised.js';
|
|
2
|
+
export { StrykerError } from './stryker-error.js';
|
|
3
|
+
export * from './errors.js';
|
|
4
|
+
export * from './immutable.js';
|
|
5
|
+
export * from './known-keys.js';
|
|
6
|
+
export * from './string-utils.js';
|
|
7
|
+
export * from './noop-logger.js';
|
|
8
|
+
export * from './not-empty.js';
|
|
9
|
+
export * from './i.js';
|
|
10
|
+
export * from './task.js';
|
|
11
|
+
export * from './require-resolve.js';
|
|
12
|
+
export * from './deep-merge.js';
|
|
13
|
+
export * from './find-unserializables.js';
|
|
14
|
+
export * from './platform.js';
|
|
15
|
+
export * from './split.js';
|
|
16
|
+
export * from './test-files-provided.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Known keys filters out the index signature from the keys of a type
|
|
3
|
+
* @see https://stackoverflow.com/questions/51465182/typescript-remove-index-signature-using-mapped-types
|
|
4
|
+
*/
|
|
5
|
+
export type KnownKeys<T> = keyof {
|
|
6
|
+
[P in keyof T as string extends P
|
|
7
|
+
? never
|
|
8
|
+
: number extends P
|
|
9
|
+
? never
|
|
10
|
+
: P]: T[P];
|
|
11
|
+
};
|