@thienvu18/designable-shared 2.0.0 → 2.0.2

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.
Files changed (73) hide show
  1. package/esm/animation.d.ts +8 -2
  2. package/esm/animation.js +29 -30
  3. package/esm/array.d.ts +163 -37
  4. package/esm/array.js +104 -87
  5. package/esm/clone.d.ts +4 -4
  6. package/esm/clone.js +79 -86
  7. package/esm/compose.d.ts +3 -1
  8. package/esm/compose.js +6 -6
  9. package/esm/coordinate.d.ts +120 -76
  10. package/esm/coordinate.js +480 -411
  11. package/esm/element.d.ts +11 -6
  12. package/esm/element.js +123 -125
  13. package/esm/event.d.ts +162 -75
  14. package/esm/event.js +197 -197
  15. package/esm/globalThisPolyfill.d.ts +1 -1
  16. package/esm/globalThisPolyfill.js +14 -17
  17. package/esm/index.d.ts +17 -17
  18. package/esm/index.js +17 -17
  19. package/esm/instanceof.d.ts +1 -1
  20. package/esm/instanceof.js +9 -10
  21. package/esm/keycode.d.ts +145 -145
  22. package/esm/keycode.js +149 -149
  23. package/esm/lru.d.ts +50 -47
  24. package/esm/lru.js +236 -245
  25. package/esm/observer.d.ts +7 -7
  26. package/esm/observer.js +37 -40
  27. package/esm/request-idle.d.ts +9 -6
  28. package/esm/request-idle.js +6 -6
  29. package/esm/scroller.d.ts +24 -8
  30. package/esm/scroller.js +78 -75
  31. package/esm/subscribable.d.ts +10 -10
  32. package/esm/subscribable.js +39 -40
  33. package/esm/types.d.ts +13 -13
  34. package/esm/types.js +19 -20
  35. package/esm/uid.d.ts +1 -1
  36. package/esm/uid.js +7 -7
  37. package/lib/animation.d.ts +8 -2
  38. package/lib/animation.js +34 -35
  39. package/lib/array.d.ts +163 -37
  40. package/lib/array.js +129 -101
  41. package/lib/clone.d.ts +4 -4
  42. package/lib/clone.js +84 -91
  43. package/lib/compose.d.ts +3 -1
  44. package/lib/compose.js +10 -10
  45. package/lib/coordinate.d.ts +120 -76
  46. package/lib/coordinate.js +538 -440
  47. package/lib/element.d.ts +11 -6
  48. package/lib/element.js +139 -133
  49. package/lib/event.d.ts +162 -75
  50. package/lib/event.js +206 -202
  51. package/lib/globalThisPolyfill.d.ts +1 -1
  52. package/lib/globalThisPolyfill.js +17 -20
  53. package/lib/index.d.ts +17 -17
  54. package/lib/index.js +49 -33
  55. package/lib/instanceof.d.ts +1 -1
  56. package/lib/instanceof.js +13 -14
  57. package/lib/keycode.d.ts +145 -145
  58. package/lib/keycode.js +153 -153
  59. package/lib/lru.d.ts +50 -47
  60. package/lib/lru.js +240 -249
  61. package/lib/observer.d.ts +7 -7
  62. package/lib/observer.js +41 -44
  63. package/lib/request-idle.d.ts +9 -6
  64. package/lib/request-idle.js +14 -11
  65. package/lib/scroller.d.ts +24 -8
  66. package/lib/scroller.js +89 -81
  67. package/lib/subscribable.d.ts +10 -10
  68. package/lib/subscribable.js +43 -44
  69. package/lib/types.d.ts +13 -13
  70. package/lib/types.js +40 -28
  71. package/lib/uid.d.ts +1 -1
  72. package/lib/uid.js +11 -11
  73. package/package.json +15 -15
package/esm/event.js CHANGED
@@ -1,212 +1,212 @@
1
- import { isArr, isWindow } from './types';
2
- import { Subscribable } from './subscribable';
3
- import { globalThisPolyfill } from './globalThisPolyfill';
4
- const ATTACHED_SYMBOL = Symbol('ATTACHED_SYMBOL');
5
- const EVENTS_SYMBOL = Symbol('__EVENTS_SYMBOL__');
6
- const EVENTS_ONCE_SYMBOL = Symbol('EVENTS_ONCE_SYMBOL');
7
- const EVENTS_BATCH_SYMBOL = Symbol('EVENTS_BATCH_SYMBOL');
8
- const DRIVER_INSTANCES_SYMBOL = Symbol('DRIVER_INSTANCES_SYMBOL');
9
- const isOnlyMode = (mode) => mode === 'onlyOne' || mode === 'onlyChild' || mode === 'onlyParent';
1
+ import { globalThisPolyfill } from './globalThisPolyfill'
2
+ import { Subscribable } from './subscribable'
3
+ import { isArr, isWindow } from './types'
4
+ const ATTACHED_SYMBOL = Symbol('ATTACHED_SYMBOL')
5
+ const EVENTS_SYMBOL = Symbol('__EVENTS_SYMBOL__')
6
+ const EVENTS_ONCE_SYMBOL = Symbol('EVENTS_ONCE_SYMBOL')
7
+ const EVENTS_BATCH_SYMBOL = Symbol('EVENTS_BATCH_SYMBOL')
8
+ const DRIVER_INSTANCES_SYMBOL = Symbol('DRIVER_INSTANCES_SYMBOL')
9
+ const isOnlyMode = (mode) =>
10
+ mode === 'onlyOne' || mode === 'onlyChild' || mode === 'onlyParent'
10
11
  /**
11
12
  * 事件驱动器基类
12
13
  */
13
14
  export class EventDriver {
14
- constructor(engine, context) {
15
- this.container = document;
16
- this.contentWindow = globalThisPolyfill;
17
- this.engine = engine;
18
- this.context = context;
19
- }
20
- dispatch(event) {
21
- return this.engine.dispatch(event, this.context);
22
- }
23
- subscribe(subscriber) {
24
- return this.engine.subscribe(subscriber);
25
- }
26
- subscribeTo(type, subscriber) {
27
- return this.engine.subscribeTo(type, subscriber);
28
- }
29
- subscribeWith(type, subscriber) {
30
- return this.engine.subscribeWith(type, subscriber);
31
- }
32
- attach(container) {
33
- void container;
34
- console.error('attach must implement.');
35
- }
36
- detach(container) {
37
- void container;
38
- console.error('attach must implement.');
39
- }
40
- eventTarget(type) {
41
- if (type === 'resize' || type === 'scroll') {
42
- if (this.container === this.contentWindow?.document) {
43
- return this.contentWindow;
44
- }
45
- }
46
- return this.container;
47
- }
48
- addEventListener(type, listener, options) {
49
- const target = this.eventTarget(type);
50
- if (isOnlyMode(options?.mode)) {
51
- target[EVENTS_ONCE_SYMBOL] = target[EVENTS_ONCE_SYMBOL] || {};
52
- const constructor = this['constructor'];
53
- constructor[EVENTS_ONCE_SYMBOL] = constructor[EVENTS_ONCE_SYMBOL] || {};
54
- const handler = target[EVENTS_ONCE_SYMBOL][type];
55
- const container = constructor[EVENTS_ONCE_SYMBOL][type];
56
- if (!handler) {
57
- if (container) {
58
- if (options.mode === 'onlyChild') {
59
- if (container.contains(target)) {
60
- container.removeEventListener(type, container[EVENTS_ONCE_SYMBOL][type], options);
61
- delete container[EVENTS_ONCE_SYMBOL][type];
62
- }
63
- }
64
- else if (options.mode === 'onlyParent') {
65
- if (container.contains(target))
66
- return;
67
- }
68
- }
69
- target.addEventListener(type, listener, options);
70
- target[EVENTS_ONCE_SYMBOL][type] = listener;
71
- constructor[EVENTS_ONCE_SYMBOL][type] = target;
72
- }
73
- }
74
- else {
75
- target[EVENTS_SYMBOL] = target[EVENTS_SYMBOL] || {};
76
- target[EVENTS_SYMBOL][type] = target[EVENTS_SYMBOL][type] || new Map();
77
- if (!target[EVENTS_SYMBOL][type]?.get?.(listener)) {
78
- target.addEventListener(type, listener, options);
79
- target[EVENTS_SYMBOL][type]?.set?.(listener, true);
15
+ constructor(engine, context) {
16
+ this.container = document
17
+ this.contentWindow = globalThisPolyfill
18
+ this.engine = engine
19
+ this.context = context
20
+ }
21
+ dispatch(event) {
22
+ return this.engine.dispatch(event, this.context)
23
+ }
24
+ subscribe(subscriber) {
25
+ return this.engine.subscribe(subscriber)
26
+ }
27
+ subscribeTo(type, subscriber) {
28
+ return this.engine.subscribeTo(type, subscriber)
29
+ }
30
+ subscribeWith(type, subscriber) {
31
+ return this.engine.subscribeWith(type, subscriber)
32
+ }
33
+ attach(container) {
34
+ void container
35
+ console.error('attach must implement.')
36
+ }
37
+ detach(container) {
38
+ void container
39
+ console.error('attach must implement.')
40
+ }
41
+ eventTarget(type) {
42
+ if (type === 'resize' || type === 'scroll') {
43
+ if (this.container === this.contentWindow?.document) {
44
+ return this.contentWindow
45
+ }
46
+ }
47
+ return this.container
48
+ }
49
+ addEventListener(type, listener, options) {
50
+ const target = this.eventTarget(type)
51
+ if (isOnlyMode(options?.mode)) {
52
+ target[EVENTS_ONCE_SYMBOL] = target[EVENTS_ONCE_SYMBOL] || {}
53
+ const constructor = this['constructor']
54
+ constructor[EVENTS_ONCE_SYMBOL] = constructor[EVENTS_ONCE_SYMBOL] || {}
55
+ const handler = target[EVENTS_ONCE_SYMBOL][type]
56
+ const container = constructor[EVENTS_ONCE_SYMBOL][type]
57
+ if (!handler) {
58
+ if (container) {
59
+ if (options.mode === 'onlyChild') {
60
+ if (container.contains(target)) {
61
+ container.removeEventListener(
62
+ type,
63
+ container[EVENTS_ONCE_SYMBOL][type],
64
+ options
65
+ )
66
+ delete container[EVENTS_ONCE_SYMBOL][type]
80
67
  }
68
+ } else if (options.mode === 'onlyParent') {
69
+ if (container.contains(target)) return
70
+ }
81
71
  }
82
- }
83
- removeEventListener(type, listener, options) {
84
- const target = this.eventTarget(type);
85
- if (isOnlyMode(options?.mode)) {
86
- const constructor = this['constructor'];
87
- constructor[EVENTS_ONCE_SYMBOL] = constructor[EVENTS_ONCE_SYMBOL] || {};
88
- target[EVENTS_ONCE_SYMBOL] = target[EVENTS_ONCE_SYMBOL] || {};
89
- delete constructor[EVENTS_ONCE_SYMBOL][type];
90
- delete target[EVENTS_ONCE_SYMBOL][type];
91
- target.removeEventListener(type, listener, options);
92
- }
93
- else {
94
- target[EVENTS_SYMBOL] = target[EVENTS_SYMBOL] || {};
95
- target[EVENTS_SYMBOL][type] = target[EVENTS_SYMBOL][type] || new Map();
96
- target[EVENTS_SYMBOL][type]?.delete?.(listener);
97
- target.removeEventListener(type, listener, options);
98
- }
99
- }
100
- batchAddEventListener(type, listener, options) {
101
- this.engine[DRIVER_INSTANCES_SYMBOL] =
102
- this.engine[DRIVER_INSTANCES_SYMBOL] || [];
103
- if (!this.engine[DRIVER_INSTANCES_SYMBOL].includes(this)) {
104
- this.engine[DRIVER_INSTANCES_SYMBOL].push(this);
105
- }
106
- this.engine[DRIVER_INSTANCES_SYMBOL].forEach((driver) => {
107
- const target = driver.eventTarget(type);
108
- target[EVENTS_BATCH_SYMBOL] = target[EVENTS_BATCH_SYMBOL] || {};
109
- if (!target[EVENTS_BATCH_SYMBOL][type]) {
110
- target.addEventListener(type, listener, options);
111
- target[EVENTS_BATCH_SYMBOL][type] = listener;
112
- }
113
- });
114
- }
115
- batchRemoveEventListener(type, listener, options) {
116
- this.engine[DRIVER_INSTANCES_SYMBOL] =
117
- this.engine[DRIVER_INSTANCES_SYMBOL] || [];
118
- this.engine[DRIVER_INSTANCES_SYMBOL].forEach((driver) => {
119
- const target = driver.eventTarget(type);
120
- target[EVENTS_BATCH_SYMBOL] = target[EVENTS_BATCH_SYMBOL] || {};
121
- target.removeEventListener(type, listener, options);
122
- delete target[EVENTS_BATCH_SYMBOL][type];
123
- });
124
- }
72
+ target.addEventListener(type, listener, options)
73
+ target[EVENTS_ONCE_SYMBOL][type] = listener
74
+ constructor[EVENTS_ONCE_SYMBOL][type] = target
75
+ }
76
+ } else {
77
+ target[EVENTS_SYMBOL] = target[EVENTS_SYMBOL] || {}
78
+ target[EVENTS_SYMBOL][type] = target[EVENTS_SYMBOL][type] || new Map()
79
+ if (!target[EVENTS_SYMBOL][type]?.get?.(listener)) {
80
+ target.addEventListener(type, listener, options)
81
+ target[EVENTS_SYMBOL][type]?.set?.(listener, true)
82
+ }
83
+ }
84
+ }
85
+ removeEventListener(type, listener, options) {
86
+ const target = this.eventTarget(type)
87
+ if (isOnlyMode(options?.mode)) {
88
+ const constructor = this['constructor']
89
+ constructor[EVENTS_ONCE_SYMBOL] = constructor[EVENTS_ONCE_SYMBOL] || {}
90
+ target[EVENTS_ONCE_SYMBOL] = target[EVENTS_ONCE_SYMBOL] || {}
91
+ delete constructor[EVENTS_ONCE_SYMBOL][type]
92
+ delete target[EVENTS_ONCE_SYMBOL][type]
93
+ target.removeEventListener(type, listener, options)
94
+ } else {
95
+ target[EVENTS_SYMBOL] = target[EVENTS_SYMBOL] || {}
96
+ target[EVENTS_SYMBOL][type] = target[EVENTS_SYMBOL][type] || new Map()
97
+ target[EVENTS_SYMBOL][type]?.delete?.(listener)
98
+ target.removeEventListener(type, listener, options)
99
+ }
100
+ }
101
+ batchAddEventListener(type, listener, options) {
102
+ this.engine[DRIVER_INSTANCES_SYMBOL] =
103
+ this.engine[DRIVER_INSTANCES_SYMBOL] || []
104
+ if (!this.engine[DRIVER_INSTANCES_SYMBOL].includes(this)) {
105
+ this.engine[DRIVER_INSTANCES_SYMBOL].push(this)
106
+ }
107
+ this.engine[DRIVER_INSTANCES_SYMBOL].forEach((driver) => {
108
+ const target = driver.eventTarget(type)
109
+ target[EVENTS_BATCH_SYMBOL] = target[EVENTS_BATCH_SYMBOL] || {}
110
+ if (!target[EVENTS_BATCH_SYMBOL][type]) {
111
+ target.addEventListener(type, listener, options)
112
+ target[EVENTS_BATCH_SYMBOL][type] = listener
113
+ }
114
+ })
115
+ }
116
+ batchRemoveEventListener(type, listener, options) {
117
+ this.engine[DRIVER_INSTANCES_SYMBOL] =
118
+ this.engine[DRIVER_INSTANCES_SYMBOL] || []
119
+ this.engine[DRIVER_INSTANCES_SYMBOL].forEach((driver) => {
120
+ const target = driver.eventTarget(type)
121
+ target[EVENTS_BATCH_SYMBOL] = target[EVENTS_BATCH_SYMBOL] || {}
122
+ target.removeEventListener(type, listener, options)
123
+ delete target[EVENTS_BATCH_SYMBOL][type]
124
+ })
125
+ }
125
126
  }
126
127
  /**
127
128
  * 事件引擎
128
129
  */
129
130
  export class Event extends Subscribable {
130
- constructor(props) {
131
- super();
132
- this.drivers = [];
133
- this.containers = [];
134
- if (isArr(props?.effects)) {
135
- props.effects.forEach((plugin) => {
136
- plugin(this);
137
- });
138
- }
139
- if (isArr(props?.drivers)) {
140
- this.drivers = props.drivers;
141
- }
142
- }
143
- subscribeTo(type, subscriber) {
144
- return this.subscribe((event) => {
145
- if (type && event instanceof type) {
146
- return subscriber(event);
147
- }
148
- });
149
- }
150
- subscribeWith(type, subscriber) {
151
- return this.subscribe((event) => {
152
- if (isArr(type)) {
153
- if (type.includes(event?.type)) {
154
- return subscriber(event);
155
- }
156
- }
157
- else {
158
- if (type && event?.type === type) {
159
- return subscriber(event);
160
- }
161
- }
162
- });
163
- }
164
- attachEvents(container, contentWindow = globalThisPolyfill, context) {
165
- if (!container)
166
- return;
167
- if (isWindow(container)) {
168
- return this.attachEvents(container.document, container, context);
131
+ constructor(props) {
132
+ super()
133
+ this.drivers = []
134
+ this.containers = []
135
+ if (isArr(props?.effects)) {
136
+ props.effects.forEach((plugin) => {
137
+ plugin(this)
138
+ })
139
+ }
140
+ if (isArr(props?.drivers)) {
141
+ this.drivers = props.drivers
142
+ }
143
+ }
144
+ subscribeTo(type, subscriber) {
145
+ return this.subscribe((event) => {
146
+ if (type && event instanceof type) {
147
+ return subscriber(event)
148
+ }
149
+ })
150
+ }
151
+ subscribeWith(type, subscriber) {
152
+ return this.subscribe((event) => {
153
+ if (isArr(type)) {
154
+ if (type.includes(event?.type)) {
155
+ return subscriber(event)
169
156
  }
170
- if (container[ATTACHED_SYMBOL])
171
- return;
172
- container[ATTACHED_SYMBOL] = this.drivers.map((EventDriver) => {
173
- const driver = new EventDriver(this, context);
174
- driver.contentWindow = contentWindow;
175
- driver.container = container;
176
- driver.attach(container);
177
- return driver;
178
- });
179
- if (!this.containers.includes(container)) {
180
- this.containers.push(container);
157
+ } else {
158
+ if (type && event?.type === type) {
159
+ return subscriber(event)
181
160
  }
182
- }
183
- detachEvents(container) {
184
- if (!container) {
185
- this.containers.forEach((container) => {
186
- this.detachEvents(container);
187
- });
188
- return;
189
- }
190
- if (isWindow(container)) {
191
- return this.detachEvents(container.document);
161
+ }
162
+ })
163
+ }
164
+ attachEvents(container, contentWindow = globalThisPolyfill, context) {
165
+ if (!container) return
166
+ if (isWindow(container)) {
167
+ return this.attachEvents(container.document, container, context)
168
+ }
169
+ if (container[ATTACHED_SYMBOL]) return
170
+ container[ATTACHED_SYMBOL] = this.drivers.map((EventDriver) => {
171
+ const driver = new EventDriver(this, context)
172
+ driver.contentWindow = contentWindow
173
+ driver.container = container
174
+ driver.attach(container)
175
+ return driver
176
+ })
177
+ if (!this.containers.includes(container)) {
178
+ this.containers.push(container)
179
+ }
180
+ }
181
+ detachEvents(container) {
182
+ if (!container) {
183
+ this.containers.forEach((container) => {
184
+ this.detachEvents(container)
185
+ })
186
+ return
187
+ }
188
+ if (isWindow(container)) {
189
+ return this.detachEvents(container.document)
190
+ }
191
+ if (!container[ATTACHED_SYMBOL]) return
192
+ container[ATTACHED_SYMBOL].forEach((driver) => {
193
+ driver.detach(container)
194
+ })
195
+ this[DRIVER_INSTANCES_SYMBOL] = this[DRIVER_INSTANCES_SYMBOL] || []
196
+ this[DRIVER_INSTANCES_SYMBOL] = this[DRIVER_INSTANCES_SYMBOL].reduce(
197
+ (drivers, driver) => {
198
+ if (driver.container === container) {
199
+ driver.detach(container)
200
+ return drivers
192
201
  }
193
- if (!container[ATTACHED_SYMBOL])
194
- return;
195
- container[ATTACHED_SYMBOL].forEach((driver) => {
196
- driver.detach(container);
197
- });
198
- this[DRIVER_INSTANCES_SYMBOL] = this[DRIVER_INSTANCES_SYMBOL] || [];
199
- this[DRIVER_INSTANCES_SYMBOL] = this[DRIVER_INSTANCES_SYMBOL].reduce((drivers, driver) => {
200
- if (driver.container === container) {
201
- driver.detach(container);
202
- return drivers;
203
- }
204
- return drivers.concat(driver);
205
- }, []);
206
- this.containers = this.containers.filter((item) => item !== container);
207
- delete container[ATTACHED_SYMBOL];
208
- delete container[EVENTS_SYMBOL];
209
- delete container[EVENTS_ONCE_SYMBOL];
210
- delete container[EVENTS_BATCH_SYMBOL];
211
- }
202
+ return drivers.concat(driver)
203
+ },
204
+ []
205
+ )
206
+ this.containers = this.containers.filter((item) => item !== container)
207
+ delete container[ATTACHED_SYMBOL]
208
+ delete container[EVENTS_SYMBOL]
209
+ delete container[EVENTS_ONCE_SYMBOL]
210
+ delete container[EVENTS_BATCH_SYMBOL]
211
+ }
212
212
  }
@@ -1 +1 @@
1
- export declare const globalThisPolyfill: Window;
1
+ export declare const globalThisPolyfill: Window
@@ -1,22 +1,19 @@
1
1
  function getGlobalThis() {
2
- try {
3
- if (typeof self !== 'undefined') {
4
- return self;
5
- }
2
+ try {
3
+ if (typeof self !== 'undefined') {
4
+ return self
6
5
  }
7
- catch (e) { }
8
- try {
9
- if (typeof globalThisPolyfill !== 'undefined') {
10
- return globalThisPolyfill;
11
- }
6
+ } catch (e) {}
7
+ try {
8
+ if (typeof globalThisPolyfill !== 'undefined') {
9
+ return globalThisPolyfill
12
10
  }
13
- catch (e) { }
14
- try {
15
- if (typeof global !== 'undefined') {
16
- return global;
17
- }
11
+ } catch (e) {}
12
+ try {
13
+ if (typeof global !== 'undefined') {
14
+ return global
18
15
  }
19
- catch (e) { }
20
- return Function('return this')();
16
+ } catch (e) {}
17
+ return Function('return this')()
21
18
  }
22
- export const globalThisPolyfill = getGlobalThis();
19
+ export const globalThisPolyfill = getGlobalThis()
package/esm/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- export * from './event';
2
- export * from './scroller';
3
- export * from './subscribable';
4
- export * from './coordinate';
5
- export * from './types';
6
- export * from './uid';
7
- export * from './clone';
8
- export * from './instanceof';
9
- export * from './lru';
10
- export * from './compose';
11
- export * from './array';
12
- export * from './keycode';
13
- export * from './animation';
14
- export * from './request-idle';
15
- export * from './element';
16
- export * from './globalThisPolyfill';
17
- export * from './observer';
1
+ export * from './animation'
2
+ export * from './array'
3
+ export * from './clone'
4
+ export * from './compose'
5
+ export * from './coordinate'
6
+ export * from './element'
7
+ export * from './event'
8
+ export * from './globalThisPolyfill'
9
+ export * from './instanceof'
10
+ export * from './keycode'
11
+ export * from './lru'
12
+ export * from './observer'
13
+ export * from './request-idle'
14
+ export * from './scroller'
15
+ export * from './subscribable'
16
+ export * from './types'
17
+ export * from './uid'
package/esm/index.js CHANGED
@@ -1,17 +1,17 @@
1
- export * from './event';
2
- export * from './scroller';
3
- export * from './subscribable';
4
- export * from './coordinate';
5
- export * from './types';
6
- export * from './uid';
7
- export * from './clone';
8
- export * from './instanceof';
9
- export * from './lru';
10
- export * from './compose';
11
- export * from './array';
12
- export * from './keycode';
13
- export * from './animation';
14
- export * from './request-idle';
15
- export * from './element';
16
- export * from './globalThisPolyfill';
17
- export * from './observer';
1
+ export * from './animation'
2
+ export * from './array'
3
+ export * from './clone'
4
+ export * from './compose'
5
+ export * from './coordinate'
6
+ export * from './element'
7
+ export * from './event'
8
+ export * from './globalThisPolyfill'
9
+ export * from './instanceof'
10
+ export * from './keycode'
11
+ export * from './lru'
12
+ export * from './observer'
13
+ export * from './request-idle'
14
+ export * from './scroller'
15
+ export * from './subscribable'
16
+ export * from './types'
17
+ export * from './uid'
@@ -1 +1 @@
1
- export declare const instOf: (value: any, cls: any) => boolean;
1
+ export declare const instOf: (value: any, cls: any) => boolean
package/esm/instanceof.js CHANGED
@@ -1,11 +1,10 @@
1
- import { isStr, isFn } from './types';
2
- import { globalThisPolyfill } from './globalThisPolyfill';
1
+ import { globalThisPolyfill } from './globalThisPolyfill'
2
+ import { isFn, isStr } from './types'
3
3
  export const instOf = (value, cls) => {
4
- if (isFn(cls))
5
- return value instanceof cls;
6
- if (isStr(cls))
7
- return globalThisPolyfill[cls]
8
- ? value instanceof globalThisPolyfill[cls]
9
- : false;
10
- return false;
11
- };
4
+ if (isFn(cls)) return value instanceof cls
5
+ if (isStr(cls))
6
+ return globalThisPolyfill[cls]
7
+ ? value instanceof globalThisPolyfill[cls]
8
+ : false
9
+ return false
10
+ }