utilium 0.7.1 → 0.7.2

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.
@@ -1,7 +1,7 @@
1
1
  import { capitalize } from '../string.js';
2
2
  export const types = ['int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64', 'float32', 'float64'];
3
3
  export const valids = [...types, ...types.map(t => capitalize(t)), 'char'];
4
- export const regex = /^(u?int)(8|16|32|64)|(float)(32|64)$/i;
4
+ export const regex = /^(u?int|float)(8|16|32|64)$/i;
5
5
  export function normalize(type) {
6
6
  return (type == 'char' ? 'uint8' : type.toLowerCase());
7
7
  }
package/dist/list.js CHANGED
@@ -12,10 +12,10 @@ export class List extends EventEmitter {
12
12
  return new Set(this.data);
13
13
  }
14
14
  toArray() {
15
- return [...this.data];
15
+ return Array.from(this.data);
16
16
  }
17
17
  toJSON() {
18
- return JSON.stringify([...this.data]);
18
+ return JSON.stringify(Array.from(this.data));
19
19
  }
20
20
  toString() {
21
21
  return this.join(',');
@@ -24,7 +24,7 @@ export class List extends EventEmitter {
24
24
  if (Math.abs(index) > this.data.size) {
25
25
  throw new ReferenceError('Can not set an element outside the bounds of the list');
26
26
  }
27
- const data = [...this.data];
27
+ const data = Array.from(this.data);
28
28
  data.splice(index, 1, value);
29
29
  this.data = new Set(data);
30
30
  this.emit('update');
@@ -33,17 +33,17 @@ export class List extends EventEmitter {
33
33
  if (Math.abs(index) > this.data.size) {
34
34
  throw new ReferenceError('Can not delete an element outside the bounds of the list');
35
35
  }
36
- this.delete([...this.data].at(index));
36
+ this.delete(Array.from(this.data).at(index));
37
37
  }
38
38
  // Array methods
39
39
  at(index) {
40
40
  if (Math.abs(index) > this.data.size) {
41
41
  throw new ReferenceError('Can not access an element outside the bounds of the list');
42
42
  }
43
- return [...this.data].at(index);
43
+ return Array.from(this.data).at(index);
44
44
  }
45
45
  pop() {
46
- const item = [...this.data].pop();
46
+ const item = Array.from(this.data).pop();
47
47
  if (item !== undefined) {
48
48
  this.delete(item);
49
49
  }
@@ -56,13 +56,13 @@ export class List extends EventEmitter {
56
56
  return this.data.size;
57
57
  }
58
58
  join(separator) {
59
- return [...this.data].join(separator);
59
+ return Array.from(this.data).join(separator);
60
60
  }
61
61
  splice(start, deleteCount, ...items) {
62
62
  if (Math.abs(start) > this.data.size) {
63
63
  throw new ReferenceError('Can not splice elements outside the bounds of the list');
64
64
  }
65
- const data = [...this.data];
65
+ const data = Array.from(this.data);
66
66
  const deleted = data.splice(start, deleteCount, ...items);
67
67
  this.data = new Set(data);
68
68
  this.emit('update');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Typescript utilies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@ export const types = ['int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'in
15
15
 
16
16
  export const valids = [...types, ...types.map(t => capitalize(t)), 'char'] satisfies Valid[];
17
17
 
18
- export const regex = /^(u?int)(8|16|32|64)|(float)(32|64)$/i;
18
+ export const regex = /^(u?int|float)(8|16|32|64)$/i;
19
19
 
20
20
  export type Normalize<T extends Valid> = T extends 'char' ? 'uint8' : Uncapitalize<T>;
21
21
 
package/src/list.ts CHANGED
@@ -17,11 +17,11 @@ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable
17
17
  }
18
18
 
19
19
  public toArray(): T[] {
20
- return [...this.data];
20
+ return Array.from(this.data);
21
21
  }
22
22
 
23
23
  public toJSON() {
24
- return JSON.stringify([...this.data]);
24
+ return JSON.stringify(Array.from(this.data));
25
25
  }
26
26
 
27
27
  public toString() {
@@ -33,7 +33,7 @@ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable
33
33
  throw new ReferenceError('Can not set an element outside the bounds of the list');
34
34
  }
35
35
 
36
- const data = [...this.data];
36
+ const data = Array.from(this.data);
37
37
  data.splice(index, 1, value);
38
38
  this.data = new Set<T>(data);
39
39
  this.emit('update');
@@ -44,7 +44,7 @@ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable
44
44
  throw new ReferenceError('Can not delete an element outside the bounds of the list');
45
45
  }
46
46
 
47
- this.delete([...this.data].at(index)!);
47
+ this.delete(Array.from(this.data).at(index)!);
48
48
  }
49
49
 
50
50
  // Array methods
@@ -54,11 +54,11 @@ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable
54
54
  throw new ReferenceError('Can not access an element outside the bounds of the list');
55
55
  }
56
56
 
57
- return [...this.data].at(index)!;
57
+ return Array.from(this.data).at(index)!;
58
58
  }
59
59
 
60
60
  public pop(): T | undefined {
61
- const item = [...this.data].pop();
61
+ const item = Array.from(this.data).pop();
62
62
  if (item !== undefined) {
63
63
  this.delete(item);
64
64
  }
@@ -73,7 +73,7 @@ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable
73
73
  }
74
74
 
75
75
  public join(separator?: string): string {
76
- return [...this.data].join(separator);
76
+ return Array.from(this.data).join(separator);
77
77
  }
78
78
 
79
79
  public splice(start: number, deleteCount: number, ...items: T[]): T[] {
@@ -81,7 +81,7 @@ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable
81
81
  throw new ReferenceError('Can not splice elements outside the bounds of the list');
82
82
  }
83
83
 
84
- const data = [...this.data];
84
+ const data = Array.from(this.data);
85
85
  const deleted = data.splice(start, deleteCount, ...items);
86
86
  this.data = new Set<T>(data);
87
87
  this.emit('update');