a-js-tools 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -9,13 +9,15 @@
9
9
  npm install a-js-tools --save
10
10
  ```
11
11
 
12
- ## pure function
12
+ ## 纯函数
13
13
 
14
14
  - `lmDebounce` 防抖函数
15
15
  - `lmThrottle` 节流函数
16
16
  - `getRandomInt` 获取随机的整数
17
17
  - `getRandomFloat` 获取随机的浮点数
18
18
  - `getRandomString` 获取随机字符串
19
+ - `escapeRegExp` 转义字符串为简单的正则表达式
20
+ - `autoEscapedRegExp` 生成简单的正则表达式
19
21
 
20
22
  ## class 名称转化
21
23
 
package/cjs/index.cjs CHANGED
@@ -4,6 +4,8 @@ var getRandomNumber = require('./src/getRandomNumber.cjs');
4
4
  var className = require('./src/className.cjs');
5
5
  var getRandomString = require('./src/getRandomString.cjs');
6
6
  var performance = require('./src/performance.cjs');
7
+ var escapeRegExp = require('./src/regexp/escapeRegExp.cjs');
8
+ var autoEscapedRegExp = require('./src/regexp/autoEscapedRegExp.cjs');
7
9
 
8
10
 
9
11
 
@@ -14,3 +16,5 @@ exports.toSplitCase = className.toSplitCase;
14
16
  exports.getRandomString = getRandomString.getRandomString;
15
17
  exports.debounce = performance.debounce;
16
18
  exports.throttle = performance.throttle;
19
+ exports.escapeRegExp = escapeRegExp.escapeRegExp;
20
+ exports.autoEscapedRegExp = autoEscapedRegExp.autoEscapedRegExp;
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var aTypeOfJs = require('a-type-of-js');
4
- var crypto$1 = require('crypto');
5
4
 
6
5
  /**
7
6
  * 获取随机字符串
@@ -12,30 +11,34 @@ var crypto$1 = require('crypto');
12
11
  */
13
12
  /**
14
13
  *
15
- * 获取随机字符串
14
+ * 获取简单的随机字符串
16
15
  *
17
- * @param length - 字符串长度
16
+ * @param options - 字符串长度
18
17
  * @returns - 随机字符串
19
18
  *
20
19
  *
21
20
  */
22
- function getRandomString(length) {
21
+ function getRandomString(options) {
23
22
  // 验证输入参数
24
23
  if (
25
24
  // 参数类型错误
26
- (!aTypeOfJs.isPlainObject(length) && !aTypeOfJs.isNumber(length)) ||
25
+ (!aTypeOfJs.isPlainObject(options) && !aTypeOfJs.isNumber(options)) ||
27
26
  // 参数为 NaN
28
- (aTypeOfJs.isNumber(length) && aTypeOfJs.isNaN(length)) ||
27
+ (aTypeOfJs.isNumber(options) && aTypeOfJs.isNaN(options)) ||
29
28
  // 参数为数字时为无穷大
30
- (aTypeOfJs.isNumber(length) && !isFinite(length)) ||
29
+ (aTypeOfJs.isNumber(options) && !isFinite(options)) ||
31
30
  // 参数为数字时为非整数
32
- (aTypeOfJs.isNumber(length) && !Number.isInteger(length)) ||
31
+ (aTypeOfJs.isNumber(options) && !Number.isInteger(options)) ||
33
32
  // 参数为数字时为负数
34
- (aTypeOfJs.isNumber(length) && Number.isInteger(length) && length < 1) ||
33
+ (aTypeOfJs.isNumber(options) && Number.isInteger(options) && options < 1) ||
35
34
  // 参数为数值然而却小于 1
36
- (aTypeOfJs.isNumber(length) && length < 1) ||
37
- (aTypeOfJs.isPlainObject(length) && aTypeOfJs.isNumber(length.length) && length.length < 1)) {
38
- throw new TypeError('Invalid argument type (getRandomString)');
35
+ (aTypeOfJs.isNumber(options) && options < 1) ||
36
+ // 参数为对象但是 length 属性非数值
37
+ (aTypeOfJs.isPlainObject(options) &&
38
+ (!aTypeOfJs.isNumber(options.length) ||
39
+ options.length < 1 ||
40
+ !Number.isInteger(options.length)))) {
41
+ throw new TypeError('参数类型错误 ❌ (getRandomString)');
39
42
  }
40
43
  const initOptions = {
41
44
  length: 32,
@@ -51,12 +54,12 @@ function getRandomString(length) {
51
54
  if (initOptions.type === 'uuid') {
52
55
  return crypto.randomUUID();
53
56
  }
54
- if (aTypeOfJs.isNumber(length) && Number.isInteger(length) && length > 0) {
57
+ if (aTypeOfJs.isNumber(options) && Number.isInteger(options) && options > 0) {
55
58
  // 验证输入参数
56
- Object.assign(initOptions, { length });
59
+ Object.assign(initOptions, { length: options });
57
60
  }
58
- if (aTypeOfJs.isPlainObject(length)) {
59
- Object.assign(initOptions, length);
61
+ if (aTypeOfJs.isPlainObject(options)) {
62
+ Object.assign(initOptions, options);
60
63
  initOptions.length = initOptions.length < 1 ? 32 : initOptions.length;
61
64
  }
62
65
  /** 生成随机字符串 */
@@ -74,7 +77,9 @@ function getRandomString(length) {
74
77
  interleaveString(templateCharsArr, initOptions.chars3);
75
78
  }
76
79
  // 使用密码学安全的随机数生成器
77
- const bytes = crypto$1.randomBytes(initOptions.length);
80
+ const bytes = !aTypeOfJs.isUndefined(window) && window.crypto
81
+ ? window.crypto.getRandomValues(new Uint8Array(initOptions.length))
82
+ : global.crypto.getRandomValues(new Uint8Array(initOptions.length));
78
83
  let result = '';
79
84
  /** 获取最后的 chars 数据 */
80
85
  const chars = templateCharsArr.join('');
@@ -65,7 +65,7 @@ function debounce(callback, delay = 200) {
65
65
  */
66
66
  function throttle(callback, delay = 200) {
67
67
  // 强制转换非数值
68
- if (!isFinite(delay) || (isFinite(delay) && delay < 0))
68
+ if (!isFinite(delay) || (isFinite(delay) && delay < 4))
69
69
  delay = 200;
70
70
  /** 延迟控制插销 */
71
71
  let inThrottle = false;
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+ var escapeRegExp = require('./escapeRegExp.cjs');
5
+ var parse = require('./parse.cjs');
6
+
7
+ /**
8
+ *
9
+ * ## 适用于简单的文本字符串自动转化为简单模式正则表达式
10
+ *
11
+ * *若字符串包含且需保留字符类、组、反向引用、量词等时,该方法可能不适用*
12
+ *
13
+ * @param pattern 待转化的文本字符串
14
+ * @param options 转化选项。 为文本字符串时,默认为正则表达式的标志,还可指定是否匹配开头或结尾
15
+ * @returns 正则表达式
16
+ * @example
17
+ *
18
+ * ```ts
19
+ * import { autoEscapedRegExp } from 'a-regexp';
20
+ *
21
+ * autoEscapedRegExp('abc'); // => /abc/
22
+ * autoEscapedRegExp('abc', 'gim'); // => /abc/gim
23
+ * autoEscapedRegExp('abc', { flags: 'g', start: true }); // => /^abc/g
24
+ * autoEscapedRegExp('abc', { flags: 'g', end: true }); // => /abc$/g
25
+ * autoEscapedRegExp('abc', { start: true, end: true }); // => /^abc$/
26
+ *
27
+ * // 转化特殊字符类、组、反向引用、量词等
28
+ * // 无法保留匹配规则
29
+ * autoEscapedRegExp('a-zA-Z0-9'); // => /a-zA-Z0-9/
30
+ * autoEscapedRegExp('a-zA-Z0-9', 'g'); // => /a-zA-Z0-9/g
31
+ * autoEscapedRegExp('[a-zA-Z0-9]'); // => /\[a-zA-Z0-9\]/
32
+ * autoEscapedRegExp('^[a-zA-Z0-9]+$'); // => /\^\[a-zA-Z0-9\]\$/
33
+ *
34
+ * ```
35
+ *
36
+ */
37
+ function autoEscapedRegExp(pattern, options) {
38
+ if (!aTypeOfJs.isString(pattern)) {
39
+ throw new TypeError('pattern must be a 字符串');
40
+ }
41
+ pattern = escapeRegExp.escapeRegExp(pattern);
42
+ /** 简单转化 */
43
+ if (aTypeOfJs.isUndefined(options)) {
44
+ return new RegExp(pattern);
45
+ }
46
+ options = parse.parse(options);
47
+ return new RegExp(`${options.start ? '^' : ''}${pattern}${options.end ? '$' : ''}`, options.flags);
48
+ }
49
+
50
+ exports.autoEscapedRegExp = autoEscapedRegExp;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ *
5
+ * 将一个字符串转化为符合正则要求的字符串
6
+ *
7
+ * @param str 需要转义的字符串
8
+ * @requires escapeRegExp 转化后字符串
9
+ * @example
10
+ *
11
+ * ```ts
12
+ * import { escapeRegExp } from 'a-js-tools';
13
+ *
14
+ * escapeRegExp('a.b.c'); // 'a\\.b\\.c'
15
+ * escapeRegExp('a\\.b\\.c'); // 'a\\\\.b\\\\.c'
16
+ * escapeRegExp('[a-z]'); // '\\[a-z\\]'
17
+ * escapeRegExp('^abc$'); // '\\^abc\\$'
18
+ * ```
19
+ */
20
+ function escapeRegExp(str) {
21
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
22
+ }
23
+
24
+ exports.escapeRegExp = escapeRegExp;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+
5
+ /**
6
+ *
7
+ * 解析 options
8
+ *
9
+ */
10
+ function parse(options) {
11
+ // 处理 options
12
+ if (aTypeOfJs.isString(options)) {
13
+ options = {
14
+ flags: options,
15
+ };
16
+ }
17
+ // 处理 flags
18
+ if (!aTypeOfJs.isString(options.flags)) {
19
+ options.flags = '';
20
+ }
21
+ else {
22
+ // 需求是保留字符串中的某一部分,使用
23
+ const regexp = /[migsuy]/g;
24
+ const matchResult = options.flags.match(regexp);
25
+ if (aTypeOfJs.isNull(matchResult)) {
26
+ options.flags = '';
27
+ }
28
+ else {
29
+ options.flags = [...new Set(matchResult)].join('');
30
+ }
31
+ }
32
+ return options;
33
+ }
34
+
35
+ exports.parse = parse;
package/mjs/index.mjs CHANGED
@@ -2,3 +2,5 @@ export { getRandomFloat, getRandomInt } from './src/getRandomNumber.mjs';
2
2
  export { toLowerCamelCase, toSplitCase } from './src/className.mjs';
3
3
  export { getRandomString } from './src/getRandomString.mjs';
4
4
  export { debounce, throttle } from './src/performance.mjs';
5
+ export { escapeRegExp } from './src/regexp/escapeRegExp.mjs';
6
+ export { autoEscapedRegExp } from './src/regexp/autoEscapedRegExp.mjs';
@@ -1,5 +1,4 @@
1
- import { isPlainObject, isNumber, isNaN } from 'a-type-of-js';
2
- import { randomBytes } from 'crypto';
1
+ import { isPlainObject, isNumber, isNaN, isUndefined } from 'a-type-of-js';
3
2
 
4
3
  /**
5
4
  * 获取随机字符串
@@ -10,30 +9,34 @@ import { randomBytes } from 'crypto';
10
9
  */
11
10
  /**
12
11
  *
13
- * 获取随机字符串
12
+ * 获取简单的随机字符串
14
13
  *
15
- * @param length - 字符串长度
14
+ * @param options - 字符串长度
16
15
  * @returns - 随机字符串
17
16
  *
18
17
  *
19
18
  */
20
- function getRandomString(length) {
19
+ function getRandomString(options) {
21
20
  // 验证输入参数
22
21
  if (
23
22
  // 参数类型错误
24
- (!isPlainObject(length) && !isNumber(length)) ||
23
+ (!isPlainObject(options) && !isNumber(options)) ||
25
24
  // 参数为 NaN
26
- (isNumber(length) && isNaN(length)) ||
25
+ (isNumber(options) && isNaN(options)) ||
27
26
  // 参数为数字时为无穷大
28
- (isNumber(length) && !isFinite(length)) ||
27
+ (isNumber(options) && !isFinite(options)) ||
29
28
  // 参数为数字时为非整数
30
- (isNumber(length) && !Number.isInteger(length)) ||
29
+ (isNumber(options) && !Number.isInteger(options)) ||
31
30
  // 参数为数字时为负数
32
- (isNumber(length) && Number.isInteger(length) && length < 1) ||
31
+ (isNumber(options) && Number.isInteger(options) && options < 1) ||
33
32
  // 参数为数值然而却小于 1
34
- (isNumber(length) && length < 1) ||
35
- (isPlainObject(length) && isNumber(length.length) && length.length < 1)) {
36
- throw new TypeError('Invalid argument type (getRandomString)');
33
+ (isNumber(options) && options < 1) ||
34
+ // 参数为对象但是 length 属性非数值
35
+ (isPlainObject(options) &&
36
+ (!isNumber(options.length) ||
37
+ options.length < 1 ||
38
+ !Number.isInteger(options.length)))) {
39
+ throw new TypeError('参数类型错误 ❌ (getRandomString)');
37
40
  }
38
41
  const initOptions = {
39
42
  length: 32,
@@ -49,12 +52,12 @@ function getRandomString(length) {
49
52
  if (initOptions.type === 'uuid') {
50
53
  return crypto.randomUUID();
51
54
  }
52
- if (isNumber(length) && Number.isInteger(length) && length > 0) {
55
+ if (isNumber(options) && Number.isInteger(options) && options > 0) {
53
56
  // 验证输入参数
54
- Object.assign(initOptions, { length });
57
+ Object.assign(initOptions, { length: options });
55
58
  }
56
- if (isPlainObject(length)) {
57
- Object.assign(initOptions, length);
59
+ if (isPlainObject(options)) {
60
+ Object.assign(initOptions, options);
58
61
  initOptions.length = initOptions.length < 1 ? 32 : initOptions.length;
59
62
  }
60
63
  /** 生成随机字符串 */
@@ -72,7 +75,9 @@ function getRandomString(length) {
72
75
  interleaveString(templateCharsArr, initOptions.chars3);
73
76
  }
74
77
  // 使用密码学安全的随机数生成器
75
- const bytes = randomBytes(initOptions.length);
78
+ const bytes = !isUndefined(window) && window.crypto
79
+ ? window.crypto.getRandomValues(new Uint8Array(initOptions.length))
80
+ : global.crypto.getRandomValues(new Uint8Array(initOptions.length));
76
81
  let result = '';
77
82
  /** 获取最后的 chars 数据 */
78
83
  const chars = templateCharsArr.join('');
@@ -63,7 +63,7 @@ function debounce(callback, delay = 200) {
63
63
  */
64
64
  function throttle(callback, delay = 200) {
65
65
  // 强制转换非数值
66
- if (!isFinite(delay) || (isFinite(delay) && delay < 0))
66
+ if (!isFinite(delay) || (isFinite(delay) && delay < 4))
67
67
  delay = 200;
68
68
  /** 延迟控制插销 */
69
69
  let inThrottle = false;
@@ -0,0 +1,48 @@
1
+ import { isString, isUndefined } from 'a-type-of-js';
2
+ import { escapeRegExp } from './escapeRegExp.mjs';
3
+ import { parse } from './parse.mjs';
4
+
5
+ /**
6
+ *
7
+ * ## 适用于简单的文本字符串自动转化为简单模式正则表达式
8
+ *
9
+ * *若字符串包含且需保留字符类、组、反向引用、量词等时,该方法可能不适用*
10
+ *
11
+ * @param pattern 待转化的文本字符串
12
+ * @param options 转化选项。 为文本字符串时,默认为正则表达式的标志,还可指定是否匹配开头或结尾
13
+ * @returns 正则表达式
14
+ * @example
15
+ *
16
+ * ```ts
17
+ * import { autoEscapedRegExp } from 'a-regexp';
18
+ *
19
+ * autoEscapedRegExp('abc'); // => /abc/
20
+ * autoEscapedRegExp('abc', 'gim'); // => /abc/gim
21
+ * autoEscapedRegExp('abc', { flags: 'g', start: true }); // => /^abc/g
22
+ * autoEscapedRegExp('abc', { flags: 'g', end: true }); // => /abc$/g
23
+ * autoEscapedRegExp('abc', { start: true, end: true }); // => /^abc$/
24
+ *
25
+ * // 转化特殊字符类、组、反向引用、量词等
26
+ * // 无法保留匹配规则
27
+ * autoEscapedRegExp('a-zA-Z0-9'); // => /a-zA-Z0-9/
28
+ * autoEscapedRegExp('a-zA-Z0-9', 'g'); // => /a-zA-Z0-9/g
29
+ * autoEscapedRegExp('[a-zA-Z0-9]'); // => /\[a-zA-Z0-9\]/
30
+ * autoEscapedRegExp('^[a-zA-Z0-9]+$'); // => /\^\[a-zA-Z0-9\]\$/
31
+ *
32
+ * ```
33
+ *
34
+ */
35
+ function autoEscapedRegExp(pattern, options) {
36
+ if (!isString(pattern)) {
37
+ throw new TypeError('pattern must be a 字符串');
38
+ }
39
+ pattern = escapeRegExp(pattern);
40
+ /** 简单转化 */
41
+ if (isUndefined(options)) {
42
+ return new RegExp(pattern);
43
+ }
44
+ options = parse(options);
45
+ return new RegExp(`${options.start ? '^' : ''}${pattern}${options.end ? '$' : ''}`, options.flags);
46
+ }
47
+
48
+ export { autoEscapedRegExp };
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * 将一个字符串转化为符合正则要求的字符串
4
+ *
5
+ * @param str 需要转义的字符串
6
+ * @requires escapeRegExp 转化后字符串
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * import { escapeRegExp } from 'a-js-tools';
11
+ *
12
+ * escapeRegExp('a.b.c'); // 'a\\.b\\.c'
13
+ * escapeRegExp('a\\.b\\.c'); // 'a\\\\.b\\\\.c'
14
+ * escapeRegExp('[a-z]'); // '\\[a-z\\]'
15
+ * escapeRegExp('^abc$'); // '\\^abc\\$'
16
+ * ```
17
+ */
18
+ function escapeRegExp(str) {
19
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
20
+ }
21
+
22
+ export { escapeRegExp };
@@ -0,0 +1,33 @@
1
+ import { isString, isNull } from 'a-type-of-js';
2
+
3
+ /**
4
+ *
5
+ * 解析 options
6
+ *
7
+ */
8
+ function parse(options) {
9
+ // 处理 options
10
+ if (isString(options)) {
11
+ options = {
12
+ flags: options,
13
+ };
14
+ }
15
+ // 处理 flags
16
+ if (!isString(options.flags)) {
17
+ options.flags = '';
18
+ }
19
+ else {
20
+ // 需求是保留字符串中的某一部分,使用
21
+ const regexp = /[migsuy]/g;
22
+ const matchResult = options.flags.match(regexp);
23
+ if (isNull(matchResult)) {
24
+ options.flags = '';
25
+ }
26
+ else {
27
+ options.flags = [...new Set(matchResult)].join('');
28
+ }
29
+ }
30
+ return options;
31
+ }
32
+
33
+ export { parse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "name": "a-js-tools",
5
5
  "description": "一点点 🤏 js 函数",
6
6
  "license": "ISC",
package/types/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { toLowerCamelCase, toSplitCase, getRandomFloat, getRandomInt, getRandomString, } from './src/index';
2
2
  export { throttle, debounce } from './src/performance';
3
3
  export type { DebounceAndThrottleReturnType } from './src/performance';
4
+ export { escapeRegExp, autoEscapedRegExp } from './src/regexp';
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  *
3
- * Random string generation function
4
- *
5
- *
3
+ * 随机字符串 生成器
6
4
  *
7
5
  */
8
6
  export type RandomStringOptions = {
@@ -46,11 +44,11 @@ export type RandomStringOptions = {
46
44
  };
47
45
  /**
48
46
  *
49
- * 获取随机字符串
47
+ * 获取简单的随机字符串
50
48
  *
51
- * @param length - 字符串长度
49
+ * @param options - 字符串长度
52
50
  * @returns - 随机字符串
53
51
  *
54
52
  *
55
53
  */
56
- export declare function getRandomString(length?: RandomStringOptions | number): string;
54
+ export declare function getRandomString(options?: RandomStringOptions | number): string;
@@ -0,0 +1,32 @@
1
+ import { autoEscapedRegExpOptions } from './types';
2
+ /**
3
+ *
4
+ * ## 适用于简单的文本字符串自动转化为简单模式正则表达式
5
+ *
6
+ * *若字符串包含且需保留字符类、组、反向引用、量词等时,该方法可能不适用*
7
+ *
8
+ * @param pattern 待转化的文本字符串
9
+ * @param options 转化选项。 为文本字符串时,默认为正则表达式的标志,还可指定是否匹配开头或结尾
10
+ * @returns 正则表达式
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * import { autoEscapedRegExp } from 'a-regexp';
15
+ *
16
+ * autoEscapedRegExp('abc'); // => /abc/
17
+ * autoEscapedRegExp('abc', 'gim'); // => /abc/gim
18
+ * autoEscapedRegExp('abc', { flags: 'g', start: true }); // => /^abc/g
19
+ * autoEscapedRegExp('abc', { flags: 'g', end: true }); // => /abc$/g
20
+ * autoEscapedRegExp('abc', { start: true, end: true }); // => /^abc$/
21
+ *
22
+ * // 转化特殊字符类、组、反向引用、量词等
23
+ * // 无法保留匹配规则
24
+ * autoEscapedRegExp('a-zA-Z0-9'); // => /a-zA-Z0-9/
25
+ * autoEscapedRegExp('a-zA-Z0-9', 'g'); // => /a-zA-Z0-9/g
26
+ * autoEscapedRegExp('[a-zA-Z0-9]'); // => /\[a-zA-Z0-9\]/
27
+ * autoEscapedRegExp('^[a-zA-Z0-9]+$'); // => /\^\[a-zA-Z0-9\]\$/
28
+ *
29
+ * ```
30
+ *
31
+ */
32
+ export declare function autoEscapedRegExp(pattern: string, options?: string | autoEscapedRegExpOptions): RegExp;
@@ -0,0 +1,18 @@
1
+ /**
2
+ *
3
+ * 将一个字符串转化为符合正则要求的字符串
4
+ *
5
+ * @param str 需要转义的字符串
6
+ * @requires escapeRegExp 转化后字符串
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * import { escapeRegExp } from 'a-js-tools';
11
+ *
12
+ * escapeRegExp('a.b.c'); // 'a\\.b\\.c'
13
+ * escapeRegExp('a\\.b\\.c'); // 'a\\\\.b\\\\.c'
14
+ * escapeRegExp('[a-z]'); // '\\[a-z\\]'
15
+ * escapeRegExp('^abc$'); // '\\^abc\\$'
16
+ * ```
17
+ */
18
+ export declare function escapeRegExp(str: string): string;
@@ -0,0 +1,2 @@
1
+ export { escapeRegExp } from './escapeRegExp';
2
+ export { autoEscapedRegExp } from './autoEscapedRegExp';
@@ -0,0 +1,7 @@
1
+ import { autoEscapedRegExpOptions } from './types';
2
+ /**
3
+ *
4
+ * 解析 options
5
+ *
6
+ */
7
+ export declare function parse(options: string | autoEscapedRegExpOptions): autoEscapedRegExpOptions;
@@ -0,0 +1,15 @@
1
+ export interface autoEscapedRegExpOptions {
2
+ /**
3
+ *
4
+ *
5
+ *
6
+ */
7
+ flags?: string;
8
+ /**
9
+ *
10
+ * 匹配开头
11
+ *
12
+ */
13
+ start?: boolean;
14
+ end?: boolean;
15
+ }