@vope/utils 1.1.0 → 1.2.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
@@ -3,11 +3,6 @@
3
3
  发布构建
4
4
  ```
5
5
 
6
- ### init:build
7
- ```
8
- 发布构建(初次需要先构建基本环境)
9
- ```
10
-
11
6
  ### cjs
12
7
  ```
13
8
  构建cjs版本
package/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.connectURLParams = exports.joinURLs = exports.Union = exports.deconPowersSum = exports.once = exports.MemoryPower = exports.MemoryList = exports.MemoryBasic = exports.isNull = exports.isEmpty = exports.isClass = exports.getEncoding = exports.hash8strings = exports.hash8object = exports.hash8json = exports.deepWeakEqual = exports.compareVersion = exports.classnames = exports.clamp = exports.apiGet = exports.apiPost = void 0;
6
+ exports.wait = exports.connectURLParams = exports.joinPaths = exports.Union = exports.rotateRad = exports.rotateAngle = exports.deconPowersSum = exports.once = exports.MemoryPower = exports.MemoryList = exports.MemoryBasic = exports.isNull = exports.isEmpty = exports.isClass = exports.inputRegex = exports.getEncoding = exports.hash8strings = exports.hash8object = exports.hash8json = exports.deepWeakEqual = exports.compareVersion = exports.classnames = exports.clamp = exports.apiGet = exports.apiPost = void 0;
7
7
  var api_1 = require("./api");
8
8
  Object.defineProperty(exports, "apiPost", { enumerable: true, get: function () { return api_1.apiPost; } });
9
9
  Object.defineProperty(exports, "apiGet", { enumerable: true, get: function () { return api_1.apiGet; } });
@@ -23,6 +23,8 @@ var strings_1 = require("./convert/strings");
23
23
  Object.defineProperty(exports, "hash8strings", { enumerable: true, get: function () { return __importDefault(strings_1).default; } });
24
24
  var encoding_1 = require("./encoding");
25
25
  Object.defineProperty(exports, "getEncoding", { enumerable: true, get: function () { return __importDefault(encoding_1).default; } });
26
+ var input_regex_1 = require("./input-regex");
27
+ Object.defineProperty(exports, "inputRegex", { enumerable: true, get: function () { return __importDefault(input_regex_1).default; } });
26
28
  var class_1 = require("./is/class");
27
29
  Object.defineProperty(exports, "isClass", { enumerable: true, get: function () { return __importDefault(class_1).default; } });
28
30
  var empty_1 = require("./is/empty");
@@ -39,9 +41,15 @@ var once_1 = require("./once");
39
41
  Object.defineProperty(exports, "once", { enumerable: true, get: function () { return __importDefault(once_1).default; } });
40
42
  var decon_1 = require("./power/decon");
41
43
  Object.defineProperty(exports, "deconPowersSum", { enumerable: true, get: function () { return __importDefault(decon_1).default; } });
44
+ var angle_1 = require("./rotate/angle");
45
+ Object.defineProperty(exports, "rotateAngle", { enumerable: true, get: function () { return __importDefault(angle_1).default; } });
46
+ var rad_1 = require("./rotate/rad");
47
+ Object.defineProperty(exports, "rotateRad", { enumerable: true, get: function () { return __importDefault(rad_1).default; } });
42
48
  var union_1 = require("./union");
43
49
  Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return __importDefault(union_1).default; } });
44
50
  var join_1 = require("./url/join");
45
- Object.defineProperty(exports, "joinURLs", { enumerable: true, get: function () { return __importDefault(join_1).default; } });
51
+ Object.defineProperty(exports, "joinPaths", { enumerable: true, get: function () { return __importDefault(join_1).default; } });
46
52
  var params_1 = require("./url/params");
47
53
  Object.defineProperty(exports, "connectURLParams", { enumerable: true, get: function () { return __importDefault(params_1).default; } });
54
+ var wait_1 = require("./wait");
55
+ Object.defineProperty(exports, "wait", { enumerable: true, get: function () { return __importDefault(wait_1).default; } });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const RE_REGEX = /[$()*+.[?\\^{|]/g;
4
+ const RE_STRING = /[$()*+.[?\\^{|-]/g;
5
+ function inputRegex(text, flags) {
6
+ return flags === false
7
+ ? text.replace(RE_STRING, ($0) => '\\' + $0)
8
+ : new RegExp(text.replace(RE_REGEX, ($0) => '\\' + $0), flags);
9
+ }
10
+ exports.default = inputRegex;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const rad_1 = __importDefault(require("./rad"));
7
+ /**
8
+ * 返回点被旋转指定角度后新的位置
9
+ * @param from 旋转点
10
+ * @param angle 旋转角度
11
+ * @param visit 旋转原点
12
+ */
13
+ const rotateAngle = (from, angle, visit) => (0, rad_1.default)(from, angle / 180 * Math.PI, visit);
14
+ exports.default = rotateAngle;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 返回点被旋转指定弧度后新的位置
5
+ * @param from 旋转点
6
+ * @param rad 旋转弧度
7
+ * @param visit 旋转原点
8
+ */
9
+ const rotateRad = (from, rad, visit = [0, 0]) => {
10
+ const x = from[0] - visit[0];
11
+ const y = from[1] - visit[1];
12
+ return [
13
+ x * Math.cos(rad) + y * Math.sin(rad) + visit[0],
14
+ y * Math.cos(rad) - x * Math.sin(rad) + visit[1],
15
+ ];
16
+ };
17
+ exports.default = rotateRad;
package/cjs/url/join.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const re = /(^|[^:/])\/{2,}/g;
3
+ const re = /([^:])\/{2,}/g;
4
4
  /**
5
5
  * 实现多个路径拼接
6
6
  */
7
- const joinURLs = (...list) => {
7
+ const joinPaths = (...list) => {
8
8
  const { length } = list;
9
9
  if (length === 0)
10
10
  return '';
@@ -12,4 +12,4 @@ const joinURLs = (...list) => {
12
12
  ? list[0]
13
13
  : list.join('/').replace(re, ($0, $1) => `${$1}/`);
14
14
  };
15
- exports.default = joinURLs;
15
+ exports.default = joinPaths;
package/cjs/wait.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 等待
5
+ */
6
+ exports.default = (delay = 0) => new Promise((resolve) => window.setTimeout(resolve, delay));
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ export { default as hash8json } from './convert/json';
7
7
  export { default as hash8object } from './convert/object';
8
8
  export { default as hash8strings } from './convert/strings';
9
9
  export { default as getEncoding } from './encoding';
10
+ export { default as inputRegex } from './input-regex';
10
11
  export { default as isClass } from './is/class';
11
12
  export { default as isEmpty } from './is/empty';
12
13
  export { default as isNull } from './is/null';
@@ -15,6 +16,9 @@ export { default as MemoryList } from './memory/list';
15
16
  export { default as MemoryPower } from './memory/power';
16
17
  export { default as once } from './once';
17
18
  export { default as deconPowersSum } from './power/decon';
19
+ export { default as rotateAngle } from './rotate/angle';
20
+ export { default as rotateRad } from './rotate/rad';
18
21
  export { default as Union } from './union';
19
- export { default as joinURLs } from './url/join';
22
+ export { default as joinPaths } from './url/join';
20
23
  export { default as connectURLParams } from './url/params';
24
+ export { default as wait } from './wait';
@@ -0,0 +1,8 @@
1
+ const RE_REGEX = /[$()*+.[?\\^{|]/g;
2
+ const RE_STRING = /[$()*+.[?\\^{|-]/g;
3
+ function inputRegex(text, flags) {
4
+ return flags === false
5
+ ? text.replace(RE_STRING, ($0) => '\\' + $0)
6
+ : new RegExp(text.replace(RE_REGEX, ($0) => '\\' + $0), flags);
7
+ }
8
+ export default inputRegex;
@@ -0,0 +1,9 @@
1
+ import rotateRad from './rad';
2
+ /**
3
+ * 返回点被旋转指定角度后新的位置
4
+ * @param from 旋转点
5
+ * @param angle 旋转角度
6
+ * @param visit 旋转原点
7
+ */
8
+ const rotateAngle = (from, angle, visit) => rotateRad(from, angle / 180 * Math.PI, visit);
9
+ export default rotateAngle;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 返回点被旋转指定弧度后新的位置
3
+ * @param from 旋转点
4
+ * @param rad 旋转弧度
5
+ * @param visit 旋转原点
6
+ */
7
+ const rotateRad = (from, rad, visit = [0, 0]) => {
8
+ const x = from[0] - visit[0];
9
+ const y = from[1] - visit[1];
10
+ return [
11
+ x * Math.cos(rad) + y * Math.sin(rad) + visit[0],
12
+ y * Math.cos(rad) - x * Math.sin(rad) + visit[1],
13
+ ];
14
+ };
15
+ export default rotateRad;
package/lib/url/join.js CHANGED
@@ -1,8 +1,8 @@
1
- const re = /(^|[^:/])\/{2,}/g;
1
+ const re = /([^:])\/{2,}/g;
2
2
  /**
3
3
  * 实现多个路径拼接
4
4
  */
5
- const joinURLs = (...list) => {
5
+ const joinPaths = (...list) => {
6
6
  const { length } = list;
7
7
  if (length === 0)
8
8
  return '';
@@ -10,4 +10,4 @@ const joinURLs = (...list) => {
10
10
  ? list[0]
11
11
  : list.join('/').replace(re, ($0, $1) => `${$1}/`);
12
12
  };
13
- export default joinURLs;
13
+ export default joinPaths;
package/lib/wait.js ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 等待
3
+ */
4
+ export default (delay = 0) => new Promise((resolve) => window.setTimeout(resolve, delay));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vope/utils",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -12,18 +12,15 @@
12
12
  "main": "./cjs/index.js",
13
13
  "scripts": {
14
14
  "build": "npm run cjs | npm run esm | npm run types",
15
- "init:build": "npm run devs & npm run trove & npm run test:build",
16
15
  "cjs": "rimraf cjs & npx tsc -p ./tsconfig.cjs.json",
17
16
  "esm": "rimraf lib & npx tsc -p ./tsconfig.esm.json",
18
17
  "types": "rimraf types & npx tsc -p ./tsconfig.types.json & node ./__devs/type.cjs",
19
18
  "trove": "node ./__devs/trove.cjs",
20
19
  "trove:build": "npm run devs & npm run trove",
21
20
  "devs": "rimraf __devs & npx tsc -p ./tsconfig.devs.json",
22
- "test": "mocha __tests/**/*.js",
23
- "test:dev": "npm run test:build & npm run test",
24
- "test:build": "node ./__devs/test.cjs",
25
- "test:all": "npm run devs & npm run test:build & npm run test",
26
- "prepublishOnly": "npm run devs & npm run trove & npm run build"
21
+ "test": "node ./__devs/test.cjs & mocha __tests/**/*.js",
22
+ "test:build": "npm run devs & npm run trove & npm run test",
23
+ "prepublishOnly": "npm run devs & npm run trove & npm run test & npm run build"
27
24
  },
28
25
  "exports": {
29
26
  ".": {
package/types/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { default as hash8json } from './convert/json';
7
7
  export { default as hash8object } from './convert/object';
8
8
  export { default as hash8strings } from './convert/strings';
9
9
  export { default as getEncoding } from './encoding';
10
+ export { default as inputRegex } from './input-regex';
10
11
  export { default as isClass } from './is/class';
11
12
  export { default as isEmpty } from './is/empty';
12
13
  export { default as isNull } from './is/null';
@@ -15,6 +16,9 @@ export { default as MemoryList } from './memory/list';
15
16
  export { default as MemoryPower } from './memory/power';
16
17
  export { default as once } from './once';
17
18
  export { default as deconPowersSum } from './power/decon';
19
+ export { default as rotateAngle } from './rotate/angle';
20
+ export { default as rotateRad } from './rotate/rad';
18
21
  export { default as Union } from './union';
19
- export { default as joinURLs } from './url/join';
22
+ export { default as joinPaths } from './url/join';
20
23
  export { default as connectURLParams } from './url/params';
24
+ export { default as wait } from './wait';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 处理输入文本中的特殊字符,用于转换正则表达式
3
+ * @param text
4
+ * @param flags 表示输出正则表达式
5
+ */
6
+ declare function inputRegex(text: string, flags?: string): RegExp;
7
+ /**
8
+ * 处理输入文本中的特殊字符,用于转换正则表达式
9
+ * @param text
10
+ * @param flags 表示输出字符串,该字符串将作为正则表达式的一部分
11
+ */
12
+ declare function inputRegex(text: string, flags: false): string;
13
+ export default inputRegex;
@@ -0,0 +1,9 @@
1
+ import { _Point } from './rad';
2
+ /**
3
+ * 返回点被旋转指定角度后新的位置
4
+ * @param from 旋转点
5
+ * @param angle 旋转角度
6
+ * @param visit 旋转原点
7
+ */
8
+ declare const rotateAngle: (from: _Point, angle: number, visit?: _Point) => number[];
9
+ export default rotateAngle;
@@ -0,0 +1,9 @@
1
+ export type _Point = [number, number];
2
+ /**
3
+ * 返回点被旋转指定弧度后新的位置
4
+ * @param from 旋转点
5
+ * @param rad 旋转弧度
6
+ * @param visit 旋转原点
7
+ */
8
+ declare const rotateRad: (from: _Point, rad: number, visit?: _Point) => number[];
9
+ export default rotateRad;
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * 实现多个路径拼接
3
3
  */
4
- declare const joinURLs: (...list: string[]) => string;
5
- export default joinURLs;
4
+ declare const joinPaths: (...list: string[]) => string;
5
+ export default joinPaths;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 等待
3
+ */
4
+ declare const _default: (delay?: number) => Promise<void>;
5
+ export default _default;