@bhsd/common 2.2.0 → 2.2.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/dist/index.d.ts CHANGED
@@ -74,6 +74,7 @@ export declare const lintJSONC: (str: string) => JsonError[];
74
74
  /**
75
75
  * 获取字符串开头的空白字符数量
76
76
  * @param str 字符串
77
+ * @param re 其他正则表达式,默认为匹配非空白字符的正则表达式
77
78
  */
78
- export declare const numLeadingSpaces: (str: string) => number;
79
+ export declare const numLeadingSpaces: (str: string, re?: RegExp) => number;
79
80
  export {};
package/dist/index.js CHANGED
@@ -171,5 +171,6 @@ export const lintJSONC = (str) => str.trim() ? lintJSONBase(str, jsonc_parse) :
171
171
  /**
172
172
  * 获取字符串开头的空白字符数量
173
173
  * @param str 字符串
174
+ * @param re 其他正则表达式,默认为匹配非空白字符的正则表达式
174
175
  */
175
- export const numLeadingSpaces = (str) => str.search(/\S|$/u);
176
+ export const numLeadingSpaces = (str, re = /\S|$/u) => str.search(re);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/common",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "homepage": "https://github.com/bhsd-harry/common#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/bhsd-harry/common/issues"
@@ -24,7 +24,7 @@
24
24
  "test": "mocha"
25
25
  },
26
26
  "devDependencies": {
27
- "@bhsd/code-standard": "^2.4.0",
27
+ "@bhsd/code-standard": "^2.4.1",
28
28
  "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
29
29
  "@stylistic/eslint-plugin": "^5.10.0",
30
30
  "@types/mocha": "^10.0.10",