@hpcc-js/dataflow 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/dist/index.js +1 -557
  2. package/dist/index.js.map +7 -1
  3. package/package.json +28 -37
  4. package/src/__package__.ts +2 -2
  5. package/src/activities/concat.ts +1 -1
  6. package/src/activities/each.ts +1 -1
  7. package/src/activities/entries.ts +1 -1
  8. package/src/activities/filter.ts +1 -1
  9. package/src/activities/first.ts +1 -1
  10. package/src/activities/group.ts +1 -1
  11. package/src/activities/histogram.ts +3 -3
  12. package/src/activities/join.ts +1 -1
  13. package/src/activities/map.ts +1 -1
  14. package/src/activities/normalize.ts +4 -4
  15. package/src/activities/skip.ts +1 -1
  16. package/src/activities/sort.ts +1 -1
  17. package/src/index.ts +27 -27
  18. package/src/observers/count.ts +1 -1
  19. package/src/observers/deviation.ts +2 -2
  20. package/src/observers/distribution.ts +5 -5
  21. package/src/observers/extent.ts +3 -3
  22. package/src/observers/max.ts +1 -1
  23. package/src/observers/mean.ts +1 -1
  24. package/src/observers/median.ts +1 -1
  25. package/src/observers/min.ts +1 -1
  26. package/src/observers/observer.ts +2 -2
  27. package/src/observers/quartile.ts +2 -2
  28. package/src/observers/reduce.ts +1 -1
  29. package/src/observers/variance.ts +1 -1
  30. package/src/utils/pipe.ts +3 -3
  31. package/types/activities/activity.d.ts +0 -1
  32. package/types/activities/concat.d.ts +1 -2
  33. package/types/activities/each.d.ts +1 -2
  34. package/types/activities/entries.d.ts +1 -2
  35. package/types/activities/filter.d.ts +1 -2
  36. package/types/activities/first.d.ts +1 -2
  37. package/types/activities/group.d.ts +1 -2
  38. package/types/activities/histogram.d.ts +1 -2
  39. package/types/activities/join.d.ts +1 -2
  40. package/types/activities/map.d.ts +1 -2
  41. package/types/activities/normalize.d.ts +1 -2
  42. package/types/activities/skip.d.ts +1 -2
  43. package/types/activities/sort.d.ts +1 -2
  44. package/types/index.d.ts +27 -28
  45. package/types/observers/count.d.ts +1 -2
  46. package/types/observers/deviation.d.ts +1 -2
  47. package/types/observers/distribution.d.ts +1 -2
  48. package/types/observers/extent.d.ts +1 -2
  49. package/types/observers/max.d.ts +1 -2
  50. package/types/observers/mean.d.ts +1 -2
  51. package/types/observers/median.d.ts +1 -2
  52. package/types/observers/min.d.ts +1 -2
  53. package/types/observers/observer.d.ts +2 -3
  54. package/types/observers/quartile.d.ts +1 -2
  55. package/types/observers/reduce.d.ts +1 -2
  56. package/types/observers/variance.d.ts +1 -2
  57. package/types/utils/generate.d.ts +0 -1
  58. package/types/utils/pipe.d.ts +1 -2
  59. package/dist/index.min.js +0 -2
  60. package/dist/index.min.js.map +0 -1
  61. package/lib-es6/__package__.js +0 -4
  62. package/lib-es6/__package__.js.map +0 -1
  63. package/lib-es6/__tests__/chain.js +0 -49
  64. package/lib-es6/__tests__/chain.js.map +0 -1
  65. package/lib-es6/__tests__/concat.js +0 -17
  66. package/lib-es6/__tests__/concat.js.map +0 -1
  67. package/lib-es6/__tests__/count.js +0 -19
  68. package/lib-es6/__tests__/count.js.map +0 -1
  69. package/lib-es6/__tests__/data.js +0 -56
  70. package/lib-es6/__tests__/data.js.map +0 -1
  71. package/lib-es6/__tests__/deviation.js +0 -13
  72. package/lib-es6/__tests__/deviation.js.map +0 -1
  73. package/lib-es6/__tests__/distribution.js +0 -19
  74. package/lib-es6/__tests__/distribution.js.map +0 -1
  75. package/lib-es6/__tests__/each.js +0 -12
  76. package/lib-es6/__tests__/each.js.map +0 -1
  77. package/lib-es6/__tests__/entries.js +0 -13
  78. package/lib-es6/__tests__/entries.js.map +0 -1
  79. package/lib-es6/__tests__/extent.js +0 -19
  80. package/lib-es6/__tests__/extent.js.map +0 -1
  81. package/lib-es6/__tests__/filter.js +0 -14
  82. package/lib-es6/__tests__/filter.js.map +0 -1
  83. package/lib-es6/__tests__/first.js +0 -14
  84. package/lib-es6/__tests__/first.js.map +0 -1
  85. package/lib-es6/__tests__/generate.js +0 -8
  86. package/lib-es6/__tests__/generate.js.map +0 -1
  87. package/lib-es6/__tests__/group.js +0 -18
  88. package/lib-es6/__tests__/group.js.map +0 -1
  89. package/lib-es6/__tests__/histogram.js +0 -42
  90. package/lib-es6/__tests__/histogram.js.map +0 -1
  91. package/lib-es6/__tests__/index.js +0 -28
  92. package/lib-es6/__tests__/index.js.map +0 -1
  93. package/lib-es6/__tests__/join.js +0 -16
  94. package/lib-es6/__tests__/join.js.map +0 -1
  95. package/lib-es6/__tests__/map.js +0 -14
  96. package/lib-es6/__tests__/map.js.map +0 -1
  97. package/lib-es6/__tests__/max.js +0 -30
  98. package/lib-es6/__tests__/max.js.map +0 -1
  99. package/lib-es6/__tests__/mean.js +0 -10
  100. package/lib-es6/__tests__/mean.js.map +0 -1
  101. package/lib-es6/__tests__/median.js +0 -13
  102. package/lib-es6/__tests__/median.js.map +0 -1
  103. package/lib-es6/__tests__/min.js +0 -30
  104. package/lib-es6/__tests__/min.js.map +0 -1
  105. package/lib-es6/__tests__/normalize.js +0 -12
  106. package/lib-es6/__tests__/normalize.js.map +0 -1
  107. package/lib-es6/__tests__/quartile.js +0 -12
  108. package/lib-es6/__tests__/quartile.js.map +0 -1
  109. package/lib-es6/__tests__/readme.js +0 -96
  110. package/lib-es6/__tests__/readme.js.map +0 -1
  111. package/lib-es6/__tests__/reduce.js +0 -15
  112. package/lib-es6/__tests__/reduce.js.map +0 -1
  113. package/lib-es6/__tests__/skip.js +0 -14
  114. package/lib-es6/__tests__/skip.js.map +0 -1
  115. package/lib-es6/__tests__/sort.js +0 -19
  116. package/lib-es6/__tests__/sort.js.map +0 -1
  117. package/lib-es6/__tests__/variance.js +0 -13
  118. package/lib-es6/__tests__/variance.js.map +0 -1
  119. package/lib-es6/activities/activity.js +0 -4
  120. package/lib-es6/activities/activity.js.map +0 -1
  121. package/lib-es6/activities/concat.js +0 -10
  122. package/lib-es6/activities/concat.js.map +0 -1
  123. package/lib-es6/activities/each.js +0 -14
  124. package/lib-es6/activities/each.js.map +0 -1
  125. package/lib-es6/activities/entries.js +0 -13
  126. package/lib-es6/activities/entries.js.map +0 -1
  127. package/lib-es6/activities/filter.js +0 -15
  128. package/lib-es6/activities/filter.js.map +0 -1
  129. package/lib-es6/activities/first.js +0 -18
  130. package/lib-es6/activities/first.js.map +0 -1
  131. package/lib-es6/activities/group.js +0 -21
  132. package/lib-es6/activities/group.js.map +0 -1
  133. package/lib-es6/activities/histogram.js +0 -64
  134. package/lib-es6/activities/histogram.js.map +0 -1
  135. package/lib-es6/activities/join.js +0 -14
  136. package/lib-es6/activities/join.js.map +0 -1
  137. package/lib-es6/activities/map.js +0 -13
  138. package/lib-es6/activities/map.js.map +0 -1
  139. package/lib-es6/activities/normalize.js +0 -18
  140. package/lib-es6/activities/normalize.js.map +0 -1
  141. package/lib-es6/activities/skip.js +0 -15
  142. package/lib-es6/activities/skip.js.map +0 -1
  143. package/lib-es6/activities/sort.js +0 -10
  144. package/lib-es6/activities/sort.js.map +0 -1
  145. package/lib-es6/index.js +0 -28
  146. package/lib-es6/index.js.map +0 -1
  147. package/lib-es6/observers/count.js +0 -13
  148. package/lib-es6/observers/count.js.map +0 -1
  149. package/lib-es6/observers/deviation.js +0 -18
  150. package/lib-es6/observers/deviation.js.map +0 -1
  151. package/lib-es6/observers/distribution.js +0 -36
  152. package/lib-es6/observers/distribution.js.map +0 -1
  153. package/lib-es6/observers/extent.js +0 -18
  154. package/lib-es6/observers/extent.js.map +0 -1
  155. package/lib-es6/observers/max.js +0 -19
  156. package/lib-es6/observers/max.js.map +0 -1
  157. package/lib-es6/observers/mean.js +0 -21
  158. package/lib-es6/observers/mean.js.map +0 -1
  159. package/lib-es6/observers/median.js +0 -26
  160. package/lib-es6/observers/median.js.map +0 -1
  161. package/lib-es6/observers/min.js +0 -19
  162. package/lib-es6/observers/min.js.map +0 -1
  163. package/lib-es6/observers/observer.js +0 -35
  164. package/lib-es6/observers/observer.js.map +0 -1
  165. package/lib-es6/observers/quartile.js +0 -38
  166. package/lib-es6/observers/quartile.js.map +0 -1
  167. package/lib-es6/observers/reduce.js +0 -18
  168. package/lib-es6/observers/reduce.js.map +0 -1
  169. package/lib-es6/observers/variance.js +0 -23
  170. package/lib-es6/observers/variance.js.map +0 -1
  171. package/lib-es6/utils/generate.js +0 -7
  172. package/lib-es6/utils/generate.js.map +0 -1
  173. package/lib-es6/utils/pipe.js +0 -32
  174. package/lib-es6/utils/pipe.js.map +0 -1
  175. package/src/__tests__/chain.ts +0 -85
  176. package/src/__tests__/concat.ts +0 -18
  177. package/src/__tests__/count.ts +0 -25
  178. package/src/__tests__/data.ts +0 -64
  179. package/src/__tests__/deviation.ts +0 -14
  180. package/src/__tests__/distribution.ts +0 -21
  181. package/src/__tests__/each.ts +0 -13
  182. package/src/__tests__/entries.ts +0 -14
  183. package/src/__tests__/extent.ts +0 -25
  184. package/src/__tests__/filter.ts +0 -16
  185. package/src/__tests__/first.ts +0 -15
  186. package/src/__tests__/generate.ts +0 -9
  187. package/src/__tests__/group.ts +0 -19
  188. package/src/__tests__/histogram.ts +0 -47
  189. package/src/__tests__/index.ts +0 -27
  190. package/src/__tests__/join.ts +0 -20
  191. package/src/__tests__/map.ts +0 -16
  192. package/src/__tests__/max.ts +0 -42
  193. package/src/__tests__/mean.ts +0 -11
  194. package/src/__tests__/median.ts +0 -14
  195. package/src/__tests__/min.ts +0 -42
  196. package/src/__tests__/normalize.ts +0 -14
  197. package/src/__tests__/quartile.ts +0 -14
  198. package/src/__tests__/readme.ts +0 -113
  199. package/src/__tests__/reduce.ts +0 -17
  200. package/src/__tests__/skip.ts +0 -15
  201. package/src/__tests__/sort.ts +0 -21
  202. package/src/__tests__/variance.ts +0 -14
  203. package/types/__package__.d.ts +0 -4
  204. package/types/__package__.d.ts.map +0 -1
  205. package/types/__tests__/chain.d.ts +0 -2
  206. package/types/__tests__/chain.d.ts.map +0 -1
  207. package/types/__tests__/concat.d.ts +0 -2
  208. package/types/__tests__/concat.d.ts.map +0 -1
  209. package/types/__tests__/count.d.ts +0 -2
  210. package/types/__tests__/count.d.ts.map +0 -1
  211. package/types/__tests__/data.d.ts +0 -62
  212. package/types/__tests__/data.d.ts.map +0 -1
  213. package/types/__tests__/deviation.d.ts +0 -2
  214. package/types/__tests__/deviation.d.ts.map +0 -1
  215. package/types/__tests__/distribution.d.ts +0 -2
  216. package/types/__tests__/distribution.d.ts.map +0 -1
  217. package/types/__tests__/each.d.ts +0 -2
  218. package/types/__tests__/each.d.ts.map +0 -1
  219. package/types/__tests__/entries.d.ts +0 -2
  220. package/types/__tests__/entries.d.ts.map +0 -1
  221. package/types/__tests__/extent.d.ts +0 -2
  222. package/types/__tests__/extent.d.ts.map +0 -1
  223. package/types/__tests__/filter.d.ts +0 -2
  224. package/types/__tests__/filter.d.ts.map +0 -1
  225. package/types/__tests__/first.d.ts +0 -2
  226. package/types/__tests__/first.d.ts.map +0 -1
  227. package/types/__tests__/generate.d.ts +0 -2
  228. package/types/__tests__/generate.d.ts.map +0 -1
  229. package/types/__tests__/group.d.ts +0 -2
  230. package/types/__tests__/group.d.ts.map +0 -1
  231. package/types/__tests__/histogram.d.ts +0 -2
  232. package/types/__tests__/histogram.d.ts.map +0 -1
  233. package/types/__tests__/index.d.ts +0 -28
  234. package/types/__tests__/index.d.ts.map +0 -1
  235. package/types/__tests__/join.d.ts +0 -2
  236. package/types/__tests__/join.d.ts.map +0 -1
  237. package/types/__tests__/map.d.ts +0 -2
  238. package/types/__tests__/map.d.ts.map +0 -1
  239. package/types/__tests__/max.d.ts +0 -2
  240. package/types/__tests__/max.d.ts.map +0 -1
  241. package/types/__tests__/mean.d.ts +0 -2
  242. package/types/__tests__/mean.d.ts.map +0 -1
  243. package/types/__tests__/median.d.ts +0 -2
  244. package/types/__tests__/median.d.ts.map +0 -1
  245. package/types/__tests__/min.d.ts +0 -2
  246. package/types/__tests__/min.d.ts.map +0 -1
  247. package/types/__tests__/normalize.d.ts +0 -2
  248. package/types/__tests__/normalize.d.ts.map +0 -1
  249. package/types/__tests__/quartile.d.ts +0 -2
  250. package/types/__tests__/quartile.d.ts.map +0 -1
  251. package/types/__tests__/readme.d.ts +0 -2
  252. package/types/__tests__/readme.d.ts.map +0 -1
  253. package/types/__tests__/reduce.d.ts +0 -2
  254. package/types/__tests__/reduce.d.ts.map +0 -1
  255. package/types/__tests__/skip.d.ts +0 -2
  256. package/types/__tests__/skip.d.ts.map +0 -1
  257. package/types/__tests__/sort.d.ts +0 -2
  258. package/types/__tests__/sort.d.ts.map +0 -1
  259. package/types/__tests__/variance.d.ts +0 -2
  260. package/types/__tests__/variance.d.ts.map +0 -1
  261. package/types/activities/activity.d.ts.map +0 -1
  262. package/types/activities/concat.d.ts.map +0 -1
  263. package/types/activities/each.d.ts.map +0 -1
  264. package/types/activities/entries.d.ts.map +0 -1
  265. package/types/activities/filter.d.ts.map +0 -1
  266. package/types/activities/first.d.ts.map +0 -1
  267. package/types/activities/group.d.ts.map +0 -1
  268. package/types/activities/histogram.d.ts.map +0 -1
  269. package/types/activities/join.d.ts.map +0 -1
  270. package/types/activities/map.d.ts.map +0 -1
  271. package/types/activities/normalize.d.ts.map +0 -1
  272. package/types/activities/skip.d.ts.map +0 -1
  273. package/types/activities/sort.d.ts.map +0 -1
  274. package/types/index.d.ts.map +0 -1
  275. package/types/observers/count.d.ts.map +0 -1
  276. package/types/observers/deviation.d.ts.map +0 -1
  277. package/types/observers/distribution.d.ts.map +0 -1
  278. package/types/observers/extent.d.ts.map +0 -1
  279. package/types/observers/max.d.ts.map +0 -1
  280. package/types/observers/mean.d.ts.map +0 -1
  281. package/types/observers/median.d.ts.map +0 -1
  282. package/types/observers/min.d.ts.map +0 -1
  283. package/types/observers/observer.d.ts.map +0 -1
  284. package/types/observers/quartile.d.ts.map +0 -1
  285. package/types/observers/reduce.d.ts.map +0 -1
  286. package/types/observers/variance.d.ts.map +0 -1
  287. package/types/utils/generate.d.ts.map +0 -1
  288. package/types/utils/pipe.d.ts.map +0 -1
  289. package/types-3.4/__package__.d.ts +0 -4
  290. package/types-3.4/__tests__/chain.d.ts +0 -2
  291. package/types-3.4/__tests__/concat.d.ts +0 -2
  292. package/types-3.4/__tests__/count.d.ts +0 -2
  293. package/types-3.4/__tests__/data.d.ts +0 -62
  294. package/types-3.4/__tests__/deviation.d.ts +0 -2
  295. package/types-3.4/__tests__/distribution.d.ts +0 -2
  296. package/types-3.4/__tests__/each.d.ts +0 -2
  297. package/types-3.4/__tests__/entries.d.ts +0 -2
  298. package/types-3.4/__tests__/extent.d.ts +0 -2
  299. package/types-3.4/__tests__/filter.d.ts +0 -2
  300. package/types-3.4/__tests__/first.d.ts +0 -2
  301. package/types-3.4/__tests__/generate.d.ts +0 -2
  302. package/types-3.4/__tests__/group.d.ts +0 -2
  303. package/types-3.4/__tests__/histogram.d.ts +0 -2
  304. package/types-3.4/__tests__/index.d.ts +0 -28
  305. package/types-3.4/__tests__/join.d.ts +0 -2
  306. package/types-3.4/__tests__/map.d.ts +0 -2
  307. package/types-3.4/__tests__/max.d.ts +0 -2
  308. package/types-3.4/__tests__/mean.d.ts +0 -2
  309. package/types-3.4/__tests__/median.d.ts +0 -2
  310. package/types-3.4/__tests__/min.d.ts +0 -2
  311. package/types-3.4/__tests__/normalize.d.ts +0 -2
  312. package/types-3.4/__tests__/quartile.d.ts +0 -2
  313. package/types-3.4/__tests__/readme.d.ts +0 -2
  314. package/types-3.4/__tests__/reduce.d.ts +0 -2
  315. package/types-3.4/__tests__/skip.d.ts +0 -2
  316. package/types-3.4/__tests__/sort.d.ts +0 -2
  317. package/types-3.4/__tests__/variance.d.ts +0 -2
  318. package/types-3.4/activities/activity.d.ts +0 -6
  319. package/types-3.4/activities/concat.d.ts +0 -4
  320. package/types-3.4/activities/each.d.ts +0 -5
  321. package/types-3.4/activities/entries.d.ts +0 -10
  322. package/types-3.4/activities/filter.d.ts +0 -5
  323. package/types-3.4/activities/first.d.ts +0 -4
  324. package/types-3.4/activities/group.d.ts +0 -9
  325. package/types-3.4/activities/histogram.d.ts +0 -18
  326. package/types-3.4/activities/join.d.ts +0 -5
  327. package/types-3.4/activities/map.d.ts +0 -5
  328. package/types-3.4/activities/normalize.d.ts +0 -4
  329. package/types-3.4/activities/skip.d.ts +0 -4
  330. package/types-3.4/activities/sort.d.ts +0 -5
  331. package/types-3.4/index.d.ts +0 -28
  332. package/types-3.4/observers/count.d.ts +0 -3
  333. package/types-3.4/observers/deviation.d.ts +0 -5
  334. package/types-3.4/observers/distribution.d.ts +0 -13
  335. package/types-3.4/observers/extent.d.ts +0 -11
  336. package/types-3.4/observers/max.d.ts +0 -5
  337. package/types-3.4/observers/mean.d.ts +0 -5
  338. package/types-3.4/observers/median.d.ts +0 -5
  339. package/types-3.4/observers/min.d.ts +0 -5
  340. package/types-3.4/observers/observer.d.ts +0 -14
  341. package/types-3.4/observers/quartile.d.ts +0 -12
  342. package/types-3.4/observers/reduce.d.ts +0 -4
  343. package/types-3.4/observers/variance.d.ts +0 -5
  344. package/types-3.4/utils/generate.d.ts +0 -2
  345. package/types-3.4/utils/pipe.d.ts +0 -42
package/dist/index.js CHANGED
@@ -1,558 +1,2 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@hpcc-js/dataflow"] = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- function isSource(source) {
8
- return source && (typeof source[Symbol.iterator] === "function" || Array.isArray(source));
9
- }
10
-
11
- function concatGen(concatSource) {
12
- return function* (source) {
13
- yield* source;
14
- yield* concatSource;
15
- };
16
- }
17
- function concat(s_or_n, concatSource) {
18
- return concatSource !== undefined ? concatGen(concatSource)(s_or_n) : concatGen(s_or_n);
19
- }
20
-
21
- function eachGen(callbackFn) {
22
- return function* (source) {
23
- let i = -1;
24
- for (const item of source) {
25
- callbackFn(item, ++i);
26
- yield item;
27
- }
28
- };
29
- }
30
- function each(s_or_cb, callbackFn) {
31
- return isSource(s_or_cb) ? eachGen(callbackFn)(s_or_cb) : eachGen(s_or_cb);
32
- }
33
-
34
- // Array.entries
35
- function entriesGen() {
36
- return function* (source) {
37
- let i = -1;
38
- for (const item of source) {
39
- yield [++i, item];
40
- }
41
- };
42
- }
43
- function entries(source) {
44
- return source ? entriesGen()(source) : entriesGen();
45
- }
46
-
47
- function filterGen(callbackFn) {
48
- return function* (source) {
49
- let i = -1;
50
- for (const item of source) {
51
- if (callbackFn(item, ++i)) {
52
- yield item;
53
- }
54
- }
55
- };
56
- }
57
- function filter(s_or_cb, callbackFn) {
58
- return isSource(s_or_cb) ? filterGen(callbackFn)(s_or_cb) : filterGen(s_or_cb);
59
- }
60
-
61
- function firstGen(n) {
62
- return function* (source) {
63
- let i = 0;
64
- for (const item of source) {
65
- yield item;
66
- if (++i >= n) {
67
- break;
68
- }
69
- }
70
- };
71
- }
72
- function first(s_or_n, n) {
73
- if (!isSource(s_or_n))
74
- return firstGen(s_or_n);
75
- return firstGen(n)(s_or_n);
76
- }
77
-
78
- function groupGen(groupFn) {
79
- return function* (source) {
80
- let i = -1;
81
- const group = {};
82
- for (const row of source) {
83
- const key = groupFn(row, ++i);
84
- if (!group[key]) {
85
- group[key] = [];
86
- }
87
- group[key].push(row);
88
- }
89
- for (const key in group) {
90
- yield { key, value: group[key] };
91
- }
92
- };
93
- }
94
- function group(s_or_gbf, groupByFn) {
95
- return isSource(s_or_gbf) ? groupGen(groupByFn)(s_or_gbf) : groupGen(s_or_gbf);
96
- }
97
-
98
- function Accessor(fof, accesor) {
99
- const s = fof();
100
- return {
101
- observe: (_, i) => {
102
- s.observe(accesor(_, i), i);
103
- },
104
- peek: s.peek
105
- };
106
- }
107
- // This is an pass through activity so a FlowObserver can be inserted into a pipeline ---
108
- function sensor(s) {
109
- return each((r, i) => s.observe(r, i));
110
- }
111
- // This converts a FlowObserver to an Activity ---
112
- function activity(s) {
113
- return function* (source) {
114
- let i = -1;
115
- for (const row of source) {
116
- s.observe(row, ++i);
117
- }
118
- yield s.peek();
119
- };
120
- }
121
- // This converts a FlowObserver to an ScalarActivity ---
122
- function scalar(s) {
123
- return function (source) {
124
- let i = -1;
125
- for (const row of source) {
126
- s.observe(row, ++i);
127
- }
128
- return s.peek();
129
- };
130
- }
131
-
132
- function _max() {
133
- let max;
134
- return {
135
- observe: (value, idx) => {
136
- if (idx === 0) {
137
- max = value;
138
- }
139
- else if (max < value) {
140
- max = value;
141
- }
142
- },
143
- peek: () => max
144
- };
145
- }
146
- function max(callbackFn) {
147
- return callbackFn ? Accessor(_max, callbackFn) : _max();
148
- }
149
-
150
- function _min() {
151
- let min;
152
- return {
153
- observe: (value, idx) => {
154
- if (idx === 0) {
155
- min = value;
156
- }
157
- else if (min > value) {
158
- min = value;
159
- }
160
- },
161
- peek: () => min
162
- };
163
- }
164
- function min(callbackFn) {
165
- return callbackFn ? Accessor(_min, callbackFn) : _min();
166
- }
167
-
168
- function _extent() {
169
- const minFO = min();
170
- const maxFO = max();
171
- return {
172
- observe: (value, idx) => {
173
- minFO.observe(value, idx);
174
- maxFO.observe(value, idx);
175
- },
176
- peek: () => [minFO.peek(), maxFO.peek()]
177
- };
178
- }
179
- function extent(callbackFn) {
180
- return callbackFn ? Accessor(_extent, callbackFn) : _extent();
181
- }
182
-
183
- function isOptionA(_) {
184
- return _.buckets !== undefined;
185
- }
186
- function histogramGen(callbackFn, options) {
187
- return function* (_source) {
188
- let min;
189
- let bucketSize;
190
- let source;
191
- if (isOptionA(options)) {
192
- source = Array.isArray(_source) ? _source : [..._source];
193
- const minMax = scalar(extent(callbackFn))(source);
194
- if (minMax === undefined) {
195
- return undefined;
196
- }
197
- min = minMax[0];
198
- const max = minMax[1];
199
- const buckets = options.buckets;
200
- bucketSize = (max - min) / buckets;
201
- }
202
- else {
203
- source = _source;
204
- min = options.min;
205
- bucketSize = options.range;
206
- }
207
- const histogram = {};
208
- let maxBucketID = 0;
209
- for (const row of source) {
210
- const value = callbackFn(row);
211
- const bucketID = Math.floor((value - min) / bucketSize);
212
- if (maxBucketID < bucketID) {
213
- maxBucketID = bucketID;
214
- }
215
- if (histogram[bucketID] === undefined) {
216
- histogram[bucketID] = [];
217
- }
218
- histogram[bucketID].push(row);
219
- }
220
- const lastBucket = histogram[maxBucketID];
221
- const from = min + maxBucketID * bucketSize;
222
- for (let i = 0; i <= maxBucketID; ++i) {
223
- // If all items in the last bucket match the "to" of the previous bucket, put them in there...
224
- if (i === maxBucketID - 1 && lastBucket.every(row => from === callbackFn(row))) {
225
- yield {
226
- from: min + i * bucketSize,
227
- to: min + (i + 1) * bucketSize,
228
- value: [...(histogram[i] || []), ...lastBucket]
229
- };
230
- break;
231
- }
232
- yield {
233
- from: min + i * bucketSize,
234
- to: min + (i + 1) * bucketSize,
235
- value: histogram[i] || []
236
- };
237
- }
238
- };
239
- }
240
- function histogram(s_or_hf, hf_or_b, options) {
241
- return isSource(s_or_hf) ? histogramGen(hf_or_b, options)(s_or_hf) : histogramGen(s_or_hf, hf_or_b);
242
- }
243
-
244
- function joinGen(_sourceU, callbackFn) {
245
- const sourceB = Array.isArray(_sourceU) ? _sourceU[Symbol.iterator]() : _sourceU;
246
- return function* (sourceT) {
247
- let i = -1;
248
- for (const item of sourceT) {
249
- yield callbackFn(item, sourceB.next().value, ++i);
250
- }
251
- };
252
- }
253
- function join(sT_or_sU, sU_or_cb, callbackFn) {
254
- return isSource(sU_or_cb) ? joinGen(sU_or_cb, callbackFn)(sT_or_sU) : joinGen(sT_or_sU, sU_or_cb);
255
- }
256
-
257
- function mapGen(callbackFn) {
258
- return function* (source) {
259
- let i = -1;
260
- for (const item of source) {
261
- yield callbackFn(item, ++i);
262
- }
263
- };
264
- }
265
- function map(s_or_cb, callbackFn) {
266
- return isSource(s_or_cb) ? mapGen(callbackFn)(s_or_cb) : mapGen(s_or_cb);
267
- }
268
-
269
- function normalizeGen() {
270
- const calcExtent = scalar(extent());
271
- return function* (_source) {
272
- const source = Array.isArray(_source) ? _source : [..._source];
273
- const range = calcExtent(source);
274
- const divisor = (range[1] - range[0]) || 1;
275
- const normalizeMap = map((row) => (row - range[0]) / divisor);
276
- return yield* normalizeMap(source);
277
- };
278
- }
279
- function normalize(s_or_undef) {
280
- return isSource(s_or_undef) ? normalizeGen()(s_or_undef) : normalizeGen();
281
- }
282
-
283
- function skipGen(n) {
284
- return function* (source) {
285
- let i = -1;
286
- for (const item of source) {
287
- if (++i >= n) {
288
- yield item;
289
- }
290
- }
291
- };
292
- }
293
- function skip(s_or_n, n) {
294
- return isSource(s_or_n) ? skipGen(n)(s_or_n) : skipGen(s_or_n);
295
- }
296
-
297
- function sortGen(compareFn) {
298
- return function* (source) {
299
- yield* (Array.isArray(source) ? source : [...source]).sort(compareFn);
300
- };
301
- }
302
- function sort(s_or_cb, callbackFn) {
303
- return isSource(s_or_cb) ? sortGen(callbackFn)(s_or_cb) : sortGen(s_or_cb);
304
- }
305
-
306
- function count() {
307
- let count;
308
- return {
309
- observe: (value, idx) => {
310
- if (idx === 0) {
311
- count = 0;
312
- }
313
- ++count;
314
- },
315
- peek: () => count
316
- };
317
- }
318
-
319
- function _variance() {
320
- let count;
321
- let mean;
322
- let sum;
323
- return {
324
- observe: (value, idx) => {
325
- if (idx === 0) {
326
- count = 0;
327
- mean = 0;
328
- sum = 0;
329
- }
330
- const delta = value - mean;
331
- mean += delta / ++count;
332
- sum += delta * (value - mean);
333
- },
334
- peek: () => count > 1 ? sum / (count - 1) : undefined
335
- };
336
- }
337
- function variance(callbackFn) {
338
- return callbackFn ? Accessor(_variance, callbackFn) : _variance();
339
- }
340
-
341
- function _deviation() {
342
- const v = variance();
343
- return {
344
- observe: (value, idx) => {
345
- v.observe(value, idx);
346
- },
347
- peek: () => {
348
- const variance = v.peek();
349
- return variance !== undefined ? Math.sqrt(variance) : variance;
350
- }
351
- };
352
- }
353
- function deviation(callbackFn) {
354
- return callbackFn ? Accessor(_deviation, callbackFn) : _deviation();
355
- }
356
-
357
- function _mean() {
358
- let total;
359
- let count;
360
- return {
361
- observe: (value, idx) => {
362
- if (idx === 0) {
363
- total = value;
364
- }
365
- else {
366
- total += value;
367
- }
368
- count = idx;
369
- },
370
- peek: () => total / (count + 1)
371
- };
372
- }
373
- function mean(callbackFn) {
374
- return callbackFn ? Accessor(_mean, callbackFn) : _mean();
375
- }
376
-
377
- function _distribution() {
378
- const minFO = min();
379
- const maxFO = max();
380
- const meanFO = mean();
381
- const varianceFO = variance();
382
- return {
383
- observe: (value, idx) => {
384
- minFO.observe(value, idx);
385
- maxFO.observe(value, idx);
386
- meanFO.observe(value, idx);
387
- varianceFO.observe(value, idx);
388
- },
389
- peek: () => {
390
- const minResult = minFO.peek();
391
- if (minResult === undefined)
392
- return undefined;
393
- const varianceResult = varianceFO.peek();
394
- return {
395
- min: minResult,
396
- max: maxFO.peek(),
397
- mean: meanFO.peek(),
398
- variance: varianceResult,
399
- deviation: varianceResult !== undefined ? Math.sqrt(varianceResult) : undefined
400
- };
401
- }
402
- };
403
- }
404
- function distribution(callbackFn) {
405
- return callbackFn ? Accessor(_distribution, callbackFn) : _distribution();
406
- }
407
-
408
- function _median() {
409
- let values;
410
- return {
411
- observe: (value, idx) => {
412
- if (idx === 0) {
413
- values = [];
414
- }
415
- values.push(value);
416
- },
417
- peek: () => {
418
- const sorted = values.sort((l, r) => l - r);
419
- const mid = sorted.length / 2;
420
- if (sorted.length % 2 === 0) {
421
- return (sorted[mid - 1] + sorted[mid]) / 2;
422
- }
423
- else {
424
- return sorted[Math.floor(mid)];
425
- }
426
- }
427
- };
428
- }
429
- function median(callbackFn) {
430
- return callbackFn ? Accessor(_median, callbackFn) : _median();
431
- }
432
-
433
- function _quartile() {
434
- let values;
435
- return {
436
- observe: (value, idx) => {
437
- if (idx === 0) {
438
- values = [];
439
- }
440
- values.push(value);
441
- },
442
- peek: () => {
443
- const sorted = values.sort((l, r) => l - r);
444
- const mid = sorted.length / 2;
445
- let medianVal;
446
- let lower;
447
- let upper;
448
- if (sorted.length < 2) {
449
- return undefined;
450
- }
451
- else if (sorted.length % 2 === 0) {
452
- medianVal = (sorted[mid - 1] + sorted[mid]) / 2;
453
- lower = sorted.slice(0, mid);
454
- upper = sorted.slice(mid);
455
- }
456
- else {
457
- medianVal = sorted[Math.floor(mid)];
458
- lower = sorted.slice(0, Math.floor(mid));
459
- upper = sorted.slice(Math.ceil(mid));
460
- }
461
- return [sorted[0], scalar(median())(lower), medianVal, scalar(median())(upper), sorted[sorted.length - 1]];
462
- }
463
- };
464
- }
465
- function quartile(callbackFn) {
466
- return callbackFn ? Accessor(_quartile, callbackFn) : _quartile();
467
- }
468
-
469
- function _reduce(callback, initialValue) {
470
- let reduced;
471
- return {
472
- observe: (value, idx) => {
473
- if (idx === 0) {
474
- reduced = initialValue === undefined ? value : callback(initialValue, value, idx);
475
- }
476
- else {
477
- reduced = callback(reduced, value, idx);
478
- }
479
- },
480
- peek: () => reduced
481
- };
482
- }
483
- function reduce(callbackFn, initialValue) {
484
- return _reduce(callbackFn, initialValue);
485
- }
486
-
487
- function* generate(generatorFn, maxLen) {
488
- let i = -1;
489
- while (maxLen === undefined || ++i < maxLen) {
490
- yield generatorFn();
491
- }
492
- }
493
-
494
- const GeneratorFunction = (function* () { }).constructor;
495
- function chainGen(...items) {
496
- if (items[items.length - 1] instanceof GeneratorFunction) {
497
- return function* (source) {
498
- // @ts-ignore
499
- let tail = source;
500
- for (const activity of items) {
501
- // @ts-ignore
502
- tail = activity(tail);
503
- }
504
- yield* tail;
505
- };
506
- }
507
- else {
508
- return function (source) {
509
- // @ts-ignore
510
- let tail = source;
511
- for (const activity of items) {
512
- // @ts-ignore
513
- tail = activity(tail);
514
- }
515
- return tail;
516
- };
517
- }
518
- }
519
- function pipe(s_or_ia, ...items) {
520
- return isSource(s_or_ia) ? chainGen(...items)(s_or_ia) : chainGen(s_or_ia, ...items);
521
- }
522
- // Maintain backward compatibility
523
- const chain = pipe;
524
-
525
- exports.Accessor = Accessor;
526
- exports.activity = activity;
527
- exports.chain = chain;
528
- exports.concat = concat;
529
- exports.count = count;
530
- exports.deviation = deviation;
531
- exports.distribution = distribution;
532
- exports.each = each;
533
- exports.entries = entries;
534
- exports.extent = extent;
535
- exports.filter = filter;
536
- exports.first = first;
537
- exports.generate = generate;
538
- exports.group = group;
539
- exports.histogram = histogram;
540
- exports.isSource = isSource;
541
- exports.join = join;
542
- exports.map = map;
543
- exports.max = max;
544
- exports.mean = mean;
545
- exports.median = median;
546
- exports.min = min;
547
- exports.normalize = normalize;
548
- exports.pipe = pipe;
549
- exports.quartile = quartile;
550
- exports.reduce = reduce;
551
- exports.scalar = scalar;
552
- exports.sensor = sensor;
553
- exports.skip = skip;
554
- exports.sort = sort;
555
- exports.variance = variance;
556
-
557
- }));
1
+ function c(e){return e&&(typeof e[Symbol.iterator]=="function"||Array.isArray(e))}function x(e){return function*(t){yield*t,yield*e}}function $(e,t){return t!==void 0?x(t)(e):x(e)}function U(e){return function*(t){let r=-1;for(let i of t)e(i,++r),yield i}}function d(e,t){return c(e)?U(t)(e):U(e)}function S(){return function*(e){let t=-1;for(let r of e)yield[++t,r]}}function ie(e){return e?S()(e):S()}function k(e){return function*(t){let r=-1;for(let i of t)e(i,++r)&&(yield i)}}function ae(e,t){return c(e)?k(t)(e):k(e)}function O(e){return function*(t){let r=0;for(let i of t)if(yield i,++r>=e)break}}function ye(e,t){return c(e)?O(t)(e):O(e)}function h(e){return function*(t){let r=-1,i={};for(let n of t){let o=e(n,++r);i[o]||(i[o]=[]),i[o].push(n)}for(let n in i)yield{key:n,value:i[n]}}}function Ae(e,t){return c(e)?h(t)(e):h(e)}function I(e,t){let r=e();return{observe:(i,n)=>{r.observe(t(i,n),n)},peek:r.peek}}function Ue(e){return d((t,r)=>e.observe(t,r))}function de(e){return function*(t){let r=-1;for(let i of t)e.observe(i,++r);yield e.peek()}}function T(e){return function(t){let r=-1;for(let i of t)e.observe(i,++r);return e.peek()}}function F(){let e;return{observe:(t,r)=>{(r===0||e<t)&&(e=t)},peek:()=>e}}function v(e){return e?I(F,e):F()}function g(){let e;return{observe:(t,r)=>{(r===0||e>t)&&(e=t)},peek:()=>e}}function p(e){return e?I(g,e):g()}function w(){let e=p(),t=v();return{observe:(r,i)=>{e.observe(r,i),t.observe(r,i)},peek:()=>[e.peek(),t.peek()]}}function s(e){return e?I(w,e):w()}function P(e){return e.buckets!==void 0}function C(e,t){return function*(r){let i,n,o;if(P(t)){o=Array.isArray(r)?r:[...r];let a=T(s(e))(o);if(a===void 0)return;i=a[0];let y=a[1],l=t.buckets;n=(y-i)/l}else o=r,i=t.min,n=t.range;let u={},b=0;for(let a of o){let y=e(a),l=Math.floor((y-i)/n);b<l&&(b=l),u[l]===void 0&&(u[l]=[]),u[l].push(a)}let f=u[b],N=i+b*n;for(let a=0;a<=b;++a){if(a===b-1&&f.every(y=>N===e(y))){yield{from:i+a*n,to:i+(a+1)*n,value:[...u[a]||[],...f]};break}yield{from:i+a*n,to:i+(a+1)*n,value:u[a]||[]}}}}function je(e,t,r){return c(e)?C(t,r)(e):C(e,t)}function M(e,t){let r=Array.isArray(e)?e[Symbol.iterator]():e;return function*(i){let n=-1;for(let o of i)yield t(o,r.next().value,++n)}}function Xe(e,t,r){return c(t)?M(t,r)(e):M(e,t)}function G(e){return function*(t){let r=-1;for(let i of t)yield e(i,++r)}}function V(e,t){return c(e)?G(t)(e):G(e)}function R(){let e=T(s());return function*(t){let r=Array.isArray(t)?t:[...t],i=e(r),n=i[1]-i[0]||1;return yield*V(u=>(u-i[0])/n)(r)}}function ct(e){return c(e)?R()(e):R()}function D(e){return function*(t){let r=-1;for(let i of t)++r>=e&&(yield i)}}function lt(e,t){return c(e)?D(t)(e):D(e)}function H(e){return function*(t){yield*(Array.isArray(t)?t:[...t]).sort(e)}}function st(e,t){return c(e)?H(t)(e):H(e)}function At(){let e;return{observe:(t,r)=>{r===0&&(e=0),++e},peek:()=>e}}function E(){let e,t,r;return{observe:(i,n)=>{n===0&&(e=0,t=0,r=0);let o=i-t;t+=o/++e,r+=o*(i-t)},peek:()=>e>1?r/(e-1):void 0}}function m(e){return e?I(E,e):E()}function B(){let e=m();return{observe:(t,r)=>{e.observe(t,r)},peek:()=>{let t=e.peek();return t!==void 0?Math.sqrt(t):t}}}function gt(e){return e?I(B,e):B()}function Q(){let e,t;return{observe:(r,i)=>{i===0?e=r:e+=r,t=i},peek:()=>e/(t+1)}}function z(e){return e?I(Q,e):Q()}function q(){let e=p(),t=v(),r=z(),i=m();return{observe:(n,o)=>{e.observe(n,o),t.observe(n,o),r.observe(n,o),i.observe(n,o)},peek:()=>{let n=e.peek();if(n===void 0)return;let o=i.peek();return{min:n,max:t.peek(),mean:r.peek(),variance:o,deviation:o!==void 0?Math.sqrt(o):void 0}}}}function Qt(e){return e?I(q,e):q()}function J(){let e;return{observe:(t,r)=>{r===0&&(e=[]),e.push(t)},peek:()=>{let t=e.sort((i,n)=>i-n),r=t.length/2;return t.length%2===0?(t[r-1]+t[r])/2:t[Math.floor(r)]}}}function A(e){return e?I(J,e):J()}function j(){let e;return{observe:(t,r)=>{r===0&&(e=[]),e.push(t)},peek:()=>{let t=e.sort((u,b)=>u-b),r=t.length/2,i,n,o;if(!(t.length<2))return t.length%2===0?(i=(t[r-1]+t[r])/2,n=t.slice(0,r),o=t.slice(r)):(i=t[Math.floor(r)],n=t.slice(0,Math.floor(r)),o=t.slice(Math.ceil(r))),[t[0],T(A())(n),i,T(A())(o),t[t.length-1]]}}}function Yt(e){return e?I(j,e):j()}function W(e,t){let r;return{observe:(i,n)=>{n===0?r=t===void 0?i:e(t,i,n):r=e(r,i,n)},peek:()=>r}}function $t(e,t){return W(e,t)}function*_t(e,t){let r=-1;for(;t===void 0||++r<t;)yield e()}var X=function*(){}.constructor;function K(...e){return e[e.length-1]instanceof X?function*(t){let r=t;for(let i of e)r=i(r);yield*r}:function(t){let r=t;for(let i of e)r=i(r);return r}}function Y(e,...t){return c(e)?K(...t)(e):K(e,...t)}var or=Y;export{I as Accessor,de as activity,or as chain,$ as concat,At as count,gt as deviation,Qt as distribution,d as each,ie as entries,s as extent,ae as filter,ye as first,_t as generate,Ae as group,je as histogram,c as isSource,Xe as join,V as map,v as max,z as mean,A as median,p as min,ct as normalize,Y as pipe,Yt as quartile,$t as reduce,T as scalar,Ue as sensor,lt as skip,st as sort,m as variance};
558
2
  //# sourceMappingURL=index.js.map