lib0 0.2.42 → 0.2.45

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 (156) hide show
  1. package/README.md +128 -72
  2. package/bin/gendocs.js +1 -1
  3. package/cache.d.ts +51 -0
  4. package/cache.d.ts.map +1 -0
  5. package/cache.js +197 -0
  6. package/cache.test.d.ts +3 -0
  7. package/cache.test.d.ts.map +1 -0
  8. package/component.d.ts +4 -1
  9. package/component.d.ts.map +1 -1
  10. package/component.js +4 -1
  11. package/diff.d.ts +5 -0
  12. package/diff.d.ts.map +1 -1
  13. package/diff.js +47 -10
  14. package/diff.test.d.ts +1 -0
  15. package/diff.test.d.ts.map +1 -1
  16. package/dist/{broadcastchannel-8a61b21a.cjs → broadcastchannel-7da37795.cjs} +2 -2
  17. package/dist/{broadcastchannel-8a61b21a.cjs.map → broadcastchannel-7da37795.cjs.map} +1 -1
  18. package/dist/broadcastchannel.cjs +5 -5
  19. package/dist/{buffer-ac2cdedf.cjs → buffer-b0dea3b0.cjs} +4 -4
  20. package/dist/{buffer-ac2cdedf.cjs.map → buffer-b0dea3b0.cjs.map} +1 -1
  21. package/dist/buffer.cjs +4 -4
  22. package/dist/cache.cjs +205 -0
  23. package/dist/cache.cjs.map +1 -0
  24. package/dist/cache.d.ts +51 -0
  25. package/dist/cache.d.ts.map +1 -0
  26. package/dist/cache.test.d.ts +3 -0
  27. package/dist/cache.test.d.ts.map +1 -0
  28. package/dist/component.cjs +7 -4
  29. package/dist/component.cjs.map +1 -1
  30. package/dist/component.d.ts +4 -1
  31. package/dist/component.d.ts.map +1 -1
  32. package/dist/decoding.cjs +4 -4
  33. package/dist/{diff-75787d87.cjs → diff-233747fa.cjs} +51 -12
  34. package/dist/diff-233747fa.cjs.map +1 -0
  35. package/dist/diff.cjs +2 -1
  36. package/dist/diff.cjs.map +1 -1
  37. package/dist/diff.d.ts +5 -0
  38. package/dist/diff.d.ts.map +1 -1
  39. package/dist/diff.test.d.ts +1 -0
  40. package/dist/diff.test.d.ts.map +1 -1
  41. package/dist/dom.d.ts.map +1 -1
  42. package/dist/encoding.cjs +4 -4
  43. package/dist/{environment-7e2ffaea.cjs → environment-60b83194.cjs} +2 -2
  44. package/dist/{environment-7e2ffaea.cjs.map → environment-60b83194.cjs.map} +1 -1
  45. package/dist/environment.cjs +2 -2
  46. package/dist/{error-55a9a8c8.cjs → error-873c9cbf.cjs} +4 -4
  47. package/dist/error-873c9cbf.cjs.map +1 -0
  48. package/dist/error.cjs +1 -1
  49. package/dist/error.d.ts.map +1 -1
  50. package/dist/index.cjs +13 -13
  51. package/dist/{indexeddb-44227700.cjs → indexeddb-5b4b0e13.cjs} +27 -25
  52. package/dist/indexeddb-5b4b0e13.cjs.map +1 -0
  53. package/dist/indexeddb.cjs +3 -3
  54. package/dist/indexeddb.d.ts +2 -2
  55. package/dist/indexeddb.d.ts.map +1 -1
  56. package/dist/isomorphic.cjs +2 -6
  57. package/dist/isomorphic.cjs.map +1 -1
  58. package/dist/list.cjs +172 -0
  59. package/dist/list.cjs.map +1 -0
  60. package/dist/list.d.ts +33 -0
  61. package/dist/list.d.ts.map +1 -0
  62. package/dist/list.test.d.ts +4 -0
  63. package/dist/list.test.d.ts.map +1 -0
  64. package/dist/{logging-7cc36806.cjs → logging-f6d41f58.cjs} +2 -2
  65. package/dist/{logging-7cc36806.cjs.map → logging-f6d41f58.cjs.map} +1 -1
  66. package/dist/logging.cjs +3 -3
  67. package/dist/{number-24f1eabe.cjs → number-e62129bc.cjs} +5 -2
  68. package/dist/number-e62129bc.cjs.map +1 -0
  69. package/dist/number.cjs +2 -1
  70. package/dist/number.cjs.map +1 -1
  71. package/dist/number.d.ts +1 -0
  72. package/dist/number.d.ts.map +1 -1
  73. package/dist/observable.cjs +1 -1
  74. package/dist/{prng-695120cc.cjs → prng-25602bac.cjs} +3 -3
  75. package/dist/{prng-695120cc.cjs.map → prng-25602bac.cjs.map} +1 -1
  76. package/dist/prng.cjs +5 -5
  77. package/dist/{promise-f0a086b2.cjs → promise-1a9fe712.cjs} +10 -1
  78. package/dist/{promise-f0a086b2.cjs.map → promise-1a9fe712.cjs.map} +1 -1
  79. package/dist/promise.cjs +2 -1
  80. package/dist/promise.cjs.map +1 -1
  81. package/dist/promise.d.ts +1 -0
  82. package/dist/promise.d.ts.map +1 -1
  83. package/dist/queue.cjs +3 -0
  84. package/dist/queue.cjs.map +1 -1
  85. package/dist/queue.d.ts.map +1 -1
  86. package/dist/queue.test.d.ts.map +1 -1
  87. package/dist/set-b596ef38.cjs +49 -0
  88. package/dist/set-b596ef38.cjs.map +1 -0
  89. package/dist/set.cjs +3 -1
  90. package/dist/set.cjs.map +1 -1
  91. package/dist/set.d.ts +2 -0
  92. package/dist/set.d.ts.map +1 -1
  93. package/dist/set.test.d.ts +2 -0
  94. package/dist/set.test.d.ts.map +1 -1
  95. package/dist/{string-f3c3d805.cjs → string-ad04f734.cjs} +12 -2
  96. package/dist/{string-f3c3d805.cjs.map → string-ad04f734.cjs.map} +1 -1
  97. package/dist/string.cjs +3 -4
  98. package/dist/string.cjs.map +1 -1
  99. package/dist/string.d.ts +1 -0
  100. package/dist/string.d.ts.map +1 -1
  101. package/dist/string.test.d.ts +1 -0
  102. package/dist/string.test.d.ts.map +1 -1
  103. package/dist/test.cjs +779 -125
  104. package/dist/test.cjs.map +1 -1
  105. package/dist/test.js +780 -126
  106. package/dist/test.js.map +1 -1
  107. package/dist/testing.cjs +12 -9
  108. package/dist/testing.cjs.map +1 -1
  109. package/dist/testing.d.ts.map +1 -1
  110. package/dist/{websocket-bfe7f545.cjs → websocket-08bd4c7b.cjs} +1 -1
  111. package/dist/{websocket-bfe7f545.cjs.map → websocket-08bd4c7b.cjs.map} +1 -1
  112. package/dist/websocket.cjs +2 -2
  113. package/dist/websocket.d.ts +1 -1
  114. package/dist/websocket.d.ts.map +1 -1
  115. package/dom.d.ts.map +1 -1
  116. package/error.d.ts.map +1 -1
  117. package/error.js +3 -3
  118. package/indexeddb.d.ts +2 -2
  119. package/indexeddb.d.ts.map +1 -1
  120. package/indexeddb.js +25 -23
  121. package/list.d.ts +33 -0
  122. package/list.d.ts.map +1 -0
  123. package/list.js +155 -0
  124. package/list.test.d.ts +4 -0
  125. package/list.test.d.ts.map +1 -0
  126. package/number.d.ts +1 -0
  127. package/number.d.ts.map +1 -1
  128. package/number.js +1 -0
  129. package/package.json +15 -3
  130. package/promise.d.ts +1 -0
  131. package/promise.d.ts.map +1 -1
  132. package/promise.js +7 -0
  133. package/queue.d.ts.map +1 -1
  134. package/queue.js +3 -0
  135. package/queue.test.d.ts.map +1 -1
  136. package/set.d.ts +2 -0
  137. package/set.d.ts.map +1 -1
  138. package/set.js +18 -0
  139. package/set.test.d.ts +2 -0
  140. package/set.test.d.ts.map +1 -1
  141. package/string.d.ts +1 -0
  142. package/string.d.ts.map +1 -1
  143. package/string.js +8 -0
  144. package/string.test.d.ts +1 -0
  145. package/string.test.d.ts.map +1 -1
  146. package/test.js +7 -1
  147. package/testing.d.ts.map +1 -1
  148. package/testing.js +5 -2
  149. package/websocket.d.ts +1 -1
  150. package/websocket.d.ts.map +1 -1
  151. package/dist/diff-75787d87.cjs.map +0 -1
  152. package/dist/error-55a9a8c8.cjs.map +0 -1
  153. package/dist/indexeddb-44227700.cjs.map +0 -1
  154. package/dist/number-24f1eabe.cjs.map +0 -1
  155. package/dist/set-7ae96d21.cjs +0 -27
  156. package/dist/set-7ae96d21.cjs.map +0 -1
package/cache.js ADDED
@@ -0,0 +1,197 @@
1
+
2
+ /* eslint-env browser */
3
+
4
+ /**
5
+ * An implementation of a map which has keys that expire.
6
+ *
7
+ * @module cache
8
+ */
9
+
10
+ import * as list from './list.js'
11
+ import * as map from './map.js'
12
+ import * as time from './time.js'
13
+
14
+ /**
15
+ * @template K, V
16
+ *
17
+ * @implements {list.ListNode}
18
+ */
19
+ class Entry {
20
+ /**
21
+ * @param {K} key
22
+ * @param {V | Promise<V>} val
23
+ */
24
+ constructor (key, val) {
25
+ /**
26
+ * @type {this | null}
27
+ */
28
+ this.prev = null
29
+ /**
30
+ * @type {this | null}
31
+ */
32
+ this.next = null
33
+ this.created = time.getUnixTime()
34
+ this.val = val
35
+ this.key = key
36
+ }
37
+ }
38
+
39
+ /**
40
+ * @template K, V
41
+ */
42
+ export class Cache {
43
+ /**
44
+ * @param {number} timeout
45
+ */
46
+ constructor (timeout) {
47
+ this.timeout = timeout
48
+ /**
49
+ * @type list.List<Entry<K, V>>
50
+ */
51
+ this._q = list.create()
52
+ /**
53
+ * @type {Map<K, Entry<K, V>>}
54
+ */
55
+ this._map = map.create()
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @template K, V
61
+ *
62
+ * @param {Cache<K, V>} cache
63
+ * @return {number} Returns the current timestamp
64
+ */
65
+ export const removeStale = cache => {
66
+ const now = time.getUnixTime()
67
+ const q = cache._q
68
+ while (q.start && now - q.start.created > cache.timeout) {
69
+ cache._map.delete(q.start.key)
70
+ list.popFront(q)
71
+ }
72
+ return now
73
+ }
74
+
75
+ /**
76
+ * @template K, V
77
+ *
78
+ * @param {Cache<K, V>} cache
79
+ * @param {K} key
80
+ * @param {V} value
81
+ */
82
+ export const set = (cache, key, value) => {
83
+ const now = removeStale(cache)
84
+ const q = cache._q
85
+ const n = cache._map.get(key)
86
+ if (n) {
87
+ list.removeNode(q, n)
88
+ list.pushEnd(q, n)
89
+ n.created = now
90
+ n.val = value
91
+ } else {
92
+ const node = new Entry(key, value)
93
+ list.pushEnd(q, node)
94
+ cache._map.set(key, node)
95
+ }
96
+ }
97
+
98
+ /**
99
+ * @template K, V
100
+ *
101
+ * @param {Cache<K, V>} cache
102
+ * @param {K} key
103
+ * @return {Entry<K, V> | undefined}
104
+ */
105
+ const getNode = (cache, key) => {
106
+ const now = removeStale(cache)
107
+ const q = cache._q
108
+ const n = cache._map.get(key)
109
+ if (n) {
110
+ list.removeNode(q, n)
111
+ list.pushEnd(q, n)
112
+ n.created = now
113
+ return n
114
+ }
115
+ }
116
+
117
+ /**
118
+ * @template K, V
119
+ *
120
+ * @param {Cache<K, V>} cache
121
+ * @param {K} key
122
+ * @return {V | undefined}
123
+ */
124
+ export const get = (cache, key) => {
125
+ const n = getNode(cache, key)
126
+ return n && !(n.val instanceof Promise) ? n.val : undefined
127
+ }
128
+
129
+ /**
130
+ * Works well in conjunktion with setIfUndefined which has an async init function.
131
+ * Using getAsync & setIfUndefined ensures that the init function is only called once.
132
+ *
133
+ * @template K, V
134
+ *
135
+ * @param {Cache<K, V>} cache
136
+ * @param {K} key
137
+ * @return {V | Promise<V> | undefined}
138
+ */
139
+ export const getAsync = (cache, key) => {
140
+ const n = getNode(cache, key)
141
+ return n ? n.val : undefined
142
+ }
143
+
144
+ /**
145
+ * @template K, V
146
+ *
147
+ * @param {Cache<K, V>} cache
148
+ * @param {K} key
149
+ */
150
+ export const remove = (cache, key) => {
151
+ const n = cache._map.get(key)
152
+ if (n) {
153
+ list.removeNode(cache._q, n)
154
+ cache._map.delete(key)
155
+ return n.val && !(n.val instanceof Promise) ? n.val : undefined
156
+ }
157
+ }
158
+
159
+ /**
160
+ * @template K, V
161
+ *
162
+ * @param {Cache<K, V>} cache
163
+ * @param {K} key
164
+ * @param {function():Promise<V>} init
165
+ * @param {boolean} removeNull Optional argument that automatically removes values that resolve to null/undefined from the cache.
166
+ * @return {Promise<V> | V}
167
+ */
168
+ export const setIfUndefined = (cache, key, init, removeNull = false) => {
169
+ const now = removeStale(cache)
170
+ const q = cache._q
171
+ const n = cache._map.get(key)
172
+ if (n) {
173
+ list.removeNode(q, n)
174
+ list.pushEnd(q, n)
175
+ n.created = now
176
+ return n.val
177
+ } else {
178
+ const p = init()
179
+ const node = new Entry(key, p)
180
+ list.pushEnd(q, node)
181
+ cache._map.set(key, node)
182
+ p.then(v => {
183
+ if (p === node.val) {
184
+ node.val = v
185
+ }
186
+ if (removeNull && v == null) {
187
+ remove(cache, key)
188
+ }
189
+ })
190
+ return p
191
+ }
192
+ }
193
+
194
+ /**
195
+ * @param {number} timeout
196
+ */
197
+ export const create = timeout => new Cache(timeout)
@@ -0,0 +1,3 @@
1
+ export function testCache(tc: t.TestCase): Promise<void>;
2
+ import * as t from "./testing.js";
3
+ //# sourceMappingURL=cache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.test.d.ts","sourceRoot":"","sources":["cache.test.js"],"names":[],"mappings":"AAQO,8BAFI,EAAE,QAAQ,iBAiEpB"}
package/component.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ /**
2
+ * @type {CustomElementRegistry}
3
+ */
1
4
  export const registry: CustomElementRegistry;
2
5
  export function define(name: string, constr: any, opts?: ElementDefinitionOptions | undefined): void;
3
- export function whenDefined(name: string): Promise<void>;
6
+ export function whenDefined(name: string): Promise<CustomElementConstructor>;
4
7
  /**
5
8
  * @template S
6
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["component.js"],"names":[],"mappings":"AAiBA,6CAAsC;AAO/B,6BAJI,MAAM,UACN,GAAG,qDAGmE;AAM1E,kCAHI,MAAM,GACL,QAAQ,IAAI,CAAC,CAEoC;AAM7D;;GAEG;AACH;IACE;;OAEG;IACH,mCAUC;IARC;;OAEG;IACH,OAFU,CAAC,GAAC,IAAI,CAEuB;IACvC;;OAEG;IACH,WAFU,GAAG,CAEM;IAGrB;;;OAGG;IACH,gBAHW,CAAC,gDAGgC;IAC5C;;QAEI;IACJ,yBAFY,GAAG,QAEc;CAC9B;AA6DM,yCAJI,MAAM,2GAEL,oBAAoB,CAqM/B;AAKM,qEAWN;AANQ,2CAKN;AALM,kDAKN;;;;;;;;;;;;;;;;;;;4BAvOoB,CAAC,QAAC,CAAC,GAAC,IAAI,QAAC,cAAc,CAAC,CAAC,KAAE,IAAI;;;;;;;4BAEjB,GAAG,QAAE,GAAG,KAAE,MAAM;;;;;;;;;;;;;;4BAMf,WAAW,QAAE,cAAc,GAAG,CAAC,KAAE,OAAO,GAAC,IAAI;;;;;;oBAE5D,CAAC,QAAE,CAAC,QAAE,cAAc,CAAC,CAAC;YAAS,MAAM,GAAC,MAAM"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["component.js"],"names":[],"mappings":"AAiBA;;GAEG;AACH,uBAFU,qBAAqB,CAEO;AAO/B,6BAJI,MAAM,UACN,GAAG,qDAGmE;AAM1E,kCAHI,MAAM,GACL,QAAQ,wBAAwB,CAAC,CAEgB;AAM7D;;GAEG;AACH;IACE;;OAEG;IACH,mCAUC;IARC;;OAEG;IACH,OAFU,CAAC,GAAC,IAAI,CAEuB;IACvC;;OAEG;IACH,WAFU,GAAG,CAEM;IAGrB;;;OAGG;IACH,gBAHW,CAAC,gDAGgC;IAC5C;;QAEI;IACJ,yBAFY,GAAG,QAEc;CAC9B;AA6DM,yCAJI,MAAM,2GAEL,oBAAoB,CAqM/B;AAKM,qEAWN;AANQ,2CAKN;AALM,kDAKN;;;;;;;;;;;;;;;;;;;4BAvOoB,CAAC,QAAC,CAAC,GAAC,IAAI,QAAC,cAAc,CAAC,CAAC,KAAE,IAAI;;;;;;;4BAEjB,GAAG,QAAE,GAAG,KAAE,MAAM;;;;;;;;;;;;;;4BAMf,WAAW,QAAE,cAAc,GAAG,CAAC,KAAE,OAAO,GAAC,IAAI;;;;;;oBAE5D,CAAC,QAAE,CAAC,QAAE,cAAc,CAAC,CAAC;YAAS,MAAM,GAAC,MAAM"}
package/component.js CHANGED
@@ -15,6 +15,9 @@ import * as array from './array.js'
15
15
  import * as number from './number.js'
16
16
  import * as func from './function.js'
17
17
 
18
+ /**
19
+ * @type {CustomElementRegistry}
20
+ */
18
21
  export const registry = customElements
19
22
 
20
23
  /**
@@ -26,7 +29,7 @@ export const define = (name, constr, opts) => registry.define(name, constr, opts
26
29
 
27
30
  /**
28
31
  * @param {string} name
29
- * @return {Promise<void>}
32
+ * @return {Promise<CustomElementConstructor>}
30
33
  */
31
34
  export const whenDefined = name => registry.whenDefined(name)
32
35
 
package/diff.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  export function simpleDiffString(a: string, b: string): SimpleDiff<string>;
2
2
  export function simpleDiff(a: string, b: string): SimpleDiff<string>;
3
3
  export function simpleDiffArray<T>(a: T[], b: T[], compare?: ((arg0: T, arg1: T) => boolean) | undefined): SimpleDiff<T[]>;
4
+ export function simpleDiffStringWithCursor(a: string, b: string, cursor: number): {
5
+ index: number;
6
+ remove: number;
7
+ insert: string;
8
+ };
4
9
  /**
5
10
  * A SimpleDiff describes a change on a String.
6
11
  *
package/diff.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["diff.js"],"names":[],"mappings":"AAwCO,oCAJI,MAAM,KACN,MAAM,GACL,WAAW,MAAM,CAAC,CAmB7B;AAjBM,8BAJI,MAAM,KACN,MAAM,GACL,WAAW,MAAM,CAAC,CAmB7B;AAuBM,oFAHmB,OAAO,gCAoBhC;;;;;;;;;;;;;;;;;;;;;;;;;;;YAzEa,CAAC"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["diff.js"],"names":[],"mappings":"AAwCO,oCAJI,MAAM,KACN,MAAM,GACL,WAAW,MAAM,CAAC,CAgB7B;AAdM,8BAJI,MAAM,KACN,MAAM,GACL,WAAW,MAAM,CAAC,CAgB7B;AAuBM,oFAHmB,OAAO,gCAiBhC;AASM,8CAJI,MAAM,KACN,MAAM,UACN,MAAM;;;;EAoChB;;;;;;;;;;;;;;;;;;;;;;;;;;;YA9Ga,CAAC"}
package/diff.js CHANGED
@@ -44,11 +44,8 @@ export const simpleDiffString = (a, b) => {
44
44
  while (left < a.length && left < b.length && a[left] === b[left]) {
45
45
  left++
46
46
  }
47
- if (left !== a.length || left !== b.length) {
48
- // Only check right if a !== b
49
- while (right + left < a.length && right + left < b.length && a[a.length - right - 1] === b[b.length - right - 1]) {
50
- right++
51
- }
47
+ while (right + left < a.length && right + left < b.length && a[a.length - right - 1] === b[b.length - right - 1]) {
48
+ right++
52
49
  }
53
50
  return {
54
51
  index: left,
@@ -84,11 +81,51 @@ export const simpleDiffArray = (a, b, compare = equalityStrict) => {
84
81
  while (left < a.length && left < b.length && compare(a[left], b[left])) {
85
82
  left++
86
83
  }
87
- if (left !== a.length || left !== b.length) {
88
- // Only check right if a !== b
89
- while (right + left < a.length && right + left < b.length && compare(a[a.length - right - 1], b[b.length - right - 1])) {
90
- right++
91
- }
84
+ while (right + left < a.length && right + left < b.length && compare(a[a.length - right - 1], b[b.length - right - 1])) {
85
+ right++
86
+ }
87
+ return {
88
+ index: left,
89
+ remove: a.length - left - right,
90
+ insert: b.slice(left, b.length - right)
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Diff text and try to diff at the current cursor position.
96
+ *
97
+ * @param {string} a
98
+ * @param {string} b
99
+ * @param {number} cursor This should refer to the current left cursor-range position
100
+ */
101
+ export const simpleDiffStringWithCursor = (a, b, cursor) => {
102
+ let left = 0 // number of same characters counting from left
103
+ let right = 0 // number of same characters counting from right
104
+ // Iterate left to the right until we find a changed character
105
+ // First iteration considers the current cursor position
106
+ while (
107
+ left < a.length &&
108
+ left < b.length &&
109
+ a[left] === b[left] &&
110
+ left < cursor
111
+ ) {
112
+ left++
113
+ }
114
+ // Iterate right to the left until we find a changed character
115
+ while (
116
+ right + left < a.length &&
117
+ right + left < b.length &&
118
+ a[a.length - right - 1] === b[b.length - right - 1]
119
+ ) {
120
+ right++
121
+ }
122
+ // Try to iterate left further to the right without caring about the current cursor position
123
+ while (
124
+ right + left < a.length &&
125
+ right + left < b.length &&
126
+ a[left] === b[left]
127
+ ) {
128
+ left++
92
129
  }
93
130
  return {
94
131
  index: left,
package/diff.test.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export function testDiffing(tc: t.TestCase): void;
2
2
  export function testRepeatDiffing(tc: t.TestCase): void;
3
+ export function testSimpleDiffWithCursor(tc: t.TestCase): void;
3
4
  export function testArrayDiffing(tc: t.TestCase): void;
4
5
  import * as t from "./testing.js";
5
6
  //# sourceMappingURL=diff.test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.test.d.ts","sourceRoot":"","sources":["diff.test.js"],"names":[],"mappings":"AAqBO,gCAFI,EAAE,QAAQ,QAWpB;AAKM,sCAFI,EAAE,QAAQ,QAQpB;AAKM,qCAFI,EAAE,QAAQ,QAQpB"}
1
+ {"version":3,"file":"diff.test.d.ts","sourceRoot":"","sources":["diff.test.js"],"names":[],"mappings":"AAuBO,gCAFI,EAAE,QAAQ,QAWpB;AAKM,sCAFI,EAAE,QAAQ,QAQpB;AAKM,6CAFI,EAAE,QAAQ,QA8BpB;AAKM,qCAFI,EAAE,QAAQ,QAQpB"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var map = require('./map-28a001c9.cjs');
4
- var encoding = require('./buffer-ac2cdedf.cjs');
4
+ var encoding = require('./buffer-b0dea3b0.cjs');
5
5
  var storage = require('./storage.cjs');
6
6
 
7
7
  /* eslint-env browser */
@@ -100,4 +100,4 @@ exports.broadcastchannel = broadcastchannel;
100
100
  exports.publish = publish;
101
101
  exports.subscribe = subscribe;
102
102
  exports.unsubscribe = unsubscribe;
103
- //# sourceMappingURL=broadcastchannel-8a61b21a.cjs.map
103
+ //# sourceMappingURL=broadcastchannel-7da37795.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"broadcastchannel-8a61b21a.cjs","sources":["../broadcastchannel.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.\n *\n * ```js\n * // In browser window A:\n * broadcastchannel.subscribe('my events', data => console.log(data))\n * broadcastchannel.publish('my events', 'Hello world!') // => A: 'Hello world!' fires synchronously in same tab\n *\n * // In browser window B:\n * broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from tab B'\n * ```\n *\n * @module broadcastchannel\n */\n\n// @todo before next major: use Uint8Array instead as buffer object\n\nimport * as map from './map.js'\nimport * as buffer from './buffer.js'\nimport * as storage from './storage.js'\n\n/**\n * @typedef {Object} Channel\n * @property {Set<Function>} Channel.subs\n * @property {any} Channel.bc\n */\n\n/**\n * @type {Map<string, Channel>}\n */\nconst channels = new Map()\n\nclass LocalStoragePolyfill {\n /**\n * @param {string} room\n */\n constructor (room) {\n this.room = room\n /**\n * @type {null|function({data:ArrayBuffer}):void}\n */\n this.onmessage = null\n storage.onChange(e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') }))\n }\n\n /**\n * @param {ArrayBuffer} buf\n */\n postMessage (buf) {\n storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))\n }\n}\n\n// Use BroadcastChannel or Polyfill\nconst BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel\n\n/**\n * @param {string} room\n * @return {Channel}\n */\nconst getChannel = room =>\n map.setIfUndefined(channels, room, () => {\n const subs = new Set()\n const bc = new BC(room)\n /**\n * @param {{data:ArrayBuffer}} e\n */\n bc.onmessage = e => subs.forEach(sub => sub(e.data))\n return {\n bc, subs\n }\n })\n\n/**\n * Subscribe to global `publish` events.\n *\n * @function\n * @param {string} room\n * @param {function(any):any} f\n */\nexport const subscribe = (room, f) => getChannel(room).subs.add(f)\n\n/**\n * Unsubscribe from `publish` global events.\n *\n * @function\n * @param {string} room\n * @param {function(any):any} f\n */\nexport const unsubscribe = (room, f) => getChannel(room).subs.delete(f)\n\n/**\n * Publish data to all subscribers (including subscribers on this tab)\n *\n * @function\n * @param {string} room\n * @param {any} data\n */\nexport const publish = (room, data) => {\n const c = getChannel(room)\n c.bc.postMessage(data)\n c.subs.forEach(sub => sub(data))\n}\n"],"names":["storage.onChange","buffer.fromBase64","storage.varStorage","buffer.toBase64","buffer.createUint8ArrayFromArrayBuffer","map.setIfUndefined"],"mappings":";;;;;;AAAA;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAE;AAC1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AAC,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAC;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAC;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK;AACvC,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAC;AAC5B,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,EAAC;AACxB,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAC;AAClC;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"broadcastchannel-7da37795.cjs","sources":["../broadcastchannel.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.\n *\n * ```js\n * // In browser window A:\n * broadcastchannel.subscribe('my events', data => console.log(data))\n * broadcastchannel.publish('my events', 'Hello world!') // => A: 'Hello world!' fires synchronously in same tab\n *\n * // In browser window B:\n * broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from tab B'\n * ```\n *\n * @module broadcastchannel\n */\n\n// @todo before next major: use Uint8Array instead as buffer object\n\nimport * as map from './map.js'\nimport * as buffer from './buffer.js'\nimport * as storage from './storage.js'\n\n/**\n * @typedef {Object} Channel\n * @property {Set<Function>} Channel.subs\n * @property {any} Channel.bc\n */\n\n/**\n * @type {Map<string, Channel>}\n */\nconst channels = new Map()\n\nclass LocalStoragePolyfill {\n /**\n * @param {string} room\n */\n constructor (room) {\n this.room = room\n /**\n * @type {null|function({data:ArrayBuffer}):void}\n */\n this.onmessage = null\n storage.onChange(e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') }))\n }\n\n /**\n * @param {ArrayBuffer} buf\n */\n postMessage (buf) {\n storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))\n }\n}\n\n// Use BroadcastChannel or Polyfill\nconst BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel\n\n/**\n * @param {string} room\n * @return {Channel}\n */\nconst getChannel = room =>\n map.setIfUndefined(channels, room, () => {\n const subs = new Set()\n const bc = new BC(room)\n /**\n * @param {{data:ArrayBuffer}} e\n */\n bc.onmessage = e => subs.forEach(sub => sub(e.data))\n return {\n bc, subs\n }\n })\n\n/**\n * Subscribe to global `publish` events.\n *\n * @function\n * @param {string} room\n * @param {function(any):any} f\n */\nexport const subscribe = (room, f) => getChannel(room).subs.add(f)\n\n/**\n * Unsubscribe from `publish` global events.\n *\n * @function\n * @param {string} room\n * @param {function(any):any} f\n */\nexport const unsubscribe = (room, f) => getChannel(room).subs.delete(f)\n\n/**\n * Publish data to all subscribers (including subscribers on this tab)\n *\n * @function\n * @param {string} room\n * @param {any} data\n */\nexport const publish = (room, data) => {\n const c = getChannel(room)\n c.bc.postMessage(data)\n c.subs.forEach(sub => sub(data))\n}\n"],"names":["storage.onChange","buffer.fromBase64","storage.varStorage","buffer.toBase64","buffer.createUint8ArrayFromArrayBuffer","map.setIfUndefined"],"mappings":";;;;;;AAAA;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAE;AAC1B;AACA,MAAM,oBAAoB,CAAC;AAC3B;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE;AACrB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAI;AACpB;AACA;AACA;AACA,IAAI,IAAI,CAAC,SAAS,GAAG,KAAI;AACzB,IAAIA,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK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AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK;AACvC,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAC;AAC5B,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,EAAC;AACxB,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAC;AAClC;;;;;;;;;;;;;;"}
@@ -3,15 +3,15 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('./map-28a001c9.cjs');
6
- require('./buffer-ac2cdedf.cjs');
6
+ require('./buffer-b0dea3b0.cjs');
7
7
  require('./storage.cjs');
8
- var broadcastchannel = require('./broadcastchannel-8a61b21a.cjs');
9
- require('./string-f3c3d805.cjs');
10
- require('./environment-7e2ffaea.cjs');
8
+ var broadcastchannel = require('./broadcastchannel-7da37795.cjs');
9
+ require('./string-ad04f734.cjs');
10
+ require('./environment-60b83194.cjs');
11
11
  require('./conditions-fb475c70.cjs');
12
12
  require('./binary-ac8e39e2.cjs');
13
13
  require('./math-08e068f9.cjs');
14
- require('./number-24f1eabe.cjs');
14
+ require('./number-e62129bc.cjs');
15
15
 
16
16
 
17
17
 
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var string = require('./string-f3c3d805.cjs');
4
- var environment = require('./environment-7e2ffaea.cjs');
3
+ var string = require('./string-ad04f734.cjs');
4
+ var environment = require('./environment-60b83194.cjs');
5
5
  var binary = require('./binary-ac8e39e2.cjs');
6
6
  var math = require('./math-08e068f9.cjs');
7
- var number = require('./number-24f1eabe.cjs');
7
+ var number = require('./number-e62129bc.cjs');
8
8
 
9
9
  /**
10
10
  * Efficient schema-less binary encoding with support for variable length encoding.
@@ -1740,4 +1740,4 @@ exports.writeVarInt = writeVarInt;
1740
1740
  exports.writeVarString = writeVarString;
1741
1741
  exports.writeVarUint = writeVarUint;
1742
1742
  exports.writeVarUint8Array = writeVarUint8Array;
1743
- //# sourceMappingURL=buffer-ac2cdedf.cjs.map
1743
+ //# sourceMappingURL=buffer-b0dea3b0.cjs.map