utilium 1.7.12 → 1.7.13

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/dist/struct.js CHANGED
@@ -18,8 +18,11 @@ export function sizeof(type) {
18
18
  }
19
19
  return size;
20
20
  }
21
- // primitive
21
+ // primitive or character
22
22
  if (typeof type == 'string') {
23
+ // Single character inside string, since sizeof(string) -> sizeof(string[0]) -> here
24
+ if (type.length == 1)
25
+ return 1;
23
26
  primitive.checkValid(type);
24
27
  return (+primitive.normalize(type).match(primitive.regex)[2] / 8);
25
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "1.7.12",
3
+ "version": "1.7.13",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",
package/src/struct.ts CHANGED
@@ -44,8 +44,11 @@ export function sizeof<T extends TypeLike>(type: T | T[]): Size<T> {
44
44
  return size as Size<T>;
45
45
  }
46
46
 
47
- // primitive
47
+ // primitive or character
48
48
  if (typeof type == 'string') {
49
+ // Single character inside string, since sizeof(string) -> sizeof(string[0]) -> here
50
+ if (type.length == 1) return 1 as Size<T>;
51
+
49
52
  primitive.checkValid(type);
50
53
 
51
54
  return (+primitive.normalize(type).match(primitive.regex)![2] / 8) as Size<T>;