hyperscript-rxjs 1.3.15 → 1.3.16

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 (278) hide show
  1. package/dist/hyperscript-rxjs.cjs +4114 -0
  2. package/dist/hyperscript-rxjs.d.ts +1438 -0
  3. package/package.json +21 -12
  4. package/src/array/advance.d.ts +0 -9
  5. package/src/array/advance.js +0 -13
  6. package/src/array/advance.test.js +0 -12
  7. package/src/array/arrayInsert.d.ts +0 -8
  8. package/src/array/arrayInsert.js +0 -13
  9. package/src/array/arrayInsert.test.js +0 -13
  10. package/src/array/arrayRemove.d.ts +0 -7
  11. package/src/array/arrayRemove.js +0 -15
  12. package/src/array/arrayRemove.test.js +0 -13
  13. package/src/array/findLastIndex.d.ts +0 -14
  14. package/src/array/findLastIndex.js +0 -20
  15. package/src/array/findLastIndex.test.js +0 -41
  16. package/src/array/index.d.ts +0 -9
  17. package/src/array/index.js +0 -9
  18. package/src/array/isRange.d.ts +0 -7
  19. package/src/array/isRange.js +0 -15
  20. package/src/array/isRange.test.js +0 -6
  21. package/src/array/rangeArray.d.ts +0 -7
  22. package/src/array/rangeArray.js +0 -10
  23. package/src/array/rangeArray.test.js +0 -11
  24. package/src/array/unwrapArgs.d.ts +0 -10
  25. package/src/array/unwrapArgs.js +0 -15
  26. package/src/array/unwrapArgs.test.js +0 -33
  27. package/src/array/zipArray.d.ts +0 -11
  28. package/src/array/zipArray.js +0 -24
  29. package/src/array/zipArray.test.js +0 -16
  30. package/src/comparers/Comparer.d.ts +0 -101
  31. package/src/comparers/Comparer.js +0 -149
  32. package/src/comparers/comparers.d.ts +0 -21
  33. package/src/comparers/comparers.js +0 -10
  34. package/src/comparers/differenceSet.d.ts +0 -20
  35. package/src/comparers/differenceSet.js +0 -35
  36. package/src/comparers/differenceSet.test.js +0 -11
  37. package/src/comparers/distinctArray.d.ts +0 -13
  38. package/src/comparers/distinctArray.js +0 -30
  39. package/src/comparers/distinctArray.test.js +0 -10
  40. package/src/comparers/findIndexInSet.d.ts +0 -20
  41. package/src/comparers/findIndexInSet.js +0 -27
  42. package/src/comparers/findIndexInSet.test.js +0 -8
  43. package/src/comparers/groupArrayBy.d.ts +0 -19
  44. package/src/comparers/groupArrayBy.js +0 -29
  45. package/src/comparers/groupArrayBy.test.js +0 -38
  46. package/src/comparers/groupSortedEntries.d.ts +0 -17
  47. package/src/comparers/groupSortedEntries.js +0 -38
  48. package/src/comparers/groupSortedEntries.test.js +0 -46
  49. package/src/comparers/index.d.ts +0 -14
  50. package/src/comparers/index.js +0 -14
  51. package/src/comparers/intersectSet.d.ts +0 -19
  52. package/src/comparers/intersectSet.js +0 -35
  53. package/src/comparers/intersectSet.test.js +0 -14
  54. package/src/comparers/isEqualset.d.ts +0 -22
  55. package/src/comparers/isEqualset.js +0 -33
  56. package/src/comparers/isEqualset.test.js +0 -22
  57. package/src/comparers/isSubset.d.ts +0 -21
  58. package/src/comparers/isSubset.js +0 -33
  59. package/src/comparers/isSubset.test.js +0 -21
  60. package/src/comparers/isSuperset.d.ts +0 -21
  61. package/src/comparers/isSuperset.js +0 -13
  62. package/src/comparers/isSuperset.test.js +0 -21
  63. package/src/comparers/sortedArrayToSet.d.ts +0 -20
  64. package/src/comparers/sortedArrayToSet.js +0 -35
  65. package/src/comparers/sortedArrayToSet.test.js +0 -11
  66. package/src/comparers/unionSet.d.ts +0 -21
  67. package/src/comparers/unionSet.js +0 -34
  68. package/src/comparers/unionSet.test.js +0 -11
  69. package/src/comparison/compareDate.d.ts +0 -8
  70. package/src/comparison/compareDate.js +0 -11
  71. package/src/comparison/compareEntries.d.ts +0 -13
  72. package/src/comparison/compareEntries.js +0 -13
  73. package/src/comparison/compareKey.d.ts +0 -11
  74. package/src/comparison/compareKey.js +0 -25
  75. package/src/comparison/compareKey.test.js +0 -21
  76. package/src/comparison/compareKeyPath.d.ts +0 -15
  77. package/src/comparison/compareKeyPath.js +0 -33
  78. package/src/comparison/compareKeyPath.test.js +0 -28
  79. package/src/comparison/compareNumber.d.ts +0 -11
  80. package/src/comparison/compareNumber.js +0 -27
  81. package/src/comparison/compareNumber.test.js +0 -21
  82. package/src/comparison/defaultCompare.d.ts +0 -8
  83. package/src/comparison/defaultCompare.js +0 -12
  84. package/src/comparison/defaultCompare.test.js +0 -24
  85. package/src/comparison/index.d.ts +0 -7
  86. package/src/comparison/index.js +0 -7
  87. package/src/comparison/infinity.test.js +0 -122
  88. package/src/comparison/typeof.test.js +0 -64
  89. package/src/comparison/types.d.ts +0 -5
  90. package/src/comparison/types.js +0 -11
  91. package/src/deep/Deep.d.ts +0 -58
  92. package/src/deep/Deep.js +0 -267
  93. package/src/deep/Deep.test.js +0 -130
  94. package/src/deep/deepCombineLatest.test.js +0 -36
  95. package/src/deep/deepMerge.test.js +0 -34
  96. package/src/deep/differenceDeep.test.js +0 -31
  97. package/src/deep/freshValueDeep.test.js +0 -17
  98. package/src/deep/index.d.ts +0 -1
  99. package/src/deep/index.js +0 -2
  100. package/src/deep/intersectDeep.test.js +0 -25
  101. package/src/deep/intersectEntries.d.ts +0 -13
  102. package/src/deep/intersectEntries.js +0 -37
  103. package/src/deep/intersectEntries.test.js +0 -20
  104. package/src/deep/objectToDeep.test.js +0 -31
  105. package/src/deep/replaceValueDeep.test.js +0 -21
  106. package/src/deep/unionDeep.test.js +0 -30
  107. package/src/deep/zipValueDeep.test.js +0 -21
  108. package/src/deep-rxjs/ObservableArray.d.ts +0 -55
  109. package/src/deep-rxjs/ObservableArray.js +0 -94
  110. package/src/deep-rxjs/ObservableArray.test.js +0 -117
  111. package/src/deep-rxjs/index.d.ts +0 -2
  112. package/src/deep-rxjs/index.js +0 -2
  113. package/src/deep-rxjs/isRxType.d.ts +0 -9
  114. package/src/deep-rxjs/isRxType.js +0 -15
  115. package/src/deep-rxjs/isRxType.test.js +0 -43
  116. package/src/hyperscript-rxjs/HyperscriptExtensions.d.ts +0 -20
  117. package/src/hyperscript-rxjs/checkbox.d.ts +0 -13
  118. package/src/hyperscript-rxjs/checkbox.js +0 -47
  119. package/src/hyperscript-rxjs/checkbox.test.js +0 -68
  120. package/src/hyperscript-rxjs/choice.d.ts +0 -13
  121. package/src/hyperscript-rxjs/choice.js +0 -24
  122. package/src/hyperscript-rxjs/choice.test.js +0 -108
  123. package/src/hyperscript-rxjs/collapse.d.ts +0 -14
  124. package/src/hyperscript-rxjs/collapse.js +0 -32
  125. package/src/hyperscript-rxjs/collapse.test.js +0 -67
  126. package/src/hyperscript-rxjs/displays/blockLevelFamily.d.ts +0 -5
  127. package/src/hyperscript-rxjs/displays/blockLevelFamily.js +0 -51
  128. package/src/hyperscript-rxjs/displays/getDisplay.d.ts +0 -7
  129. package/src/hyperscript-rxjs/displays/getDisplay.js +0 -51
  130. package/src/hyperscript-rxjs/displays/getDisplay.test.js +0 -56
  131. package/src/hyperscript-rxjs/displays/index.d.ts +0 -3
  132. package/src/hyperscript-rxjs/displays/index.js +0 -3
  133. package/src/hyperscript-rxjs/displays/inlineFamily.d.ts +0 -5
  134. package/src/hyperscript-rxjs/displays/inlineFamily.js +0 -73
  135. package/src/hyperscript-rxjs/flip.d.ts +0 -15
  136. package/src/hyperscript-rxjs/flip.js +0 -29
  137. package/src/hyperscript-rxjs/flip.test.js +0 -85
  138. package/src/hyperscript-rxjs/fragment.d.ts +0 -10
  139. package/src/hyperscript-rxjs/fragment.js +0 -22
  140. package/src/hyperscript-rxjs/fragment.test.js +0 -70
  141. package/src/hyperscript-rxjs/hyperscript.d.ts +0 -15
  142. package/src/hyperscript-rxjs/hyperscript.js +0 -170
  143. package/src/hyperscript-rxjs/hyperscript.test.js +0 -75
  144. package/src/hyperscript-rxjs/index.d.ts +0 -19
  145. package/src/hyperscript-rxjs/index.js +0 -19
  146. package/src/hyperscript-rxjs/multiselect.d.ts +0 -18
  147. package/src/hyperscript-rxjs/multiselect.js +0 -41
  148. package/src/hyperscript-rxjs/multiselect.test.js +0 -121
  149. package/src/hyperscript-rxjs/numberbox.d.ts +0 -14
  150. package/src/hyperscript-rxjs/numberbox.js +0 -73
  151. package/src/hyperscript-rxjs/numberbox.test.js +0 -84
  152. package/src/hyperscript-rxjs/radio.d.ts +0 -15
  153. package/src/hyperscript-rxjs/radio.js +0 -53
  154. package/src/hyperscript-rxjs/radio.test.js +0 -59
  155. package/src/hyperscript-rxjs/select.d.ts +0 -28
  156. package/src/hyperscript-rxjs/select.js +0 -88
  157. package/src/hyperscript-rxjs/select.test.js +0 -101
  158. package/src/hyperscript-rxjs/tabControls/bindTabIndex.d.ts +0 -12
  159. package/src/hyperscript-rxjs/tabControls/bindTabIndex.js +0 -59
  160. package/src/hyperscript-rxjs/tabControls/index.d.ts +0 -8
  161. package/src/hyperscript-rxjs/tabControls/index.js +0 -10
  162. package/src/hyperscript-rxjs/tabControls/tabControl.d.ts +0 -19
  163. package/src/hyperscript-rxjs/tabControls/tabControl.js +0 -40
  164. package/src/hyperscript-rxjs/tabControls/tabControl.test.js +0 -98
  165. package/src/hyperscript-rxjs/tabControls/tabNavItem.d.ts +0 -9
  166. package/src/hyperscript-rxjs/tabControls/tabNavItem.js +0 -30
  167. package/src/hyperscript-rxjs/tabControls/tabPanel.d.ts +0 -9
  168. package/src/hyperscript-rxjs/tabControls/tabPanel.js +0 -21
  169. package/src/hyperscript-rxjs/tabControls/tabRoot.d.ts +0 -7
  170. package/src/hyperscript-rxjs/tabControls/tabRoot.js +0 -26
  171. package/src/hyperscript-rxjs/tags.d.ts +0 -193
  172. package/src/hyperscript-rxjs/tags.js +0 -751
  173. package/src/hyperscript-rxjs/tags.test.js +0 -75
  174. package/src/hyperscript-rxjs/textNode.d.ts +0 -11
  175. package/src/hyperscript-rxjs/textNode.js +0 -51
  176. package/src/hyperscript-rxjs/textNode.test.js +0 -56
  177. package/src/hyperscript-rxjs/textarea.d.ts +0 -17
  178. package/src/hyperscript-rxjs/textarea.js +0 -45
  179. package/src/hyperscript-rxjs/textarea.test.js +0 -52
  180. package/src/hyperscript-rxjs/textbox.d.ts +0 -15
  181. package/src/hyperscript-rxjs/textbox.js +0 -42
  182. package/src/hyperscript-rxjs/textbox.test.js +0 -52
  183. package/src/index.d.ts +0 -19
  184. package/src/index.js +0 -19
  185. package/src/nodes/attachSubscriptionToNode.d.ts +0 -13
  186. package/src/nodes/attachSubscriptionToNode.js +0 -25
  187. package/src/nodes/attachSubscriptionToNode.test.js +0 -73
  188. package/src/nodes/index.d.ts +0 -6
  189. package/src/nodes/index.js +0 -6
  190. package/src/nodes/normalizeChildNodes.d.ts +0 -9
  191. package/src/nodes/normalizeChildNodes.js +0 -15
  192. package/src/nodes/normalizeChildNodes.test.js +0 -55
  193. package/src/nodes/parseHyperscriptArgs.d.ts +0 -10
  194. package/src/nodes/parseHyperscriptArgs.js +0 -57
  195. package/src/nodes/parseHyperscriptArgs.test.js +0 -85
  196. package/src/nodes/pipeEvent.d.ts +0 -15
  197. package/src/nodes/pipeEvent.js +0 -49
  198. package/src/nodes/pipeEvent.test.js +0 -97
  199. package/src/nodes/subscribeEvent.d.ts +0 -15
  200. package/src/nodes/subscribeEvent.js +0 -56
  201. package/src/nodes/subscribeEvent.test.js +0 -88
  202. package/src/object/index.d.ts +0 -10
  203. package/src/object/index.js +0 -11
  204. package/src/object/intersectObject.d.ts +0 -12
  205. package/src/object/intersectObject.js +0 -23
  206. package/src/object/intersectObject.test.js +0 -69
  207. package/src/object/isEmptyObject.d.ts +0 -7
  208. package/src/object/isEmptyObject.js +0 -13
  209. package/src/object/isEmptyObject.test.js +0 -33
  210. package/src/object/isPlainObject.d.ts +0 -11
  211. package/src/object/isPlainObject.js +0 -18
  212. package/src/object/nestedCombineLatest.d.ts +0 -11
  213. package/src/object/nestedCombineLatest.js +0 -18
  214. package/src/object/nestedCombineLatest.test.js +0 -25
  215. package/src/object/nestedMerge.d.ts +0 -11
  216. package/src/object/nestedMerge.js +0 -11
  217. package/src/object/nestedMerge.test.js +0 -61
  218. package/src/object/pickBehaviorSubject.d.ts +0 -13
  219. package/src/object/pickBehaviorSubject.js +0 -81
  220. package/src/object/pickBehaviorSubject.test.js +0 -88
  221. package/src/object/pluckProperty.d.ts +0 -13
  222. package/src/object/pluckProperty.js +0 -24
  223. package/src/object/pluckProperty.test.js +0 -37
  224. package/src/object/restore.d.ts +0 -12
  225. package/src/object/restore.js +0 -69
  226. package/src/object/restore.test.js +0 -124
  227. package/src/object/splitObjectByObservable.d.ts +0 -12
  228. package/src/object/splitObjectByObservable.js +0 -41
  229. package/src/object/splitObjectByObservable.test.js +0 -78
  230. package/src/props/getNestedProperty.d.ts +0 -12
  231. package/src/props/getNestedProperty.js +0 -31
  232. package/src/props/getNestedProperty.test.js +0 -72
  233. package/src/props/index.d.ts +0 -7
  234. package/src/props/index.js +0 -7
  235. package/src/props/parsePropName.d.ts +0 -13
  236. package/src/props/parsePropName.js +0 -45
  237. package/src/props/parsePropName.test.js +0 -67
  238. package/src/props/setProp.d.ts +0 -16
  239. package/src/props/setProp.js +0 -42
  240. package/src/props/setProp.test.js +0 -59
  241. package/src/props/setProps.d.ts +0 -14
  242. package/src/props/setProps.js +0 -47
  243. package/src/props/setProps.test.js +0 -97
  244. package/src/props/subscribeProp.d.ts +0 -16
  245. package/src/props/subscribeProp.js +0 -47
  246. package/src/props/subscribeProp.test.js +0 -81
  247. package/src/ramda/compose.d.ts +0 -10
  248. package/src/ramda/compose.js +0 -36
  249. package/src/ramda/compose.test.js +0 -73
  250. package/src/ramda/cond.d.ts +0 -12
  251. package/src/ramda/cond.js +0 -29
  252. package/src/ramda/cond.test.js +0 -88
  253. package/src/ramda/fold.d.ts +0 -13
  254. package/src/ramda/fold.js +0 -20
  255. package/src/ramda/fold.test.js +0 -51
  256. package/src/ramda/index.d.ts +0 -6
  257. package/src/ramda/index.js +0 -6
  258. package/src/ramda/pipe.d.ts +0 -13
  259. package/src/ramda/pipe.js +0 -27
  260. package/src/ramda/pipe.test.js +0 -77
  261. package/src/ramda/unfold.d.ts +0 -11
  262. package/src/ramda/unfold.js +0 -20
  263. package/src/ramda/unfold.test.js +0 -29
  264. package/src/unquoted-json/ajax.test.js +0 -1074
  265. package/src/unquoted-json/index.d.ts +0 -13
  266. package/src/unquoted-json/index.js +0 -12
  267. package/src/unquoted-json/queryStringify.d.ts +0 -8
  268. package/src/unquoted-json/queryStringify.js +0 -70
  269. package/src/unquoted-json/queryStringify.test.js +0 -110
  270. package/src/unquoted-json/stringifyKey.d.ts +0 -7
  271. package/src/unquoted-json/stringifyKey.js +0 -16
  272. package/src/unquoted-json/stringifyKey.test.js +0 -51
  273. package/src/unquoted-json/stringifyStringValue.d.ts +0 -7
  274. package/src/unquoted-json/stringifyStringValue.js +0 -17
  275. package/src/unquoted-json/stringifyStringValue.test.js +0 -52
  276. package/src/unquoted-json/unquotedJsonStringify.d.ts +0 -7
  277. package/src/unquoted-json/unquotedJsonStringify.js +0 -39
  278. package/src/unquoted-json/unquotedJsonStringify.test.js +0 -52
@@ -1,7 +0,0 @@
1
- export * from "./compareDate"
2
- export * from "./compareEntries"
3
- export * from "./compareKey"
4
- export * from "./compareKeyPath"
5
- export * from "./compareNumber"
6
- export * from "./defaultCompare"
7
- export * from "./types"
@@ -1,7 +0,0 @@
1
- export * from "./compareDate"
2
- export * from "./compareEntries"
3
- export * from "./compareKey"
4
- export * from "./compareKeyPath"
5
- export * from "./compareNumber"
6
- export * from "./defaultCompare"
7
- export * from "./types"
@@ -1,122 +0,0 @@
1
- describe('The definition of Infinity', () => {
2
- test('typeof', () => {
3
- expect(typeof Infinity).toEqual('number')
4
- expect(typeof -Infinity).toEqual('number')
5
- })
6
-
7
- test('Number', () => {
8
- expect(Number.POSITIVE_INFINITY).toEqual(Infinity)
9
- expect(Number.NEGATIVE_INFINITY).toEqual(-Infinity)
10
- })
11
- })
12
-
13
- describe('The properties of Infinity', () => {
14
- test('some examples', () => {
15
- expect(Infinity).toBeGreaterThan(100)
16
- expect(Infinity).toBeGreaterThan(Number.MAX_SAFE_INTEGER)
17
- expect(Infinity).toBeGreaterThan(Number.MAX_VALUE)
18
- expect(Infinity).toBeGreaterThan(100n)
19
-
20
-
21
- })
22
-
23
- test('arithmetical operations', () => {
24
- expect(Infinity + 1).toEqual(Infinity)
25
- expect(Infinity + Infinity).toEqual(Infinity)
26
-
27
- expect(Infinity * 2).toEqual(Infinity)
28
- expect(Infinity * Infinity).toEqual(Infinity)
29
-
30
- expect(Infinity / 2).toEqual(Infinity)
31
- })
32
-
33
- test('result in finite numbers', () => {
34
- expect(10 / Infinity).toEqual(0)
35
- })
36
-
37
- test('results in `Infinity`', () => {
38
- expect(10 / 0).toEqual(Infinity)
39
- })
40
-
41
- test('results in `NaN`', () => {
42
- expect(Infinity / Infinity).toBeNaN()
43
- expect(Infinity % 2).toEqual(NaN)
44
- })
45
- })
46
-
47
- describe('the negative infinity', () => {
48
- test('some examples', () => {
49
- expect(-Infinity).toBeLessThan(100)
50
- expect(-Infinity).toBeLessThan(Number.MIN_SAFE_INTEGER)
51
- expect(-Infinity).toBeLessThan(Number.MIN_VALUE)
52
- expect(-Infinity).toBeLessThan(Infinity)
53
-
54
- })
55
-
56
- test('end up in negative infinity', () => {
57
- expect(Infinity * -2).toEqual(-Infinity)
58
- expect(Infinity / -1).toEqual(-Infinity)
59
- expect(-2 / 0).toEqual(-Infinity)
60
- })
61
-
62
- })
63
-
64
-
65
- describe('Checking for *Infinity*', () => {
66
- test('an infinite value equals to an infinite value of the same sign', () => {
67
- expect(Infinity).toEqual(Infinity)
68
- expect(-Infinity).toEqual(-Infinity)
69
- expect(-Infinity).not.toEqual(Infinity)
70
-
71
- })
72
-
73
- test('whether the provided value is finite', () => {
74
- expect(Number.isFinite(Infinity)).toEqual(false)
75
- expect(Number.isFinite(-Infinity)).toEqual(false)
76
- expect(Number.isFinite(999)).toEqual(true)
77
-
78
- })
79
-
80
- })
81
-
82
- describe('*Infinity* use cases', () => {
83
-
84
- })
85
-
86
- describe('Pitfalls of *Infinity*', () => {
87
- test('Parsing numbers', () => {
88
- expect(parseFloat('Infinity')).toEqual(Infinity)
89
- expect(parseInt('Infinity', 10)).toEqual(NaN)
90
- })
91
-
92
- test('JSON serialization', () => {
93
- const worker = {
94
- salary: Infinity
95
- };
96
-
97
- let y = JSON.parse(JSON.stringify(worker))
98
- let e = { "salary": null }
99
-
100
- expect(y).toEqual(e)
101
- })
102
-
103
- test('Max number overflow', () => {
104
-
105
- expect(2 * Number.MAX_VALUE).toEqual(Infinity)
106
- expect(Math.pow(10, 1000)).toEqual(Infinity)
107
-
108
- })
109
-
110
- test('Math functions', () => {
111
- expect(Math.max()).toEqual(-Infinity)
112
- expect(Math.min()).toEqual(Infinity)
113
-
114
- })
115
-
116
-
117
-
118
- })
119
-
120
-
121
-
122
-
@@ -1,64 +0,0 @@
1
- describe('Basic usage', () => {
2
- test('Number', () => {
3
- expect(typeof 37).toEqual('number');
4
- expect(typeof 3.14).toEqual('number');
5
- expect(typeof (42)).toEqual('number');
6
- expect(typeof Math.LN2).toEqual('number');
7
- expect(typeof Infinity).toEqual('number');
8
- expect(typeof NaN).toEqual('number'); // Despite being "Not-A-Number"
9
- expect(typeof Number('1')).toEqual('number'); // Number tries to parse things into numbers
10
- expect(typeof Number('shoe')).toEqual('number'); // including values that cannot be type coerced to a number
11
-
12
- expect(typeof 42n).toEqual('bigint');
13
- })
14
-
15
- test('String', () => {
16
- expect(typeof '').toEqual('string');
17
- expect(typeof 'bla').toEqual('string');
18
- expect(typeof `template literal`).toEqual('string');
19
- expect(typeof '1').toEqual('string'); // note that a number within a string is still typeof string
20
- expect(typeof (typeof 1)).toEqual('string'); // typeof always returns a string
21
- expect(typeof String(1)).toEqual('string'); // String converts anything into a string, safer than toString
22
- })
23
-
24
- test('Boolean', () => {
25
- expect(typeof true).toEqual('boolean');
26
- expect(typeof false).toEqual('boolean');
27
- expect(typeof Boolean(1)).toEqual('boolean'); // Boolean() will convert values based on if they're truthy or falsy
28
- expect(typeof !!(1)).toEqual('boolean'); // two calls of the ! (logical NOT) operator are equivalent to Boolean()
29
- })
30
-
31
- test('Symbol', () => {
32
- expect(typeof Symbol()).toEqual('symbol')
33
- expect(typeof Symbol('foo')).toEqual('symbol')
34
- expect(typeof Symbol.iterator).toEqual('symbol')
35
- })
36
-
37
- test('Undefined', () => {
38
- expect(typeof undefined).toEqual('undefined')
39
- expect(typeof declaredButUndefinedVariable).toEqual('undefined')
40
- expect(typeof undeclaredVariable).toEqual('undefined')
41
- })
42
-
43
- test('Object', () => {
44
- expect(typeof { a: 1 }).toEqual('object')
45
-
46
- // use Array.isArray or Object.prototype.toString.call
47
- // to differentiate regular objects from arrays
48
- expect(typeof [1, 2, 4]).toEqual('object')
49
-
50
- expect(typeof new Date()).toEqual('object')
51
- expect(typeof /regex/).toEqual('object') // See Regular expressions section for historical results
52
-
53
- // The following are confusing, dangerous, and wasteful. Avoid them.
54
- expect(typeof new Boolean(true)).toEqual('object')
55
- expect(typeof new Number(1)).toEqual('object')
56
- expect(typeof new String('abc')).toEqual('object')
57
- })
58
-
59
- test('Function', () => {
60
- expect(typeof function () { }).toEqual('function')
61
- expect(typeof class C { }).toEqual('function')
62
- expect(typeof Math.sin).toEqual('function')
63
- })
64
- })
@@ -1,5 +0,0 @@
1
- /**
2
- * JavaScript 基本数据类型名称数组
3
- * typeof 返回的所有类型字符串
4
- */
5
- export declare const types: string[];
@@ -1,11 +0,0 @@
1
- /// 这个字符串数组列举了JavaScript 中所有基本数据类型(primitive types)的名称。typeof 返回值域
2
- export const types = [
3
- "undefined", // 未定义类型,表示未赋值的变量
4
- "object", // 对象类型(包括 null 和所有对象/数组/日期等)
5
- "boolean", // 布尔类型(true/false)
6
- "number", // 数字类型(包括整数和浮点数)
7
- "bigint", // 大整数类型(ES2020 新增,表示任意精度的整数)
8
- "string", // 字符串类型
9
- "symbol", // Symbol 类型(ES2015 新增,表示唯一标识符)
10
- "function" // 函数类型(虽然 typeof 返回 'function',但函数本质是 object 的子类型)
11
- ]
@@ -1,58 +0,0 @@
1
- import { BehaviorSubject, Observable } from 'rxjs';
2
-
3
- export declare class Deep<T> {
4
- constructor(entries: [(string | number)[], T][]);
5
-
6
- readonly entries: [(string | number)[], T][];
7
- readonly keys: (string | number)[][];
8
- getValues(): T[];
9
-
10
- /**
11
- * 将深度数据结构转换为普通对象。
12
- *
13
- * @returns {Record<string|number, any>} 转换后的普通对象。
14
- */
15
- toObject(): Record<string | number, any>;
16
-
17
- findIndex(searchKeyPath: (string | number)[]): number;
18
-
19
- structuralEqual(keys: (string | number)[][]): boolean;
20
- structuralSubset(keys: (string | number)[][]): boolean;
21
- structuralSuperset(keys: (string | number)[][]): boolean;
22
-
23
- intersect(keys: (string | number)[][]): Deep<T>;
24
- difference(keys: (string | number)[][]): Deep<T>;
25
- /**
26
- * 后来者赢(参数赢)
27
- * @param entries
28
- */
29
- union(entries: [(string | number)[], T][]): Deep<T>;
30
-
31
- map<U>(
32
- callbackfn: (value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => U,
33
- thisArg?: any
34
- ): Deep<U>;
35
- filter(
36
- predicate: (value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => boolean,
37
- thisArg?: any
38
- ): Deep<T>;
39
- forEach(
40
- callbackfn: (value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => void,
41
- thisArg?: any
42
- ): void;
43
-
44
- freshValue(obj: Record<string | number, any>): Deep<any>;
45
- replaceValue<U>(values: U[]): Deep<U>;
46
- zipValue<U>(values: U[]): Deep<[T, U]>;
47
-
48
- combineLatest<U>(): Observable<Deep<U>>;
49
- merge<U>(): Observable<[(string | number)[], U]>;
50
-
51
- static fromObject(
52
- obj: Record<string | number, any>,
53
- filter?: (value: any, key: string | number, keyPath: (string | number)[]) => boolean
54
- ): Deep<any>;
55
- static fromBehaviorSubject(obj: Record<string | number, any>): Deep<BehaviorSubject<any>>;
56
- static fromObservable(obj: Record<string | number, any>): Deep<Observable<any>>;
57
- }
58
-
package/src/deep/Deep.js DELETED
@@ -1,267 +0,0 @@
1
- import { BehaviorSubject, isObservable, Observable, combineLatest, from, Subscription } from 'rxjs'
2
- import { map, mergeMap } from 'rxjs/operators'
3
-
4
- import { zipArray } from "../array"
5
- import { pluckProperty } from '../object'
6
- import { keyPathComparer, entryComparer } from '../comparers'
7
- import { tojs, flat } from '../structures'
8
- import { intersectEntries } from './intersectEntries'
9
-
10
-
11
- /**
12
- * 深度(嵌套)数据结构类,用于处理按键路径排序的键值对集合。
13
- * 提供了多种操作方法,包括集合操作、序列操作和数据转换。
14
- *
15
- * @template T
16
- *
17
- */
18
- export class Deep {
19
- /**
20
- * 构造函数。
21
- *
22
- * @param {[(string|number)[], T][]} entries - 按键路径排序的键值对数组。键值对已经按keypath排序。
23
- */
24
- constructor(entries) {
25
- this._entries = entries
26
- this._keys = this._entries.map(([k]) => k)
27
- }
28
-
29
- ///基本數據屬性
30
-
31
- get entries() { return this._entries }
32
-
33
- get keys() { return this._keys }
34
-
35
- getValues() {
36
- return this.entries.map(([k, v]) => v)
37
- }
38
-
39
- ///构造正常数据对象
40
- /**
41
- * 将深度数据结构转换为普通对象。
42
- *
43
- * @returns {Record<string|number, any>} 转换后的普通对象。
44
- */
45
- toObject() {
46
- return tojs(this.entries)
47
- }
48
-
49
- ///單個讀取
50
-
51
- /**
52
- *
53
- * @param {(string|number)[]} searchKeyPath
54
- * @returns
55
- */
56
- findIndex(searchKeyPath) {
57
- return keyPathComparer.findIndexInSet(this.keys, searchKeyPath)
58
- }
59
-
60
- ///集合操作
61
-
62
- /**
63
- *
64
- * @param {(string|number)[][]} keys
65
- * @returns
66
- */
67
- structuralEqual(keys) {
68
- return keyPathComparer.isEqualset(this.keys, keys)
69
- }
70
-
71
- /**
72
- *
73
- * @param {(string|number)[][]} keys
74
- * @returns
75
- */
76
- structuralSubset(keys) {
77
- return keyPathComparer.isSubset(this.keys, keys)
78
- }
79
-
80
- /**
81
- *
82
- * @param {(string|number)[][]} keys
83
- * @returns
84
- */
85
- structuralSuperset(keys) {
86
- return keyPathComparer.isSuperset(this.keys, keys)
87
- }
88
-
89
- /**
90
- * @param {(string|number)[][]} keys
91
- * @this {Deep<T>}
92
- * @returns {Deep<T>}
93
- */
94
- intersect(keys) {
95
- let entries = intersectEntries(this.entries, keys)
96
- return new Deep(entries)
97
- }
98
-
99
- /**
100
- *
101
- * @param {(string|number)[][]} keys
102
- * @this {Deep<T>}
103
- * @returns {Deep<T>}
104
- */
105
- difference(keys) {
106
- let newkeys = keyPathComparer.differenceSet(this.keys, keys)
107
- return this.intersect(newkeys)
108
- }
109
-
110
- /**
111
- * 后来者赢(参数赢)
112
- * @param {[(string | number)[], T][]} entries
113
- * @returns
114
- */
115
- union(entries) {
116
- let entries2 = entryComparer.sort([...this.entries, ...entries])
117
- return new Deep(entries2)
118
- }
119
-
120
-
121
- /// 序列操作符
122
-
123
- /**
124
- *
125
- * @template U
126
- * @param {(value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => U} callbackfn 返回的是值,而不是键值对,KeyPath保持不变
127
- * @param {Deep<T>} [thisArg]
128
- * @this {Deep<T>}
129
- * @returns {Deep<U>}
130
- *
131
- */
132
- map(callbackfn, thisArg) {
133
- let values = this.entries.map(callbackfn, thisArg)
134
- return this.replaceValue(values)
135
- }
136
-
137
- /**
138
- *
139
- * @param {(value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => boolean} predicate
140
- * @param {Deep<T>} [thisArg]
141
- * @returns
142
- */
143
- filter(predicate, thisArg) {
144
- let entries = this.entries.filter(predicate, thisArg)
145
- return new Deep(entries)
146
- }
147
-
148
- /**
149
- *
150
- * @param { (value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => void} callbackfn
151
- * @param {Deep<T>} [thisArg]
152
- * @returns
153
- */
154
- forEach(callbackfn, thisArg) {
155
- this.entries.forEach(callbackfn, thisArg)
156
- }
157
-
158
- /// 值操作
159
-
160
- /**
161
- * 修改部分个别数值
162
- * @param {Record<string|number,any>} obj
163
- * @this {Deep<T>}
164
- * @returns
165
- */
166
- freshValue(obj) {
167
- let entries = this.keys.map(
168
- /**
169
- * @returns {[(string | number)[],any]}
170
- */
171
- k => [k, pluckProperty(obj, k)]
172
- )
173
- return new Deep(entries)
174
-
175
- }
176
-
177
- /**
178
- * 按列替换数值
179
- * @template U
180
- * @param {U[]} values
181
- * @this {Deep<T>}
182
- * @returns {Deep<U>}
183
- */
184
- replaceValue(values) {
185
- let entries = zipArray(this.keys, values)
186
- return new Deep(entries)
187
- }
188
-
189
- /**
190
- * 按列替换数值,保留原有数值
191
- * @template U
192
- * @param {U[]} values
193
- * @this {Deep<T>}
194
- * @returns {Deep<[T,U]>}
195
- */
196
- zipValue(values) {
197
- return this.replaceValue(zipArray(this.getValues(), values))
198
- }
199
-
200
- /// rxjs操作符
201
-
202
- /**
203
- * 返回Observable of 总体的当前值
204
- * @template U
205
- * @this {Deep<Observable<U>>}
206
- * @returns {Observable<Deep<U>>}
207
- */
208
- combineLatest() {
209
- let values = this.getValues()
210
- return combineLatest(values).pipe(
211
- map(values => this.replaceValue(values))
212
- )
213
- }
214
-
215
- /**
216
- * 返回发射消息的那一个成员的路径以及新值。
217
- * @template U
218
- * @this {Deep<Observable<U>>}
219
- * @returns {Observable<[(string|number)[], U]>}
220
- */
221
- merge() {
222
- return from(this.entries).pipe(
223
- mergeMap(([keyPath, value$]) =>
224
- value$.pipe(
225
- map(
226
- /**
227
- * @returns {[(string|number)[], U]}
228
- */
229
- value => [keyPath, value])
230
- )))
231
- }
232
-
233
- /// 静态构造方法
234
-
235
- /**
236
- *
237
- * @param {{[_:string|number]:any}} obj
238
- * @param {(value: any, key: string | number, keyPath: (string | number)[]) => boolean} [filter]
239
- * @returns
240
- */
241
- static fromObject(obj, filter = () => false) {
242
- let arr = flat(obj, filter)
243
- let entries = entryComparer.sort(arr)
244
- return new Deep(entries)
245
- }
246
-
247
- /**
248
- * @template T
249
- * @param {{[_:string|number]:any}} obj
250
- * @returns {Deep<BehaviorSubject<T>>}
251
- */
252
- static fromBehaviorSubject(obj) {
253
- return Deep.fromObject(obj, v => isObservable(v) || v instanceof Subscription)
254
- .filter(([k, v]) => v instanceof BehaviorSubject)
255
- }
256
-
257
- /**
258
- * @template T
259
- * @param {{[_:string|number]:any}} obj
260
- * @returns
261
- */
262
- static fromObservable(obj) {
263
- return Deep.fromObject(obj, v => isObservable(v) || v instanceof Subscription)
264
- .filter(([k, v]) => isObservable(v))
265
- }
266
-
267
- }
@@ -1,130 +0,0 @@
1
- import { Deep } from './Deep'
2
-
3
- // let data = {
4
- // a: {
5
- // a: 0,
6
- // b: 1,
7
- // },
8
- // b: [2, 3],
9
- // }
10
-
11
- // let entries = [[['a', 'a'], 0], [['a', 'b'], 1], [['b', 0], 2], [['b', 1], 3]]
12
-
13
- test('constructor entries', () => {
14
- let entries = [[['a', 'a'], 0], [['a', 'b'], 1], [['b', 0], 2], [['b', 1], 3]]
15
- let deep = new Deep(entries)
16
- let y = deep.entries
17
- expect(y).toEqual(entries)
18
- })
19
-
20
- test('deep keys', () => {
21
- let entries = [[['a', 'a'], 0], [['a', 'b'], 1], [['b', 0], 2], [['b', 1], 3]]
22
- let deep = new Deep(entries)
23
-
24
- let keys = [['a', 'a'], ['a', 'b'], ['b', 0], ['b', 1]]
25
- expect(deep.keys).toEqual(keys)
26
- })
27
-
28
- test('deep getValues', () => {
29
- let entries = [[['a', 'a'], 0], [['a', 'b'], 1], [['b', 0], 2], [['b', 1], 3]]
30
- let deep = new Deep(entries)
31
- let values = [0, 1, 2, 3]
32
- expect(deep.getValues()).toEqual(values)
33
- })
34
-
35
- test('deep toObject', () => {
36
- let entries = [[['a', 'a'], 0], [['a', 'b'], 1], [['b', 0], 2], [['b', 1], 3]]
37
- let deep = new Deep(entries)
38
- let data = {
39
- a: {
40
- a: 0,
41
- b: 1,
42
- },
43
- b: [2, 3],
44
- }
45
- expect(deep.toObject()).toEqual(data)
46
- })
47
-
48
- test('deep findIndex', () => {
49
- let entries = [[['a', 'a'], 0], [['a', 'b'], 1], [['b', 0], 2], [['b', 1], 3]]
50
- let deep = new Deep(entries)
51
- let keyPath = ['a', 'b']
52
- expect(deep.findIndex(keyPath)).toEqual(1)
53
- })
54
-
55
- test('keys & values', () => {
56
- let entries = [[['a'], 0], [['b'], 1], [['c', 0], 2], [['c', 1], 3], [['c', 2, 'e'], 4]]
57
-
58
- let deep = new Deep(entries)
59
-
60
- let keys = [['a'], ['b'], ['c', 0], ['c', 1], ['c', 2, 'e']]
61
-
62
- expect(deep.keys).toEqual(keys)
63
- expect(deep.getValues()).toEqual([0, 1, 2, 3, 4])
64
- })
65
-
66
- test('find index', () => {
67
- let entries = [[['a'], 0], [['b'], 1], [['c', 0], 2], [['c', 1], 3], [['c', 2, 'e'], 4]]
68
-
69
- let deep = new Deep(entries)
70
-
71
- let i = deep.findIndex(['c', 0])
72
- expect(i).toEqual(2)
73
-
74
- let j = deep.findIndex(['no exist', 0])
75
- expect(j).toEqual(-1)
76
- })
77
-
78
- test('test to object', () => {
79
- let entries = [[['a'], 0], [['b'], 1], [['c', 0], 2], [['c', 1], 3], [['c', 2, 'e'], 4]]
80
-
81
- let deep = new Deep(entries)
82
- let obj = {
83
- a: 0,
84
- b: 1,
85
- c: [
86
- 2,
87
- 3,
88
- {
89
- e: 4,
90
- },
91
- ],
92
- }
93
-
94
- expect(deep.toObject()).toEqual(obj)
95
- })
96
-
97
- describe('structural comparison', () => {
98
- test('structuralEqual', () => {
99
- let deep = new Deep([[['a'], 0], [['b'], 1], [['c', 0], 2], [['c', 1], 3], [['c', 2, 'e'], 4]])
100
- let keys = [['a'], ['b'], ['c', 0], ['c', 1], ['c', 2, 'e']]
101
- let y = deep.structuralEqual(keys)
102
- expect(y).toEqual(true)
103
- })
104
-
105
- test('structuralSubset', () => {
106
- let deep = new Deep([[['a'], 0], [['c', 0], 2], [['c', 1], 3], [['c', 2, 'e'], 4]])
107
- let keys = [
108
- ['a'],
109
- ['b'], //*
110
- ['c', 0],
111
- ['c', 1],
112
- ['c', 2, 'e'],
113
- ]
114
- let y = deep.structuralSubset(keys)
115
- expect(y).toEqual(true)
116
- })
117
-
118
- test('structuralSuperset', () => {
119
- let deep = new Deep([[['a'], 0], [['b'], 1], [['c', 0], 2], [['c', 1], 3], [['c', 2, 'e'], 4]])
120
- let keys = [
121
- ['a'],
122
- //['b'],
123
- ['c', 0],
124
- ['c', 1],
125
- ['c', 2, 'e'],
126
- ]
127
- let y = deep.structuralSuperset(keys)
128
- expect(y).toEqual(true)
129
- })
130
- })