@xaendar/common 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/common",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "A library containing common utils and types",
5
5
  "type": "module",
6
6
  "main": "./xaendar-common.es.js",
@@ -125,6 +125,7 @@ export declare class Stack<T = unknown> {
125
125
  */
126
126
  private _elements;
127
127
  [index: number]: T;
128
+ [prop: string | symbol]: unknown;
128
129
  constructor();
129
130
  /**
130
131
  * The number of elements currently in the stack.
@@ -3,7 +3,7 @@ var e = class {
3
3
  _elements = [];
4
4
  constructor() {
5
5
  return new Proxy(this, { get(e, t) {
6
- if (typeof t == "string") return isNaN(Number(t)) ? e[t] : e._elements[Number(t)];
6
+ return isNaN(Number(t)) ? e[t] : e._elements[Number(t)];
7
7
  } });
8
8
  }
9
9
  get length() {
@@ -1 +1 @@
1
- {"version":3,"file":"xaendar-common.es.js","names":[],"sources":["../../../packages/common/src/models/stack/stack.model.ts"],"sourcesContent":["/**\r\n * A generic LIFO (Last In, First Out) stack data structure.\r\n *\r\n * @template T - The type of elements held in the stack. Defaults to `unknown`.\r\n */\r\nexport class Stack<T = unknown> {\r\n /**\r\n * Internal array holding the stack elements, ordered from bottom to top.\r\n */\r\n private _elements = new Array<T>;\r\n\r\n [index: number]: T;\r\n\r\n constructor() {\r\n return new Proxy(this, {\r\n get(target, prop) {\r\n if (typeof prop === 'string') {\r\n return isNaN(Number(prop)) ? (target as unknown as { [prop]: unknown })[prop] : target._elements[Number(prop)];\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * The number of elements currently in the stack.\r\n */\r\n public get length(): number {\r\n return this._elements.length;\r\n }\r\n\r\n /**\r\n * A shallow copy of the elements in the stack, ordered from bottom to top.\r\n */\r\n public get values(): T[] {\r\n return [...this._elements];\r\n }\r\n\r\n /**\r\n * Removes and returns the top element of the stack.\r\n *\r\n * @returns The top element, or `undefined` if the stack is empty.\r\n */\r\n public pop(): T | undefined {\r\n return this._elements.pop();\r\n }\r\n\r\n /**\r\n * Pushes an element onto the top of the stack.\r\n *\r\n * @param element - The element to push.\r\n * @returns The new length of the stack.\r\n */\r\n public push(element: T): number {\r\n return this._elements.push(element);\r\n }\r\n}"],"mappings":";AAKA,IAAa,IAAb,MAAgC;CAI9B,YAAoB,EAAY;CAIhC,cAAc;AACZ,SAAO,IAAI,MAAM,MAAM,EACrB,IAAI,GAAQ,GAAM;AAChB,OAAI,OAAO,KAAS,SAClB,QAAO,MAAM,OAAO,EAAK,CAAC,GAAI,EAA0C,KAAQ,EAAO,UAAU,OAAO,EAAK;KAGlH,CAAC;;CAMJ,IAAW,SAAiB;AAC1B,SAAO,KAAK,UAAU;;CAMxB,IAAW,SAAc;AACvB,SAAO,CAAC,GAAG,KAAK,UAAU;;CAQ5B,MAA4B;AAC1B,SAAO,KAAK,UAAU,KAAK;;CAS7B,KAAY,GAAoB;AAC9B,SAAO,KAAK,UAAU,KAAK,EAAQ"}
1
+ {"version":3,"file":"xaendar-common.es.js","names":[],"sources":["../../../packages/common/src/models/stack/stack.model.ts"],"sourcesContent":["/**\r\n * A generic LIFO (Last In, First Out) stack data structure.\r\n *\r\n * @template T - The type of elements held in the stack. Defaults to `unknown`.\r\n */\r\nexport class Stack<T = unknown> {\r\n /**\r\n * Internal array holding the stack elements, ordered from bottom to top.\r\n */\r\n private _elements = new Array<T>;\r\n\r\n [index: number]: T;\r\n\r\n [prop: string | symbol]: unknown;\r\n\r\n constructor() {\r\n return new Proxy(this, {\r\n get(target, prop) {\r\n return isNaN(Number(prop)) ? target[prop] : target._elements[Number(prop)];\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * The number of elements currently in the stack.\r\n */\r\n public get length(): number {\r\n return this._elements.length;\r\n }\r\n\r\n /**\r\n * A shallow copy of the elements in the stack, ordered from bottom to top.\r\n */\r\n public get values(): T[] {\r\n return [...this._elements];\r\n }\r\n\r\n /**\r\n * Removes and returns the top element of the stack.\r\n *\r\n * @returns The top element, or `undefined` if the stack is empty.\r\n */\r\n public pop(): T | undefined {\r\n return this._elements.pop();\r\n }\r\n\r\n /**\r\n * Pushes an element onto the top of the stack.\r\n *\r\n * @param element - The element to push.\r\n * @returns The new length of the stack.\r\n */\r\n public push(element: T): number {\r\n return this._elements.push(element);\r\n }\r\n}"],"mappings":";AAKA,IAAa,IAAb,MAAgC;CAI9B,YAAoB,EAAY;CAMhC,cAAc;EACZ,OAAO,IAAI,MAAM,MAAM,EACrB,IAAI,GAAQ,GAAM;GAChB,OAAO,MAAM,OAAO,EAAK,CAAC,GAAG,EAAO,KAAQ,EAAO,UAAU,OAAO,EAAK;KAE5E,CAAC;;CAMJ,IAAW,SAAiB;EAC1B,OAAO,KAAK,UAAU;;CAMxB,IAAW,SAAc;EACvB,OAAO,CAAC,GAAG,KAAK,UAAU;;CAQ5B,MAA4B;EAC1B,OAAO,KAAK,UAAU,KAAK;;CAS7B,KAAY,GAAoB;EAC9B,OAAO,KAAK,UAAU,KAAK,EAAQ"}