@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 +7 -0
- package/es/clamp.js +15 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/lib/clamp.d.ts +7 -0
- package/lib/clamp.js +19 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/es/clamp.d.ts
ADDED
package/es/clamp.js
ADDED
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/lib/clamp.d.ts
ADDED
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
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);
|