@rnacanvas/utilities 5.0.1 → 5.2.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 +23 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/isJSONSerializable.d.ts +8 -0
- package/dist/isJSONSerializable.d.ts.map +1 -0
- package/dist/splitLines.d.ts +6 -0
- package/dist/splitLines.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,29 @@ 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
|
+
|
|
20
43
|
## `function hasFocus()`
|
|
21
44
|
|
|
22
45
|
The `hasFocus()` function returns `true` if and only if
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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E,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,o,
|
|
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,c,h,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},c=function(){var e,t;return null!==(t=null===(e=f(this,s,"f"))||void 0===e?void 0:e.metaKey)&&void 0!==t&&t},h=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",c)&&e.shiftKey===f(this,r,"a",h)&&(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){try{return JSON.stringify(e),!0}catch(e){return!1}}function n(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function s(e){return e===document.activeElement}function o(e){return!!document.activeElement&&e.contains(document.activeElement)}r.r(i),r.d(i,{DownloadableFile:()=>c,EventfulSet:()=>h,FiniteStack:()=>y,KeyBinding:()=>a.KeyBinding,containsFocus:()=>o,detectMacOS:()=>l,hasFocus:()=>s,isJSONSerializable:()=>t,isURL:()=>w,shuffled:()=>n,splitLines:()=>e});var a=r(992);function l(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}class c{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 u,d,f,v,p=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 y{constructor(e){u.add(this),this.maxSize=e,d.set(this,[]),f.set(this,{change:[]})}get size(){return p(this,d,"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,d,[],"f"),p(this,u,"m",v).call(this,"change"))}peek(){if(0==this.size)throw new Error("The stack is empty.");return p(this,d,"f")[p(this,d,"f").length-1]}push(e){p(this,d,"f").push(e),this.size>this.maxSize&&p(this,d,"f").shift(),p(this,u,"m",v).call(this,"change")}pop(){if(0==this.size)throw new Error("The stack is empty.");let e=p(this,d,"f").pop();return p(this,u,"m",v).call(this,"change"),e}addEventListener(e,t){p(this,f,"f")[e].push(t)}removeEventListener(e,t){p(this,f,"f")[e]=p(this,f,"f")[e].filter((e=>e!==t))}}function w(e){try{return new URL(e),!0}catch(e){return!1}}d=new WeakMap,f=new WeakMap,u=new WeakSet,v=function(e){p(this,f,"f")[e].forEach((e=>e()))}})(),i})()));
|
|
@@ -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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitLines.d.ts","sourceRoot":"","sources":["../src/splitLines.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9C"}
|