@daysnap/utils 0.0.65 → 0.0.67

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/es/clamp.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 首选值超出最小值,返回最小值;首选值超出最大值,返回最大值;其余返回首选值
3
+ * @param min 最小值
4
+ * @param x 首选值
5
+ * @param max 最大值
6
+ */
7
+ export declare function clamp(min: number, val: number, max: number): number;
package/es/clamp.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 首选值超出最小值,返回最小值;首选值超出最大值,返回最大值;其余返回首选值
3
+ * @param min 最小值
4
+ * @param x 首选值
5
+ * @param max 最大值
6
+ */
7
+ export function clamp(min, val, max) {
8
+ if (val < min) {
9
+ return min;
10
+ }
11
+ if (val > max) {
12
+ return max;
13
+ }
14
+ return val;
15
+ }
package/es/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './cached';
4
4
  export * from './camelCase';
5
5
  export * from './canvasToBlob';
6
6
  export * from './capitalize';
7
+ export * from './clamp';
7
8
  export * from './clone';
8
9
  export * from './cloneSimple';
9
10
  export * from './compareVersion';
package/es/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './cached';
5
5
  export * from './camelCase';
6
6
  export * from './canvasToBlob';
7
7
  export * from './capitalize';
8
+ export * from './clamp';
8
9
  export * from './clone';
9
10
  export * from './cloneSimple';
10
11
  export * from './compareVersion';
package/lib/clamp.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 首选值超出最小值,返回最小值;首选值超出最大值,返回最大值;其余返回首选值
3
+ * @param min 最小值
4
+ * @param x 首选值
5
+ * @param max 最大值
6
+ */
7
+ export declare function clamp(min: number, val: number, max: number): number;
package/lib/clamp.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clamp = void 0;
4
+ /**
5
+ * 首选值超出最小值,返回最小值;首选值超出最大值,返回最大值;其余返回首选值
6
+ * @param min 最小值
7
+ * @param x 首选值
8
+ * @param max 最大值
9
+ */
10
+ function clamp(min, val, max) {
11
+ if (val < min) {
12
+ return min;
13
+ }
14
+ if (val > max) {
15
+ return max;
16
+ }
17
+ return val;
18
+ }
19
+ exports.clamp = clamp;
package/lib/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './cached';
4
4
  export * from './camelCase';
5
5
  export * from './canvasToBlob';
6
6
  export * from './capitalize';
7
+ export * from './clamp';
7
8
  export * from './clone';
8
9
  export * from './cloneSimple';
9
10
  export * from './compareVersion';
package/lib/index.js CHANGED
@@ -21,6 +21,7 @@ __exportStar(require("./cached"), exports);
21
21
  __exportStar(require("./camelCase"), exports);
22
22
  __exportStar(require("./canvasToBlob"), exports);
23
23
  __exportStar(require("./capitalize"), exports);
24
+ __exportStar(require("./clamp"), exports);
24
25
  __exportStar(require("./clone"), exports);
25
26
  __exportStar(require("./cloneSimple"), exports);
26
27
  __exportStar(require("./compareVersion"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
4
4
  "description": "通用的工具库",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",