@rnacanvas/utilities 5.1.0 → 6.0.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/README.md CHANGED
@@ -17,6 +17,61 @@ import { DownloadableFile } from '@rnacanvas/utilities';
17
17
  import { KeyBinding } from '@rnacanvas/utilities';
18
18
  ```
19
19
 
20
+ ## `function splitLines()`
21
+
22
+ Splits a string into its constituent lines
23
+ regardless of newline character encoding
24
+ (e.g., CR, LF, CRLF).
25
+
26
+ ```javascript
27
+ splitLines('asdf\nqwer'); // ["asdf", "qwer"]
28
+
29
+ splitLines('1\n2\r3\r\n4'); // ["1", "2", "3", "4"]
30
+ ```
31
+
32
+ Note that empty strings might be present in the returned array
33
+ after splitting.
34
+
35
+ ```javascript
36
+ splitLines('\nasdf'); // ["", "asdf"]
37
+
38
+ splitLines('qwer\r'); // ["qwer", ""]
39
+
40
+ splitLines('asdf\n\n\nqwer'); // ["asdf", "", "", "qwer"]
41
+ ```
42
+
43
+ ## `function isJSONSerializable()`
44
+
45
+ Return `true` if the provided value can be serialized
46
+ using the `JSON.stringify()` method
47
+ without the `JSON.stringify()` method throwing.
48
+
49
+ Returns `false` otherwise.
50
+
51
+ ```javascript
52
+ var obj1 = { 'a': 1, 'b': 2 };
53
+
54
+ isJSONSerializable(obj1); // true
55
+
56
+ var obj2 = {};
57
+
58
+ // a circular reference
59
+ obj2.obj2 = obj2;
60
+
61
+ isJSONSerializable(obj2); // false
62
+ ```
63
+
64
+ ## `function shuffled()`
65
+
66
+ Returns a new array containing the same values as in the input array
67
+ but shuffled in random order.
68
+
69
+ (Does not modify the input array of values.)
70
+
71
+ ```javascript
72
+ shuffled([1, 2, 3, 4, 5]); // [3, 1, 5, 2, 4]
73
+ ```
74
+
20
75
  ## `function hasFocus()`
21
76
 
22
77
  The `hasFocus()` function returns `true` if and only if
@@ -59,3 +114,9 @@ containsFocus(ele2); // true
59
114
  The `KeyBinding` class represents a key binding.
60
115
 
61
116
  See the [@rnacanvas/key-bindings](https://pzhaojohnson.github.io/rnacanvas.key-bindings/) package for documentation.
117
+
118
+ ## `function detectMacOS()`
119
+
120
+ Returns `true` if it is detected that the user is using macOS.
121
+
122
+ Returns `false` otherwise.
@@ -1,17 +1,15 @@
1
1
  /**
2
- * Represents a file that can be downloaded.
2
+ * A file that can be downloaded.
3
3
  */
4
4
  export declare class DownloadableFile {
5
- private textContent;
6
- /**
7
- * Creates a downloadable file with the given text content.
8
- */
9
- constructor(textContent: string);
10
- /**
11
- * Offers the file to the user for download with the given name and type.
12
- */
13
- downloadAs(name: string, options: {
14
- type: string;
15
- }): void;
5
+ #private;
6
+ name: string;
7
+ content: string | Blob;
8
+ constructor(name?: string, content?: string | Blob, options?: {
9
+ type?: string;
10
+ });
11
+ get type(): string;
12
+ set type(type: string);
13
+ download(): void;
16
14
  }
17
15
  //# sourceMappingURL=DownloadableFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DownloadableFile.d.ts","sourceRoot":"","sources":["../src/DownloadableFile.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAgB;IAIf,OAAO,CAAC,WAAW;IAH/B;;OAEG;gBACiB,WAAW,EAAE,MAAM;IAEvC;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAc1D"}
1
+ {"version":3,"file":"DownloadableFile.d.ts","sourceRoot":"","sources":["../src/DownloadableFile.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAgB;;IAC3B,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;gBAIX,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAQ/E,IAAI,IAAI,IAAI,MAAM,CAUjB;IAED,IAAI,IAAI,CAAC,IAAI,EAZD,MAYC,EAEZ;IAED,QAAQ,IAAI,IAAI;CAejB"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { splitLines } from './splitLines';
2
2
  export { splitLines };
3
+ import { isJSONSerializable } from './isJSONSerializable';
4
+ export { isJSONSerializable };
3
5
  import { shuffled } from './shuffled';
4
6
  export { shuffled };
5
7
  import { hasFocus } from './hasFocus';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,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;AAEvB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,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;AAEvB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,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,(()=>(()=>{var e={992:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},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={};e.r(t),e.d(t,{KeyBinding:()=>v});var r,i,n,s,o,a,l,h,c,u,d=function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};class v{constructor(e,t,a){r.add(this),this.key=e,i.set(this,void 0),n.set(this,void 0),s.set(this,void 0),o.set(this,void 0),d(this,i,t,"f"),d(this,n,(e=>f(this,r,"m",u).call(this,e)),"f"),d(this,s,a,"f")}get owner(){return f(this,o,"f")}set owner(e){var t;null===(t=f(this,o,"f"))||void 0===t||t.removeEventListener("keydown",f(this,n,"f")),null==e||e.addEventListener("keydown",f(this,n,"f"),{passive:!1}),d(this,o,e,"f")}}return i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){var e,t;return null!==(t=null===(e=f(this,s,"f"))||void 0===e?void 0:e.altKey)&&void 0!==t&&t},l=function(){var e,t;return null!==(t=null===(e=f(this,s,"f"))||void 0===e?void 0:e.ctrlKey)&&void 0!==t&&t},h=function(){var e,t;return null!==(t=null===(e=f(this,s,"f"))||void 0===e?void 0:e.metaKey)&&void 0!==t&&t},c=function(){var e,t;return null!==(t=null===(e=f(this,s,"f"))||void 0===e?void 0:e.shiftKey)&&void 0!==t&&t},u=function(e){this.owner&&this.owner===document.activeElement&&e.key.toUpperCase()===this.key.toUpperCase()&&e.altKey===f(this,r,"a",a)&&e.ctrlKey===f(this,r,"a",l)&&e.metaKey===f(this,r,"a",h)&&e.shiftKey===f(this,r,"a",c)&&(e.preventDefault(),f(this,i,"f").call(this))},t})(),e.exports=t()}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,r),s.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";function e(e){return e.split(/\r\n|\r|\n/)}function t(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function n(e){return e===document.activeElement}function s(e){return!!document.activeElement&&e.contains(document.activeElement)}r.r(i),r.d(i,{DownloadableFile:()=>l,EventfulSet:()=>h,FiniteStack:()=>p,KeyBinding:()=>o.KeyBinding,containsFocus:()=>s,detectMacOS:()=>a,hasFocus:()=>n,isURL:()=>y,shuffled:()=>t,splitLines:()=>e});var o=r(992);function a(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}class l{constructor(e){this.textContent=e}downloadAs(e,t){let r=new File([this.textContent],e,{type:t.type}),i=URL.createObjectURL(r),n=document.createElement("a");n.href=i,n.download=r.name,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(i)}}class h{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 c,u,d,f,v=function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};class p{constructor(e){c.add(this),this.maxSize=e,u.set(this,[]),d.set(this,{change:[]})}get size(){return v(this,u,"f").length}isEmpty(){return 0==this.size}empty(){0!=this.size&&(function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?n.call(e,r):n?n.value=r:t.set(e,r)}(this,u,[],"f"),v(this,c,"m",f).call(this,"change"))}peek(){if(0==this.size)throw new Error("The stack is empty.");return v(this,u,"f")[v(this,u,"f").length-1]}push(e){v(this,u,"f").push(e),this.size>this.maxSize&&v(this,u,"f").shift(),v(this,c,"m",f).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,c,"m",f).call(this,"change"),e}addEventListener(e,t){v(this,d,"f")[e].push(t)}removeEventListener(e,t){v(this,d,"f")[e]=v(this,d,"f")[e].filter((e=>e!==t))}}function y(e){try{return new URL(e),!0}catch(e){return!1}}u=new WeakMap,d=new WeakMap,c=new WeakSet,f=function(e){v(this,d,"f")[e].forEach((e=>e()))}})(),i})()));
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,()=>(()=>{var e={992:function(e){var t;t=()=>(()=>{"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={};e.r(t),e.d(t,{KeyBinding:()=>p});var r,n,i,o,s,a,l,c,h,u,d=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");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r},f=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,t,a){r.add(this),this.key=e,n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),s.set(this,void 0),d(this,n,t,"f"),d(this,i,e=>f(this,r,"m",u).call(this,e),"f"),d(this,o,a,"f")}get owner(){return f(this,s,"f")}set owner(e){var t;null===(t=f(this,s,"f"))||void 0===t||t.removeEventListener("keydown",f(this,i,"f")),null==e||e.addEventListener("keydown",f(this,i,"f"),{passive:!1}),d(this,s,e,"f")}}return n=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap,r=new WeakSet,a=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.altKey)&&void 0!==t&&t},l=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.ctrlKey)&&void 0!==t&&t},c=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.metaKey)&&void 0!==t&&t},h=function(){var e,t;return null!==(t=null===(e=f(this,o,"f"))||void 0===e?void 0:e.shiftKey)&&void 0!==t&&t},u=function(e){this.owner&&this.owner===document.activeElement&&e.key.toUpperCase()===this.key.toUpperCase()&&e.altKey===f(this,r,"a",a)&&e.ctrlKey===f(this,r,"a",l)&&e.metaKey===f(this,r,"a",c)&&e.shiftKey===f(this,r,"a",h)&&(e.preventDefault(),f(this,n,"f").call(this))},t})(),e.exports=t()}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";function e(e){return e.split(/\r\n|\r|\n/)}function t(e){try{return JSON.stringify(e),!0}catch(e){return!1}}function i(e){return e.map(e=>({v:e,priority:Math.random()})).sort((e,t)=>e.priority-t.priority).map(({v:e})=>e)}function o(e){return e===document.activeElement}function s(e){return!!document.activeElement&&e.contains(document.activeElement)}r.r(n),r.d(n,{DownloadableFile:()=>d,EventfulSet:()=>f,FiniteStack:()=>g,KeyBinding:()=>a.KeyBinding,containsFocus:()=>s,detectMacOS:()=>l,hasFocus:()=>o,isJSONSerializable:()=>t,isURL:()=>b,shuffled:()=>i,splitLines:()=>e});var a=r(992);function l(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}var c,h=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");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r},u=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 d{constructor(e,t,r){c.set(this,void 0),this.name=null!=e?e:"Unnamed.txt",this.content=null!=t?t:"",h(this,c,null==r?void 0:r.type,"f")}get type(){return null!=u(this,c,"f")?u(this,c,"f"):this.content instanceof Blob?this.content.type:"text/plain"}set type(e){h(this,c,e,"f")}download(){let e=new File([this.content],this.name,{type:this.type}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=e.name,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(t)}}c=new WeakMap;class f{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 p,v,y,w,m=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 g{constructor(e){p.add(this),this.maxSize=e,v.set(this,[]),y.set(this,{change:[]})}get size(){return m(this,v,"f").length}isEmpty(){return 0==this.size}empty(){0!=this.size&&(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,v,[],"f"),m(this,p,"m",w).call(this,"change"))}peek(){if(0==this.size)throw new Error("The stack is empty.");return m(this,v,"f")[m(this,v,"f").length-1]}push(e){m(this,v,"f").push(e),this.size>this.maxSize&&m(this,v,"f").shift(),m(this,p,"m",w).call(this,"change")}pop(){if(0==this.size)throw new Error("The stack is empty.");let e=m(this,v,"f").pop();return m(this,p,"m",w).call(this,"change"),e}addEventListener(e,t){m(this,y,"f")[e].push(t)}removeEventListener(e,t){m(this,y,"f")[e]=m(this,y,"f")[e].filter(e=>e!==t)}}function b(e){try{return new URL(e),!0}catch(e){return!1}}v=new WeakMap,y=new WeakMap,p=new WeakSet,w=function(e){m(this,y,"f")[e].forEach(e=>e())}})(),n})());
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns true if the provided value can be serialized using the `JSON.stringify()` method
3
+ * without the `JSON.stringify()` method throwing.
4
+ *
5
+ * Returns false otherwise.
6
+ */
7
+ export declare function isJSONSerializable(value: unknown): boolean;
8
+ //# sourceMappingURL=isJSONSerializable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isJSONSerializable.d.ts","sourceRoot":"","sources":["../src/isJSONSerializable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/utilities",
3
- "version": "5.1.0",
3
+ "version": "6.0.0",
4
4
  "description": "General utilities",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -13,9 +13,9 @@
13
13
  "@babel/core": "^7.23.7",
14
14
  "@babel/preset-env": "^7.23.7",
15
15
  "@babel/preset-typescript": "^7.23.3",
16
- "babel-jest": "^29.7.0",
17
- "jest": "^29.7.0",
18
- "jest-environment-jsdom": "^29.7.0",
16
+ "babel-jest": "^30.1.2",
17
+ "jest": "^30.1.3",
18
+ "jest-environment-jsdom": "^30.1.2",
19
19
  "ts-loader": "^9.5.1",
20
20
  "typescript": "^5.3.3",
21
21
  "webpack": "^5.89.0",