hsu-utils 0.0.29 → 0.0.31
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 +7 -7
- package/dist/hsu-utils.js +3 -3
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +1 -1
- package/es/ArrayIsIncludes/index.js +3 -0
- package/es/GetStrSize/index.js +1 -1
- package/lib/ArrayIsIncludes/index.js +3 -0
- package/lib/GetStrSize/index.js +1 -1
- package/package.json +1 -1
@@ -7,6 +7,9 @@ function countMap(arr) {
|
|
7
7
|
return map;
|
8
8
|
}
|
9
9
|
export default function array_is_includes(arr1, arr2) {
|
10
|
+
if (arr1.length === 0 || arr2.length === 0) {
|
11
|
+
return false;
|
12
|
+
}
|
10
13
|
const smallArr = arr1.length <= arr2.length ? arr1 : arr2;
|
11
14
|
const largeArr = arr1.length > arr2.length ? arr1 : arr2;
|
12
15
|
const smallArrMap = countMap(smallArr);
|
package/es/GetStrSize/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export default function get_string_size(str, font = {}, letterSpacing = 0) {
|
2
|
-
const { style = 'normal', variant = 'normal', weight = 'normal', size =
|
2
|
+
const { style = 'normal', variant = 'normal', weight = 'normal', size = 10, family: fontFamily = 'sans-serif' } = font;
|
3
3
|
const canvas = document.createElement('canvas');
|
4
4
|
const ctx = canvas.getContext('2d');
|
5
5
|
ctx.font = `${style} ${variant} ${weight} ${size}px ${fontFamily}`;
|
@@ -46,6 +46,9 @@ function countMap(arr) {
|
|
46
46
|
}
|
47
47
|
function array_is_includes(arr1, arr2) {
|
48
48
|
var e_1, _a;
|
49
|
+
if (arr1.length === 0 || arr2.length === 0) {
|
50
|
+
return false;
|
51
|
+
}
|
49
52
|
var smallArr = arr1.length <= arr2.length ? arr1 : arr2;
|
50
53
|
var largeArr = arr1.length > arr2.length ? arr1 : arr2;
|
51
54
|
var smallArrMap = countMap(smallArr);
|
package/lib/GetStrSize/index.js
CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function get_string_size(str, font, letterSpacing) {
|
4
4
|
if (font === void 0) { font = {}; }
|
5
5
|
if (letterSpacing === void 0) { letterSpacing = 0; }
|
6
|
-
var _a = font.style, style = _a === void 0 ? 'normal' : _a, _b = font.variant, variant = _b === void 0 ? 'normal' : _b, _c = font.weight, weight = _c === void 0 ? 'normal' : _c, _d = font.size, size = _d === void 0 ?
|
6
|
+
var _a = font.style, style = _a === void 0 ? 'normal' : _a, _b = font.variant, variant = _b === void 0 ? 'normal' : _b, _c = font.weight, weight = _c === void 0 ? 'normal' : _c, _d = font.size, size = _d === void 0 ? 10 : _d, _e = font.family, fontFamily = _e === void 0 ? 'sans-serif' : _e;
|
7
7
|
var canvas = document.createElement('canvas');
|
8
8
|
var ctx = canvas.getContext('2d');
|
9
9
|
ctx.font = "".concat(style, " ").concat(variant, " ").concat(weight, " ").concat(size, "px ").concat(fontFamily);
|