@augment-vir/common 31.54.2 → 31.54.4

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.
@@ -23,7 +23,7 @@ import { type OptionalKeysOf, type RequiredKeysOf } from 'type-fest';
23
23
  export declare function filterObject<ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, callback: (key: keyof ObjectGeneric, value: CompleteValues<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
24
24
  /**
25
25
  * Converts any optionally `undefined` keys to partials with non-undefined values. This does not
26
- * exclude `null`.
26
+ * exclude `null` (but {@link RemoveNullishValues} does).
27
27
  *
28
28
  * @category Object
29
29
  * @category Package : @augment-vir/common
@@ -34,6 +34,18 @@ export type RemoveUndefinedValues<ObjectGeneric> = {
34
34
  } & {
35
35
  [Key in ExtractKeysWithMatchingValues<ObjectGeneric, undefined>]?: Exclude<ObjectGeneric[Key], undefined>;
36
36
  };
37
+ /**
38
+ * Converts any optionally `undefined` or `null` keys to partials with non-nullable values.
39
+ *
40
+ * @category Object
41
+ * @category Package : @augment-vir/common
42
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
43
+ */
44
+ export type RemoveNullishValues<ObjectGeneric> = {
45
+ [Key in ExcludeKeysWithMatchingValues<ObjectGeneric, undefined | null>]: ObjectGeneric[Key];
46
+ } & {
47
+ [Key in ExtractKeysWithMatchingValues<ObjectGeneric, undefined | null>]?: NonNullable<ObjectGeneric[Key]>;
48
+ };
37
49
  /**
38
50
  * Converts any `undefined` values into `null`.
39
51
  *
@@ -66,6 +78,14 @@ export type ReplaceNullValuesWithUndefined<ObjectGeneric> = {
66
78
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
67
79
  */
68
80
  export declare function removeUndefinedValues<ObjectGeneric>(input: Readonly<ObjectGeneric>): RemoveUndefinedValues<ObjectGeneric>;
81
+ /**
82
+ * Removes keys for values that are `undefined` or `null`.
83
+ *
84
+ * @category Object
85
+ * @category Package : @augment-vir/common
86
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
87
+ */
88
+ export declare function removeNullishValues<ObjectGeneric>(input: Readonly<ObjectGeneric>): RemoveNullishValues<ObjectGeneric>;
69
89
  /**
70
90
  * Replaces all `undefined` values with `null`.
71
91
  *
@@ -40,7 +40,30 @@ export function removeUndefinedValues(input) {
40
40
  return undefined;
41
41
  }
42
42
  else {
43
- return { key, value };
43
+ return {
44
+ key,
45
+ value,
46
+ };
47
+ }
48
+ });
49
+ }
50
+ /**
51
+ * Removes keys for values that are `undefined` or `null`.
52
+ *
53
+ * @category Object
54
+ * @category Package : @augment-vir/common
55
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
56
+ */
57
+ export function removeNullishValues(input) {
58
+ return mapObject(input, (key, value) => {
59
+ if (value == undefined) {
60
+ return undefined;
61
+ }
62
+ else {
63
+ return {
64
+ key,
65
+ value,
66
+ };
44
67
  }
45
68
  });
46
69
  }
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Sanitize a file path for use within Linux, macOS, or Windows file systems.
2
+ * Sanitize a file name for use within Linux, macOS, or Windows file systems. This removes all file
3
+ * path separators. If you wish to retain the separators, split the path parts up before using this
4
+ * function.
3
5
  *
4
6
  * @category Path : Common
5
7
  * @category Package : @augment-vir/common
6
8
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
7
9
  */
8
- export declare function sanitizeFilePath(original: string | null | undefined): string | undefined;
10
+ export declare function sanitizeFileName(original: string | null | undefined): string | undefined;
@@ -6,20 +6,21 @@ import { safeSplit } from '../string/split.js';
6
6
  import { collapseWhiteSpace } from '../string/white-space.js';
7
7
  import { extractExtension } from './universal-path.js';
8
8
  /**
9
- * Sanitize a file path for use within Linux, macOS, or Windows file systems.
9
+ * Sanitize a file name for use within Linux, macOS, or Windows file systems. This removes all file
10
+ * path separators. If you wish to retain the separators, split the path parts up before using this
11
+ * function.
10
12
  *
11
13
  * @category Path : Common
12
14
  * @category Package : @augment-vir/common
13
15
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
14
16
  */
15
- export function sanitizeFilePath(original) {
17
+ export function sanitizeFileName(original) {
16
18
  if (!original) {
17
19
  return undefined;
18
20
  }
19
- const sanitized = sanitizeFileName(collapseWhiteSpace(original)
21
+ const sanitized = rawSanitize(collapseWhiteSpace(original)
20
22
  .replaceAll(' ', '_')
21
- /** This ESLint error is wrong. */
22
- .replaceAll(/['()*"![\]{}\s?=&<>:/\-\\|]/g, '_')
23
+ .replaceAll(/[',()*"![\]{}\s?=&<>:/\-\\|]/g, '_')
23
24
  .replaceAll(/_{2,}/g, '_')
24
25
  .replace(/_$/, '')
25
26
  .replace(/\.$/, '')
@@ -50,7 +51,7 @@ const illegalRe = /[/?<>\\:*|"]/g;
50
51
  const controlRe = /[\x00-\x1f\x80-\x9f]/g;
51
52
  const reservedRe = /^\.+$/;
52
53
  const windowsReservedRe = /^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i;
53
- function internalSanitizeFileName(input, replacement) {
54
+ function internalRawSanitize(input, replacement) {
54
55
  /**
55
56
  * These as casts are necessary because `.replace` is not typed correctly in the TypeScript
56
57
  * library.
@@ -64,8 +65,8 @@ function internalSanitizeFileName(input, replacement) {
64
65
  .replace(windowsReservedRe, replacement);
65
66
  return truncate(sanitized, 255);
66
67
  }
67
- function sanitizeFileName(input, { replacement, } = {}) {
68
- return internalSanitizeFileName(internalSanitizeFileName(input, replacement || ''), '');
68
+ function rawSanitize(input, { replacement, } = {}) {
69
+ return internalRawSanitize(internalRawSanitize(input, replacement || ''), '');
69
70
  }
70
71
  /**
71
72
  * The following code is copied from the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "31.54.2",
3
+ "version": "31.54.4",
4
4
  "description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",
5
5
  "keywords": [
6
6
  "augment",
@@ -40,13 +40,13 @@
40
40
  "test:web": "virmator --no-deps test web"
41
41
  },
42
42
  "dependencies": {
43
- "@augment-vir/assert": "^31.54.2",
44
- "@augment-vir/core": "^31.54.2",
45
- "@date-vir/duration": "^8.0.0",
43
+ "@augment-vir/assert": "^31.54.4",
44
+ "@augment-vir/core": "^31.54.4",
45
+ "@date-vir/duration": "^8.1.0",
46
46
  "ansi-styles": "^6.2.3",
47
47
  "deepcopy-esm": "^2.1.1",
48
48
  "json5": "^2.2.3",
49
- "type-fest": "^5.2.0",
49
+ "type-fest": "^5.3.1",
50
50
  "typed-event-target": "^4.1.0"
51
51
  },
52
52
  "devDependencies": {
@@ -57,7 +57,7 @@
57
57
  "@web/test-runner-visual-regression": "^0.10.0",
58
58
  "execute-in-browser": "^1.0.9",
59
59
  "istanbul-smart-text-reporter": "^1.1.5",
60
- "runstorm": "^0.6.2",
60
+ "runstorm": "^1.0.0",
61
61
  "typescript": "^5.9.3"
62
62
  },
63
63
  "engines": {