@rnacanvas/utilities 1.2.0 → 2.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/dist/DownloadableFile.d.ts +17 -0
- package/dist/DownloadableFile.d.ts.map +1 -0
- package/dist/EventfulSet.d.ts +59 -0
- package/dist/EventfulSet.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a file that can be downloaded.
|
|
3
|
+
*/
|
|
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;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=DownloadableFile.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change events are defined as occurring whenever the composition of items in a set changes.
|
|
3
|
+
*/
|
|
4
|
+
type ChangeEventName = 'change';
|
|
5
|
+
type EventName = (ChangeEventName);
|
|
6
|
+
type EventListener = () => void;
|
|
7
|
+
/**
|
|
8
|
+
* A set of items with events that can be listened to
|
|
9
|
+
* (such as whenever the set changes).
|
|
10
|
+
*/
|
|
11
|
+
export declare class EventfulSet<T> {
|
|
12
|
+
private underlyingSet;
|
|
13
|
+
private eventListeners;
|
|
14
|
+
constructor();
|
|
15
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns true if the set possesses the given item and returns false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
includes(item: T): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* An alias for the `includes` method.
|
|
22
|
+
*
|
|
23
|
+
* Often reads more nicely if a variable referencing a set has a plural name.
|
|
24
|
+
*/
|
|
25
|
+
include(item: T): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Adds all of the specified items to the set.
|
|
28
|
+
*
|
|
29
|
+
* If some items were already present in the set, they are not duplicated.
|
|
30
|
+
*
|
|
31
|
+
* Calls change event listeners if items were added to the set.
|
|
32
|
+
*
|
|
33
|
+
* Does not call change event listeners if all of the specified items were already present in the set
|
|
34
|
+
* or for an empty iterable of specified items.
|
|
35
|
+
*/
|
|
36
|
+
addAll(items: Iterable<T>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Removes all of the specified items from the set.
|
|
39
|
+
*
|
|
40
|
+
* Calls change event listeners.
|
|
41
|
+
*
|
|
42
|
+
* (Does not call change event listeners if none of the specified items were in the set to begin with
|
|
43
|
+
* or for an empty iterable of specified items.)
|
|
44
|
+
*/
|
|
45
|
+
removeAll(items: Iterable<T>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Removes all items from the set.
|
|
48
|
+
*
|
|
49
|
+
* Calls change event listeners.
|
|
50
|
+
*
|
|
51
|
+
* (Does not call change event listeners if there were no items in the set to begin with.)
|
|
52
|
+
*/
|
|
53
|
+
clear(): void;
|
|
54
|
+
addEventListener(name: EventName, listener: EventListener): void;
|
|
55
|
+
private callEventListeners;
|
|
56
|
+
removeEventListener(name: EventName, listener: EventListener): void;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=EventfulSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventfulSet.d.ts","sourceRoot":"","sources":["../src/EventfulSet.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,eAAe,GAAG,QAAQ,CAAC;AAEhC,KAAK,SAAS,GAAG,CACf,eAAe,CAChB,CAAC;AAEF,KAAK,aAAa,GAAG,MAAM,IAAI,CAAC;AAMhC;;;GAGG;AACH,qBAAa,WAAW,CAAC,CAAC;IACxB,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,cAAc,CAEpB;;IAMF,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAI1B;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAIzB;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAahC;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAanC;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;IASb,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAIhE,OAAO,CAAC,kBAAkB;IAI1B,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;CAGpE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ import { shuffled } from './shuffled';
|
|
|
2
2
|
export { shuffled };
|
|
3
3
|
import { detectMac } from './detectMac';
|
|
4
4
|
export { detectMac };
|
|
5
|
+
import { DownloadableFile } from './DownloadableFile';
|
|
6
|
+
export { DownloadableFile };
|
|
7
|
+
import { EventfulSet } from './EventfulSet';
|
|
8
|
+
export { EventfulSet };
|
|
5
9
|
//# 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,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,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,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"}
|
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,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(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}e.r(t),e.d(t,{DownloadableFile:()=>i,EventfulSet:()=>s,detectMac:()=>r,shuffled:()=>n});class i{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 s{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))}}return t})()));
|
package/package.json
CHANGED