@chocbite/ts-lib-state 1.1.3 → 1.1.4

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/index.d.ts CHANGED
@@ -262,14 +262,12 @@ type EnumHelperEntry = {
262
262
  type StateEnumHelperList<K extends PropertyKey> = {
263
263
  [P in K]: EnumHelperEntry;
264
264
  };
265
- interface StateEnumRelated<L extends StateEnumHelperList<any> = StateEnumHelperList<any>> extends StateRelatedBase {
265
+ interface StateEnumRelated<L extends StateEnumHelperList<PropertyKey> = StateEnumHelperList<PropertyKey>> extends StateRelatedBase {
266
266
  list: State<L>;
267
- map<K extends keyof L, R>(func: (key: K, val: EnumHelperEntry) => R): Promise<R[]>;
268
267
  }
269
268
  declare class StateEnumHelper<L extends StateEnumHelperList<any>, K extends PropertyKey = keyof L, R extends StateRelatedBase = StateEnumRelated<L>> extends StateHelper<K, OptionSome<R>> implements StateEnumRelated<L> {
270
269
  readonly list: State<L>;
271
270
  constructor(list: State<L>, writable?: State<boolean>);
272
- map<K extends keyof L, R>(func: (key: K, val: EnumHelperEntry) => R): Promise<R[]>;
273
271
  limit(value: K): Promise<Result<K, string>>;
274
272
  check(value: K): Promise<Result<K, string>>;
275
273
  related(): OptionSome<R>;
@@ -1158,6 +1156,15 @@ declare const state: {
1158
1156
  description?: string;
1159
1157
  icon?: _chocbite_ts_lib_svg.SVGFunc;
1160
1158
  }; }): typeof list;
1159
+ map<K extends PropertyKey, R>(list: { [P in K]: {
1160
+ name: string;
1161
+ description?: string;
1162
+ icon?: _chocbite_ts_lib_svg.SVGFunc;
1163
+ }; }, func: (key: K, val: {
1164
+ name: string;
1165
+ description?: string;
1166
+ icon?: _chocbite_ts_lib_svg.SVGFunc;
1167
+ }) => R): R[];
1161
1168
  };
1162
1169
  await_value: <T>(value: T, state: State<T>, timeout?: number) => Promise<boolean>;
1163
1170
  compare: (state1: State<any>, state2: State<any>) => Promise<boolean>;
package/dist/index.js CHANGED
@@ -1576,13 +1576,6 @@ var StateEnumHelper = class extends StateHelper {
1576
1576
  super(writable);
1577
1577
  this.list = list;
1578
1578
  }
1579
- async map(func) {
1580
- const list = await this.list;
1581
- if (list.err) return [];
1582
- return Object.keys(list.value).map(
1583
- (key) => func(key, list.value[key])
1584
- );
1585
- }
1586
1579
  async limit(value) {
1587
1580
  return ok5(value);
1588
1581
  }
@@ -1604,6 +1597,13 @@ var enums = {
1604
1597
  /**Creates an enum description list, passing the enum as a generic type to this function makes things look a bit nicer */
1605
1598
  list(list) {
1606
1599
  return list;
1600
+ },
1601
+ /**Maps over an enum description list
1602
+ * @param list enum description list
1603
+ * @param func function to apply to each entry
1604
+ * @returns array of results*/
1605
+ map(list, func) {
1606
+ return Object.keys(list).map((key) => func(key, list[key]));
1607
1607
  }
1608
1608
  };
1609
1609
  async function await_value(value, state2, timeout = 500) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chocbite/ts-lib-state",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "State management library for TypeScript",
5
5
  "author": "chocolateandmilkwin",
6
6
  "license": "MIT",