@augment-vir/common 31.55.0 → 31.57.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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Trim all lines within a string and keep it a string.
3
+ *
4
+ * @category String
5
+ * @category Package : @augment-vir/common
6
+ * @example
7
+ *
8
+ * ```ts
9
+ * import {trimLines} from '@augment-vir/common';
10
+ *
11
+ * const result = trimLines(' hi \n bye \n\n abc'); // 'hi\nbye\nabc'
12
+ * ```
13
+ *
14
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
15
+ */
16
+ export declare function trimLines(value: string): string;
17
+ /**
18
+ * Split a string by newline and trim each line.
19
+ *
20
+ * @category String
21
+ * @category Package : @augment-vir/common
22
+ * @example
23
+ *
24
+ * ```ts
25
+ * import {trimLines} from '@augment-vir/common';
26
+ *
27
+ * const result = trimAndSplitLines(' hi \n bye \n\n abc'); // ['hi', 'bye', 'abc']
28
+ * ```
29
+ *
30
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
31
+ */
32
+ export declare function trimAndSplitLines(value: string): string[];
@@ -0,0 +1,38 @@
1
+ import { check } from '@augment-vir/assert';
2
+ import { filterMap } from '../array/filter.js';
3
+ /**
4
+ * Trim all lines within a string and keep it a string.
5
+ *
6
+ * @category String
7
+ * @category Package : @augment-vir/common
8
+ * @example
9
+ *
10
+ * ```ts
11
+ * import {trimLines} from '@augment-vir/common';
12
+ *
13
+ * const result = trimLines(' hi \n bye \n\n abc'); // 'hi\nbye\nabc'
14
+ * ```
15
+ *
16
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
17
+ */
18
+ export function trimLines(value) {
19
+ return trimAndSplitLines(value).join('\n').trim();
20
+ }
21
+ /**
22
+ * Split a string by newline and trim each line.
23
+ *
24
+ * @category String
25
+ * @category Package : @augment-vir/common
26
+ * @example
27
+ *
28
+ * ```ts
29
+ * import {trimLines} from '@augment-vir/common';
30
+ *
31
+ * const result = trimAndSplitLines(' hi \n bye \n\n abc'); // ['hi', 'bye', 'abc']
32
+ * ```
33
+ *
34
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
35
+ */
36
+ export function trimAndSplitLines(value) {
37
+ return filterMap(value.trim().split('\n'), (line) => line.trim(), check.isTruthy);
38
+ }
package/dist/index.d.ts CHANGED
@@ -84,6 +84,7 @@ export * from './augments/string/casing/kebab-and-camel.js';
84
84
  export * from './augments/string/comma.js';
85
85
  export * from './augments/string/join.js';
86
86
  export * from './augments/string/length.js';
87
+ export * from './augments/string/lines.js';
87
88
  export * from './augments/string/prefix.js';
88
89
  export * from './augments/string/replace.js';
89
90
  export * from './augments/string/split.js';
package/dist/index.js CHANGED
@@ -84,6 +84,7 @@ export * from './augments/string/casing/kebab-and-camel.js';
84
84
  export * from './augments/string/comma.js';
85
85
  export * from './augments/string/join.js';
86
86
  export * from './augments/string/length.js';
87
+ export * from './augments/string/lines.js';
87
88
  export * from './augments/string/prefix.js';
88
89
  export * from './augments/string/replace.js';
89
90
  export * from './augments/string/split.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "31.55.0",
3
+ "version": "31.57.0",
4
4
  "description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",
5
5
  "keywords": [
6
6
  "augment",
@@ -40,8 +40,8 @@
40
40
  "test:web": "virmator --no-deps test web"
41
41
  },
42
42
  "dependencies": {
43
- "@augment-vir/assert": "^31.55.0",
44
- "@augment-vir/core": "^31.55.0",
43
+ "@augment-vir/assert": "^31.57.0",
44
+ "@augment-vir/core": "^31.57.0",
45
45
  "@date-vir/duration": "^8.1.0",
46
46
  "ansi-styles": "^6.2.3",
47
47
  "deepcopy-esm": "^2.1.1",