@ntnyq/utils 0.4.0 → 0.4.1

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/README.md CHANGED
@@ -10,18 +10,22 @@
10
10
 
11
11
  ## Install
12
12
 
13
- ```bash
13
+ ```shell
14
14
  npm install @ntnyq/utils
15
15
  ```
16
16
 
17
- ```bash
17
+ ```shell
18
18
  yarn add @ntnyq/utils
19
19
  ```
20
20
 
21
- ```bash
21
+ ```shell
22
22
  pnpm add @ntnyq/utils
23
23
  ```
24
24
 
25
+ ## Credits
26
+
27
+ - [antfu/utils](https://github.com/antfu/utils)
28
+
25
29
  ## License
26
30
 
27
31
  [MIT](./LICENSE) License © 2024-PRESENT [ntnyq](https://github.com/ntnyq)
package/dist/index.cjs CHANGED
@@ -406,10 +406,10 @@ function unindent(input) {
406
406
  const lines = (typeof input === "string" ? input : input[0]).split("\n");
407
407
  const whitespaceLines = lines.map((line) => _RE_FULL_WS.test(line));
408
408
  const commonIndent = lines.reduce((min, line, idx) => {
409
- if (!whitespaceLines[idx]) {
409
+ if (whitespaceLines[idx]) {
410
410
  return min;
411
411
  }
412
- const indent = line.match(/^\s/)?.[0].length;
412
+ const indent = line.match(/^\s*/)?.[0].length;
413
413
  return indent === void 0 ? min : Math.min(min, indent);
414
414
  }, Number.POSITIVE_INFINITY);
415
415
  let emptylinesHead = 0;
package/dist/index.d.cts CHANGED
@@ -246,7 +246,7 @@ declare function join(array: JoinableValue[], options?: JoinOptions): string;
246
246
  declare function slash(input: string): string;
247
247
 
248
248
  /**
249
- * Remove leading whitespace from a template string
249
+ * Remove common leading whitespace from a template string
250
250
  * Empty lines at the beginning and end of the template string are also removed.
251
251
  * @param input - template string
252
252
  *
package/dist/index.d.ts CHANGED
@@ -246,7 +246,7 @@ declare function join(array: JoinableValue[], options?: JoinOptions): string;
246
246
  declare function slash(input: string): string;
247
247
 
248
248
  /**
249
- * Remove leading whitespace from a template string
249
+ * Remove common leading whitespace from a template string
250
250
  * Empty lines at the beginning and end of the template string are also removed.
251
251
  * @param input - template string
252
252
  *
package/dist/index.js CHANGED
@@ -308,10 +308,10 @@ function unindent(input) {
308
308
  const lines = (typeof input === "string" ? input : input[0]).split("\n");
309
309
  const whitespaceLines = lines.map((line) => _RE_FULL_WS.test(line));
310
310
  const commonIndent = lines.reduce((min, line, idx) => {
311
- if (!whitespaceLines[idx]) {
311
+ if (whitespaceLines[idx]) {
312
312
  return min;
313
313
  }
314
- const indent = line.match(/^\s/)?.[0].length;
314
+ const indent = line.match(/^\s*/)?.[0].length;
315
315
  return indent === void 0 ? min : Math.min(min, indent);
316
316
  }, Number.POSITIVE_INFINITY);
317
317
  let emptylinesHead = 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ntnyq/utils",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "Common used utils.",
6
6
  "keywords": [
7
7
  "utils"