@rnacanvas/utilities 2.3.2 → 2.5.0
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/FiniteStack.d.ts +27 -0
- package/dist/FiniteStack.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stack with a finite size.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FiniteStack<T> {
|
|
5
|
+
#private;
|
|
6
|
+
readonly maxSize: number;
|
|
7
|
+
constructor(maxSize: number);
|
|
8
|
+
/**
|
|
9
|
+
* The number of items in the stack.
|
|
10
|
+
*/
|
|
11
|
+
get size(): number;
|
|
12
|
+
isEmpty(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Pushes the item to the top of the stack.
|
|
15
|
+
*
|
|
16
|
+
* Removes the item at the bottom of the stack
|
|
17
|
+
* if the maximum stack size is exceeded.
|
|
18
|
+
*/
|
|
19
|
+
push(item: T): void;
|
|
20
|
+
/**
|
|
21
|
+
* Pops off and returns the item at the top of the stack.
|
|
22
|
+
*
|
|
23
|
+
* Throws if the stack is empty.
|
|
24
|
+
*/
|
|
25
|
+
pop(): T | never;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=FiniteStack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiniteStack.d.ts","sourceRoot":"","sources":["../src/FiniteStack.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;;IAGZ,QAAQ,CAAC,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAEpC;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,IAAI,OAAO;IAIlB;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAQnB;;;;OAIG;IACH,GAAG,IAAI,CAAC,GAAG,KAAK;CAOjB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,6 @@ import { DownloadableFile } from './DownloadableFile';
|
|
|
12
12
|
export { DownloadableFile };
|
|
13
13
|
import { EventfulSet } from './EventfulSet';
|
|
14
14
|
export { EventfulSet };
|
|
15
|
+
import { FiniteStack } from './FiniteStack';
|
|
16
|
+
export { FiniteStack };
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.utilities=t():e.utilities=t()}(this,(()=>(()=>{"use strict";var e={d:(t,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.utilities=t():e.utilities=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function n(){return!(!document.activeElement||"textarea"!==document.activeElement.tagName.toLowerCase()&&(e=document.activeElement,"input"!==e.tagName.toLowerCase()||"text"!==(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.toLowerCase())));var e,t}e.r(t),e.d(t,{DownloadableFile:()=>l,EventfulSet:()=>d,FiniteStack:()=>p,KeyBinding:()=>a,detectMac:()=>c,isBeingInteractedWith:()=>o,shuffled:()=>r,userIsTyping:()=>n});let i=null;function o(e){return e===document.body||!!i&&i.target instanceof Node&&e.contains(i.target)}window.addEventListener("mousedown",(e=>i=e));var s;class a{constructor(e,t){this.key=e,s.set(this,void 0),window.addEventListener("keydown",(r=>{r.key.toUpperCase()===e.toUpperCase()&&!n()&&o(this.scope)&&(r.preventDefault(),t())}),{passive:!1})}get scope(){var e;return null!==(e=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}(this,s,"f"))&&void 0!==e?e:document.body}set scope(e){!function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?i.call(e,r):i?i.value=r:t.set(e,r)}(this,s,e,"f")}}function c(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}s=new WeakMap;class l{constructor(e){this.textContent=e}downloadAs(e,t){let r=new File([this.textContent],e,{type:t.type}),n=URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=r.name,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(n)}}class d{constructor(){this.eventListeners={change:[]},this.underlyingSet=new Set}[Symbol.iterator](){return this.underlyingSet.values()}includes(e){return this.underlyingSet.has(e)}include(e){return this.includes(e)}addAll(e){let t=[...e];0!=t.length&&(t.every((e=>this.includes(e)))||(t.forEach((e=>this.underlyingSet.add(e))),this.callEventListeners("change")))}removeAll(e){let t=[...e];0!=t.length&&(t.every((e=>!this.includes(e)))||(t.forEach((e=>this.underlyingSet.delete(e))),this.callEventListeners("change")))}clear(){0!=this.underlyingSet.size&&(this.underlyingSet.clear(),this.callEventListeners("change"))}addEventListener(e,t){this.eventListeners[e].push(t)}callEventListeners(e){this.eventListeners[e].forEach((e=>e()))}removeEventListener(e,t){this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))}}var u,h=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};class p{constructor(e){this.maxSize=e,u.set(this,[])}get size(){return h(this,u,"f").length}isEmpty(){return 0==this.size}push(e){h(this,u,"f").push(e),this.size>this.maxSize&&h(this,u,"f").shift()}pop(){if(0==this.size)throw new Error("The stack is empty.");return h(this,u,"f").pop()}}return u=new WeakMap,t})()));
|