Socket
Socket
Sign inDemoInstall

@stryker-mutator/util

Package Overview
Dependencies
Maintainers
4
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stryker-mutator/util - npm Package Compare versions

Comparing version 5.6.1 to 6.0.0-beta.0

22

CHANGELOG.md

@@ -6,2 +6,24 @@ # Change Log

# [6.0.0-beta.0](https://github.com/stryker-mutator/stryker-js/compare/v5.6.1...v6.0.0-beta.0) (2022-03-02)
### Features
* **esm config:** support config file as pure esm ([#3432](https://github.com/stryker-mutator/stryker-js/issues/3432)) ([309a7e2](https://github.com/stryker-mutator/stryker-js/commit/309a7e2807e454a82f177de781bc4908f87c739b))
* **esm:** migrate StrykerJS to pure ESM ([#3409](https://github.com/stryker-mutator/stryker-js/issues/3409)) ([78c305e](https://github.com/stryker-mutator/stryker-js/commit/78c305e2c2271fedb54bfff3d34aa6b70b421b3a))
* **esm:** support native es modules in the jasmine runner. ([#3396](https://github.com/stryker-mutator/stryker-js/issues/3396)) ([94708d0](https://github.com/stryker-mutator/stryker-js/commit/94708d00b43e3f84accd42ccb40d95ff30718efa)), closes [#3340](https://github.com/stryker-mutator/stryker-js/issues/3340)
### BREAKING CHANGES
* **esm config:** Exporting a function (using `module.exports = function(config) {}`) from your `stryker.conf.js` file is no longer supported. This was already deprecated but now will give an error.
* **esm:** StrykerJS is now a pure ESM. Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
* **esm:** Node 12.20 is now the min version.
* **esm:** Karma v6.3 is now the min supported karma version for `@stryker-mutator/karma-runner`, since [that version added support for async config loading](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#630-2021-03-23)
* **esm:** The `@stryker-mutator/jamsine-runner` now requires jasmine@3.10 or higher.
## [5.6.1](https://github.com/stryker-mutator/stryker-js/compare/v5.6.0...v5.6.1) (2022-01-23)

@@ -8,0 +30,0 @@

12

dist/src/child-process-as-promised.js

@@ -1,10 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.childProcessAsPromised = void 0;
const tslib_1 = require("tslib");
const childProcess = (0, tslib_1.__importStar)(require("child_process"));
const util_1 = require("util");
exports.childProcessAsPromised = {
exec: (0, util_1.promisify)(childProcess.exec),
import * as childProcess from 'child_process';
import { promisify } from 'util';
export const childProcessAsPromised = {
exec: promisify(childProcess.exec),
};
//# sourceMappingURL=child-process-as-promised.js.map

@@ -1,4 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepMerge = void 0;
/**

@@ -9,3 +6,3 @@ *

*/
function deepMerge(defaults, overrides) {
export function deepMerge(defaults, overrides) {
Object.keys(overrides).forEach((key) => {

@@ -24,3 +21,2 @@ const defaultValue = defaults[key];

}
exports.deepMerge = deepMerge;
//# sourceMappingURL=deep-merge.js.map

@@ -1,8 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DirectoryRequireCache = void 0;
const tslib_1 = require("tslib");
const path_1 = (0, tslib_1.__importDefault)(require("path"));
const not_empty_1 = require("./not-empty");
const platform_1 = require("./platform");
import { createRequire } from 'module';
import path from 'path';
import { notEmpty } from './not-empty.js';
import { platform } from './platform.js';
const require = createRequire(import.meta.url);
/**

@@ -16,3 +14,3 @@ * A helper class that can be used by test runners.

*/
class DirectoryRequireCache {
export class DirectoryRequireCache {
/**

@@ -28,5 +26,5 @@ * Records the files required in the current working directory (excluding node_modules)

const startsWithCaseSensitive = (filename, prefix) => filename.startsWith(prefix);
const startsWith = (0, platform_1.caseSensitiveFs)() ? startsWithCaseSensitive : startsWithCaseInsensitive;
const startsWith = platform.caseSensitiveFs() ? startsWithCaseSensitive : startsWithCaseInsensitive;
Object.keys(require.cache)
.filter((fileName) => startsWith(fileName, `${cwd}${path_1.default.sep}`) && !startsWith(fileName, path_1.default.join(cwd, 'node_modules')))
.filter((fileName) => startsWith(fileName, `${cwd}${path.sep}`) && !startsWith(fileName, path.join(cwd, 'node_modules')))
.forEach((file) => cache.add(file));

@@ -37,3 +35,3 @@ this.parents = new Set(Array.from(cache)

.map((fileName) => { var _a, _b; return (_b = (_a = require.cache[fileName]) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.filename; })
.filter(not_empty_1.notEmpty)
.filter(notEmpty)
// Filter out any parents that are in the current cache, since they will be removed anyway

@@ -56,3 +54,2 @@ .filter((parentFileName) => !cache.has(parentFileName)));

}
exports.DirectoryRequireCache = DirectoryRequireCache;
//# sourceMappingURL=directory-require-cache.js.map

@@ -1,10 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorToString = exports.isErrnoException = void 0;
function isErrnoException(error) {
export function isErrnoException(error) {
return error instanceof Error && typeof error.code === 'string';
}
exports.isErrnoException = isErrnoException;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function errorToString(error) {
export function errorToString(error) {
if (!error) {

@@ -27,3 +23,2 @@ return '';

}
exports.errorToString = errorToString;
//# sourceMappingURL=errors.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findUnserializables = void 0;
const not_empty_1 = require("./not-empty");
function findUnserializables(thing) {
import { notEmpty } from './not-empty.js';
export function findUnserializables(thing) {
switch (typeof thing) {

@@ -36,3 +33,3 @@ case 'number':

})
.filter(not_empty_1.notEmpty);
.filter(notEmpty);
return things.length ? things : undefined;

@@ -50,3 +47,3 @@ }

})
.filter(not_empty_1.notEmpty);
.filter(notEmpty);
return things.length ? things : undefined;

@@ -63,3 +60,2 @@ }

}
exports.findUnserializables = findUnserializables;
//# sourceMappingURL=find-unserializables.js.map

@@ -1,7 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatMap = void 0;
const tslib_1 = require("tslib");
const lodash_flatmap_1 = (0, tslib_1.__importDefault)(require("lodash.flatmap"));
exports.flatMap = lodash_flatmap_1.default;
import flatMap from 'lodash.flatmap';
/**
* `Array.prototype.flatMap`, but also works on node 10
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap
*/
export { flatMap };
//# sourceMappingURL=flat-map.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=i.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepFreeze = void 0;
function deepFreeze(target) {
export function deepFreeze(target) {
switch (typeof target) {

@@ -32,3 +29,2 @@ case 'object':

}
exports.deepFreeze = deepFreeze;
//# sourceMappingURL=immutable.js.map

@@ -1,17 +0,17 @@

export { childProcessAsPromised } from './child-process-as-promised';
export { StrykerError } from './stryker-error';
export * from './errors';
export * from './immutable';
export * from './known-keys';
export * from './string-utils';
export * from './noop-logger';
export * from './not-empty';
export * from './flat-map';
export * from './i';
export * from './task';
export * from './directory-require-cache';
export * from './require-resolve';
export * from './deep-merge';
export * from './find-unserializables';
export * from './platform';
export { childProcessAsPromised } from './child-process-as-promised.js';
export { StrykerError } from './stryker-error.js';
export * from './errors.js';
export * from './immutable.js';
export * from './known-keys.js';
export * from './string-utils.js';
export * from './noop-logger.js';
export * from './not-empty.js';
export * from './flat-map.js';
export * from './i.js';
export * from './task.js';
export * from './directory-require-cache.js';
export * from './require-resolve.js';
export * from './deep-merge.js';
export * from './find-unserializables.js';
export * from './platform.js';
//# sourceMappingURL=index.d.ts.map

@@ -1,23 +0,17 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrykerError = exports.childProcessAsPromised = void 0;
const tslib_1 = require("tslib");
var child_process_as_promised_1 = require("./child-process-as-promised");
Object.defineProperty(exports, "childProcessAsPromised", { enumerable: true, get: function () { return child_process_as_promised_1.childProcessAsPromised; } });
var stryker_error_1 = require("./stryker-error");
Object.defineProperty(exports, "StrykerError", { enumerable: true, get: function () { return stryker_error_1.StrykerError; } });
(0, tslib_1.__exportStar)(require("./errors"), exports);
(0, tslib_1.__exportStar)(require("./immutable"), exports);
(0, tslib_1.__exportStar)(require("./known-keys"), exports);
(0, tslib_1.__exportStar)(require("./string-utils"), exports);
(0, tslib_1.__exportStar)(require("./noop-logger"), exports);
(0, tslib_1.__exportStar)(require("./not-empty"), exports);
(0, tslib_1.__exportStar)(require("./flat-map"), exports);
(0, tslib_1.__exportStar)(require("./i"), exports);
(0, tslib_1.__exportStar)(require("./task"), exports);
(0, tslib_1.__exportStar)(require("./directory-require-cache"), exports);
(0, tslib_1.__exportStar)(require("./require-resolve"), exports);
(0, tslib_1.__exportStar)(require("./deep-merge"), exports);
(0, tslib_1.__exportStar)(require("./find-unserializables"), exports);
(0, tslib_1.__exportStar)(require("./platform"), exports);
export { childProcessAsPromised } from './child-process-as-promised.js';
export { StrykerError } from './stryker-error.js';
export * from './errors.js';
export * from './immutable.js';
export * from './known-keys.js';
export * from './string-utils.js';
export * from './noop-logger.js';
export * from './not-empty.js';
export * from './flat-map.js';
export * from './i.js';
export * from './task.js';
export * from './directory-require-cache.js';
export * from './require-resolve.js';
export * from './deep-merge.js';
export * from './find-unserializables.js';
export * from './platform.js';
//# sourceMappingURL=index.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=known-keys.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noopLogger = void 0;
exports.noopLogger = {
export const noopLogger = {
isTraceEnabled() {

@@ -6,0 +3,0 @@ return false;

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.notEmpty = void 0;
function notEmpty(item) {
export function notEmpty(item) {
return item !== undefined && item !== null;
}
exports.notEmpty = notEmpty;
//# sourceMappingURL=not-empty.js.map

@@ -1,7 +0,9 @@

/**
* Tells whether the filesystem is case sensitive.
*
* @returns false on Win32, true elsewhere
*/
export declare function caseSensitiveFs(): boolean;
export declare const platform: {
/**
* Tells whether the filesystem is case sensitive.
*
* @returns false on Win32, true elsewhere
*/
caseSensitiveFs(): boolean;
};
//# sourceMappingURL=platform.d.ts.map

@@ -1,13 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.caseSensitiveFs = void 0;
/**
* Tells whether the filesystem is case sensitive.
*
* @returns false on Win32, true elsewhere
*/
function caseSensitiveFs() {
return process.platform != 'win32';
}
exports.caseSensitiveFs = caseSensitiveFs;
export const platform = {
/**
* Tells whether the filesystem is case sensitive.
*
* @returns false on Win32, true elsewhere
*/
caseSensitiveFs() {
return process.platform != 'win32';
},
};
//# sourceMappingURL=platform.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=primitive.js.map

@@ -1,4 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.requireResolve = void 0;
import { createRequire } from 'module';
/**

@@ -8,7 +6,6 @@ * Require a module from the current working directory (or a different base dir)

*/
function requireResolve(id, from = process.cwd()) {
// eslint-disable-next-line @typescript-eslint/no-require-imports
export function requireResolve(id, from = process.cwd()) {
const require = createRequire(import.meta.url);
return require(require.resolve(id, { paths: [from] }));
}
exports.requireResolve = requireResolve;
//# sourceMappingURL=require-resolve.js.map

@@ -9,2 +9,7 @@ import { KnownKeys } from './known-keys';

export declare function normalizeWhitespaces(str: string): string;
export interface PropertyPathOverloads<T> {
(key: KnownKeys<T>): string;
<TProp1 extends KnownKeys<T>>(key: TProp1, key2: KnownKeys<OnlyObject<T[TProp1]>>): string;
<TProp1 extends KnownKeys<T>, TProp2 extends KnownKeys<OnlyObject<T[TProp1]>>>(key: TProp1, key2: TProp2, key3: KnownKeys<OnlyObject<OnlyObject<T[TProp1]>[TProp2]>>): string;
}
/**

@@ -14,25 +19,4 @@ * Given a base type, allows type safe access to the name of a property.

*/
export declare function propertyPath<T>(prop: KnownKeys<T>): string;
export declare function propertyPath<T>(): PropertyPathOverloads<T>;
/**
* A helper class to allow you to get type safe access to the name of a deep property of `T`
* @example
* ```ts
* PropertyPathBuilder<StrykerOptions>('warnings').prop('unknownOptions').build()
* ```
*/
export declare class PropertyPathBuilder<T> {
private readonly pathSoFar;
constructor(pathSoFar: string[]);
prop<TProp extends KnownKeys<OnlyObject<T>> & keyof OnlyObject<T>>(prop: TProp): PropertyPathBuilder<Pick<OnlyObject<T>, TProp>[TProp]>;
/**
* Build the (deep) path to the property name
*/
build(): string;
/**
* Creates a new `PropertyPathBuilder` for type T
*/
static create<K>(): PropertyPathBuilder<K>;
toString(): string;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping

@@ -39,0 +23,0 @@ */

@@ -1,4 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeRegExp = exports.escapeRegExpLiteral = exports.PropertyPathBuilder = exports.propertyPath = exports.normalizeWhitespaces = void 0;
/**

@@ -8,6 +5,5 @@ * Consolidates multiple consecutive white spaces into a single space.

*/
function normalizeWhitespaces(str) {
export function normalizeWhitespaces(str) {
return str.replace(/\s+/g, ' ').trim();
}
exports.normalizeWhitespaces = normalizeWhitespaces;
/**

@@ -17,51 +13,18 @@ * Given a base type, allows type safe access to the name of a property.

*/
function propertyPath(prop) {
return String(prop);
export function propertyPath() {
const fn = ((...args) => args.join('.'));
return fn;
}
exports.propertyPath = propertyPath;
/**
* A helper class to allow you to get type safe access to the name of a deep property of `T`
* @example
* ```ts
* PropertyPathBuilder<StrykerOptions>('warnings').prop('unknownOptions').build()
* ```
*/
class PropertyPathBuilder {
constructor(pathSoFar) {
this.pathSoFar = pathSoFar;
}
prop(prop) {
return new PropertyPathBuilder([...this.pathSoFar, prop.toString()]);
}
/**
* Build the (deep) path to the property name
*/
build() {
return this.pathSoFar.join('.');
}
/**
* Creates a new `PropertyPathBuilder` for type T
*/
static create() {
return new PropertyPathBuilder([]);
}
toString() {
return this.build();
}
}
exports.PropertyPathBuilder = PropertyPathBuilder;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
*/
function escapeRegExpLiteral(input) {
export function escapeRegExpLiteral(input) {
return input.replace(/[.*+\-?^${}()|[\]\\/]/g, '\\$&'); // $& means the whole matched string
}
exports.escapeRegExpLiteral = escapeRegExpLiteral;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
*/
function escapeRegExp(input) {
export function escapeRegExp(input) {
return input.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
exports.escapeRegExp = escapeRegExp;
//# sourceMappingURL=string-utils.js.map

@@ -1,12 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrykerError = void 0;
const errors_1 = require("./errors");
class StrykerError extends Error {
import { errorToString } from './errors.js';
export class StrykerError extends Error {
constructor(message, innerError) {
super(`${message}${innerError ? `. Inner error: ${(0, errors_1.errorToString)(innerError)}` : ''}`);
super(`${message}${innerError ? `. Inner error: ${errorToString(innerError)}` : ''}`);
this.innerError = innerError;
}
}
exports.StrykerError = StrykerError;
//# sourceMappingURL=stryker-error.js.map

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpirableTask = exports.Task = void 0;
/**
* Wraps a promise in a Task api for convenience.
*/
class Task {
export class Task {
constructor() {

@@ -30,7 +27,6 @@ this._isCompleted = false;

}
exports.Task = Task;
/**
* A task that can expire after the given time.
*/
class ExpirableTask extends Task {
export class ExpirableTask extends Task {
constructor(timeoutMS) {

@@ -56,4 +52,3 @@ super();

}
exports.ExpirableTask = ExpirableTask;
ExpirableTask.TimeoutExpired = Symbol('TimeoutExpired');
//# sourceMappingURL=task.js.map
{
"name": "@stryker-mutator/util",
"version": "5.6.1",
"version": "6.0.0-beta.0",
"description": "Contains utilities for Stryker, the mutation testing framework for JavaScript and friends",
"main": "dist/src/index.js",
"type": "module",
"scripts": {
"test": "nyc npm run test:all",
"test": "c8 npm run test:all",
"test:all": "npm run test:unit && npm run test:integration",
"test:unit": "mocha \"dist/test/unit/**/*.js\"",
"test:integration": "mocha \"dist/test/integration/**/*.js\"",
"stryker": "node ../core/bin/stryker run"
"stryker": "node ../core/bin/stryker.js run"
},

@@ -32,3 +33,3 @@ "repository": {

"devDependencies": {
"@stryker-mutator/test-helpers": "5.6.1",
"@stryker-mutator/test-helpers": "6.0.0-beta.0",
"@types/lodash.flatmap": "~4.5.6",

@@ -40,3 +41,3 @@ "@types/node": "^17.0.0"

},
"gitHead": "4eb804dd016fc1d1637a77a9b9a26c5a03ff2a6b"
"gitHead": "f0d58792aed18aa58f41c67668bfabcc66bdd302"
}

@@ -12,1 +12,3 @@ [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fstryker-mutator%2Fstryker-js%2Fmaster%3Fmodule%3Dutil)](https://dashboard.stryker-mutator.io/reports/github.com/stryker-mutator/stryker-js/master?module=util)

Utility functions for StrykerJS plugins and/or core packages.
Note: this is not designed to be for use outside of the StrykerJS ecosystem and thus does **NOT follow strict semver**. Use at your own risk.

@@ -0,6 +1,9 @@

import { createRequire } from 'module';
import path from 'path';
import { notEmpty } from './not-empty';
import { caseSensitiveFs } from './platform';
import { notEmpty } from './not-empty.js';
import { platform } from './platform.js';
const require = createRequire(import.meta.url);
/**

@@ -28,3 +31,3 @@ * A helper class that can be used by test runners.

const startsWithCaseSensitive = (filename: string, prefix: string) => filename.startsWith(prefix);
const startsWith = caseSensitiveFs() ? startsWithCaseSensitive : startsWithCaseInsensitive;
const startsWith = platform.caseSensitiveFs() ? startsWithCaseSensitive : startsWithCaseInsensitive;
Object.keys(require.cache)

@@ -31,0 +34,0 @@ .filter((fileName) => startsWith(fileName, `${cwd}${path.sep}`) && !startsWith(fileName, path.join(cwd, 'node_modules')))

@@ -1,2 +0,2 @@

import { notEmpty } from './not-empty';
import { notEmpty } from './not-empty.js';

@@ -3,0 +3,0 @@ export interface UnserializableDescription {

@@ -1,16 +0,16 @@

export { childProcessAsPromised } from './child-process-as-promised';
export { StrykerError } from './stryker-error';
export * from './errors';
export * from './immutable';
export * from './known-keys';
export * from './string-utils';
export * from './noop-logger';
export * from './not-empty';
export * from './flat-map';
export * from './i';
export * from './task';
export * from './directory-require-cache';
export * from './require-resolve';
export * from './deep-merge';
export * from './find-unserializables';
export * from './platform';
export { childProcessAsPromised } from './child-process-as-promised.js';
export { StrykerError } from './stryker-error.js';
export * from './errors.js';
export * from './immutable.js';
export * from './known-keys.js';
export * from './string-utils.js';
export * from './noop-logger.js';
export * from './not-empty.js';
export * from './flat-map.js';
export * from './i.js';
export * from './task.js';
export * from './directory-require-cache.js';
export * from './require-resolve.js';
export * from './deep-merge.js';
export * from './find-unserializables.js';
export * from './platform.js';

@@ -1,8 +0,10 @@

/**
* Tells whether the filesystem is case sensitive.
*
* @returns false on Win32, true elsewhere
*/
export function caseSensitiveFs(): boolean {
return process.platform != 'win32';
}
export const platform = {
/**
* Tells whether the filesystem is case sensitive.
*
* @returns false on Win32, true elsewhere
*/
caseSensitiveFs(): boolean {
return process.platform != 'win32';
},
};

@@ -0,1 +1,3 @@

import { createRequire } from 'module';
/**

@@ -6,4 +8,4 @@ * Require a module from the current working directory (or a different base dir)

export function requireResolve(id: string, from = process.cwd()): unknown {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const require = createRequire(import.meta.url);
return require(require.resolve(id, { paths: [from] }));
}

@@ -14,2 +14,12 @@ import { KnownKeys } from './known-keys';

export interface PropertyPathOverloads<T> {
(key: KnownKeys<T>): string;
<TProp1 extends KnownKeys<T>>(key: TProp1, key2: KnownKeys<OnlyObject<T[TProp1]>>): string;
<TProp1 extends KnownKeys<T>, TProp2 extends KnownKeys<OnlyObject<T[TProp1]>>>(
key: TProp1,
key2: TProp2,
key3: KnownKeys<OnlyObject<OnlyObject<T[TProp1]>[TProp2]>>
): string;
}
/**

@@ -19,40 +29,8 @@ * Given a base type, allows type safe access to the name of a property.

*/
export function propertyPath<T>(prop: KnownKeys<T>): string {
return String(prop);
export function propertyPath<T>(): PropertyPathOverloads<T> {
const fn: PropertyPathOverloads<T> = ((...args: string[]) => args.join('.')) as unknown as PropertyPathOverloads<T>;
return fn;
}
/**
* A helper class to allow you to get type safe access to the name of a deep property of `T`
* @example
* ```ts
* PropertyPathBuilder<StrykerOptions>('warnings').prop('unknownOptions').build()
* ```
*/
export class PropertyPathBuilder<T> {
constructor(private readonly pathSoFar: string[]) {}
public prop<TProp extends KnownKeys<OnlyObject<T>> & keyof OnlyObject<T>>(prop: TProp): PropertyPathBuilder<Pick<OnlyObject<T>, TProp>[TProp]> {
return new PropertyPathBuilder<Pick<OnlyObject<T>, TProp>[TProp]>([...this.pathSoFar, prop.toString()]);
}
/**
* Build the (deep) path to the property name
*/
public build(): string {
return this.pathSoFar.join('.');
}
/**
* Creates a new `PropertyPathBuilder` for type T
*/
public static create<K>(): PropertyPathBuilder<K> {
return new PropertyPathBuilder<K>([]);
}
public toString(): string {
return this.build();
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping

@@ -59,0 +37,0 @@ */

@@ -1,2 +0,2 @@

import { errorToString } from './errors';
import { errorToString } from './errors.js';

@@ -3,0 +3,0 @@ export class StrykerError extends Error {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc