@rnacanvas/utilities 2.4.0 → 2.6.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.
@@ -9,6 +9,7 @@ export declare class FiniteStack<T> {
9
9
  * The number of items in the stack.
10
10
  */
11
11
  get size(): number;
12
+ isEmpty(): boolean;
12
13
  /**
13
14
  * Pushes the item to the top of the stack.
14
15
  *
@@ -22,5 +23,10 @@ export declare class FiniteStack<T> {
22
23
  * Throws if the stack is empty.
23
24
  */
24
25
  pop(): T | never;
26
+ addEventListener(name: EventName, listener: EventListener): void;
27
+ removeEventListener(name: EventName, listener: EventListener): void;
25
28
  }
29
+ type EventName = ('change');
30
+ type EventListener = () => void;
31
+ export {};
26
32
  //# sourceMappingURL=FiniteStack.d.ts.map
@@ -1 +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;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAQnB;;;;OAIG;IACH,GAAG,IAAI,CAAC,GAAG,KAAK;CAOjB"}
1
+ {"version":3,"file":"FiniteStack.d.ts","sourceRoot":"","sources":["../src/FiniteStack.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;;IAOZ,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;IAUnB;;;;OAIG;IACH,GAAG,IAAI,CAAC,GAAG,KAAK;IAYhB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAIhE,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;CAOpE;AAED,KAAK,SAAS,GAAG,CACf,QAAQ,CACT,CAAC;AAEF,KAAK,aAAa,GAAG,MAAM,IAAI,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,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}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})()));
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,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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 n(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function r(){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:()=>m,KeyBinding:()=>a,detectMac:()=>c,isBeingInteractedWith:()=>s,shuffled:()=>n,userIsTyping:()=>r});let i=null;function s(e){return e===document.body||!!i&&i.target instanceof Node&&e.contains(i.target)}window.addEventListener("mousedown",(e=>i=e));var o;class a{constructor(e,t){this.key=e,o.set(this,void 0),window.addEventListener("keydown",(n=>{n.key.toUpperCase()===e.toUpperCase()&&!r()&&s(this.scope)&&(n.preventDefault(),t())}),{passive:!1})}get scope(){var e;return null!==(e=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}(this,o,"f"))&&void 0!==e?e:document.body}set scope(e){!function(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!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"===r?i.call(e,n):i?i.value=n:t.set(e,n)}(this,o,e,"f")}}function c(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}o=new WeakMap;class l{constructor(e){this.textContent=e}downloadAs(e,t){let n=new File([this.textContent],e,{type:t.type}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=n.name,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}}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 h,u,f,p,v=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};class m{constructor(e){h.add(this),this.maxSize=e,u.set(this,[]),f.set(this,{change:[]})}get size(){return v(this,u,"f").length}isEmpty(){return 0==this.size}push(e){v(this,u,"f").push(e),this.size>this.maxSize&&v(this,u,"f").shift(),v(this,h,"m",p).call(this,"change")}pop(){if(0==this.size)throw new Error("The stack is empty.");let e=v(this,u,"f").pop();return v(this,h,"m",p).call(this,"change"),e}addEventListener(e,t){v(this,f,"f")[e].push(t)}removeEventListener(e,t){v(this,f,"f")[e]=v(this,f,"f")[e].filter((e=>e!==t))}}return u=new WeakMap,f=new WeakMap,h=new WeakSet,p=function(e){v(this,f,"f")[e].forEach((e=>e()))},t})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/utilities",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "General utilities",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {