@eagleoutice/flowr 1.4.1 → 1.5.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 (300) hide show
  1. package/README.md +3 -3
  2. package/abstract-interpretation/processor.js +9 -3
  3. package/config.d.ts +16 -0
  4. package/config.js +75 -0
  5. package/core/input.d.ts +1 -1
  6. package/core/output.d.ts +1 -2
  7. package/core/print/parse-printer.d.ts +1 -2
  8. package/core/print/parse-printer.js +6 -4
  9. package/core/print/slice-diff-ansi.js +7 -7
  10. package/core/slicer.js +4 -8
  11. package/core/steps.d.ts +355 -31
  12. package/core/steps.js +7 -14
  13. package/dataflow/environments/environment.js +8 -0
  14. package/dataflow/environments/register.js +1 -0
  15. package/dataflow/extractor.d.ts +2 -2
  16. package/dataflow/extractor.js +10 -2
  17. package/dataflow/internal/process/functions/function-call.js +7 -1
  18. package/dataflow/internal/process/functions/source.d.ts +8 -0
  19. package/dataflow/internal/process/functions/source.js +81 -0
  20. package/dataflow/processor.d.ts +10 -1
  21. package/index.d.ts +0 -2
  22. package/index.js +0 -2
  23. package/package.json +75 -202
  24. package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
  25. package/r-bridge/lang-4.x/ast/index.js +3 -0
  26. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
  27. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
  28. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
  29. package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
  30. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
  31. package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
  32. package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
  33. package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
  34. package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
  35. package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
  36. package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
  37. package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
  38. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
  39. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
  40. package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
  41. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
  42. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
  43. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
  44. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
  45. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
  46. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
  47. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
  48. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
  49. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
  50. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
  51. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
  52. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
  53. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
  54. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
  55. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
  56. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
  57. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
  58. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
  59. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
  60. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
  61. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
  62. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
  63. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
  64. package/r-bridge/lang-4.x/values.d.ts +0 -1
  65. package/r-bridge/lang-4.x/values.js +14 -6
  66. package/r-bridge/retriever.d.ts +25 -21
  67. package/r-bridge/retriever.js +73 -23
  68. package/r-bridge/shell-executor.d.ts +3 -17
  69. package/r-bridge/shell-executor.js +9 -78
  70. package/r-bridge/shell.d.ts +5 -27
  71. package/r-bridge/shell.js +31 -92
  72. package/{statistics/output → util}/ansi.js +1 -1
  73. package/util/args.d.ts +8 -4
  74. package/util/args.js +11 -4
  75. package/util/cfg/visitor.js +1 -1
  76. package/util/files.d.ts +6 -0
  77. package/util/files.js +11 -1
  78. package/util/log.js +3 -0
  79. package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
  80. package/util/summarizer.js +37 -0
  81. package/util/version.d.ts +2 -0
  82. package/util/version.js +10 -0
  83. package/benchmark/index.d.ts +0 -3
  84. package/benchmark/index.js +0 -20
  85. package/benchmark/slicer.d.ts +0 -101
  86. package/benchmark/slicer.js +0 -225
  87. package/benchmark/stats/index.d.ts +0 -10
  88. package/benchmark/stats/index.js +0 -27
  89. package/benchmark/stats/print.d.ts +0 -7
  90. package/benchmark/stats/print.js +0 -157
  91. package/benchmark/stats/stats.d.ts +0 -41
  92. package/benchmark/stats/stats.js +0 -6
  93. package/benchmark/stopwatch.d.ts +0 -35
  94. package/benchmark/stopwatch.js +0 -79
  95. package/cli/benchmark-app.d.ts +0 -9
  96. package/cli/benchmark-app.js +0 -52
  97. package/cli/benchmark-helper-app.d.ts +0 -7
  98. package/cli/benchmark-helper-app.js +0 -60
  99. package/cli/common/features.d.ts +0 -3
  100. package/cli/common/features.js +0 -30
  101. package/cli/common/index.d.ts +0 -2
  102. package/cli/common/index.js +0 -19
  103. package/cli/common/options.d.ts +0 -20
  104. package/cli/common/options.js +0 -82
  105. package/cli/common/script.d.ts +0 -21
  106. package/cli/common/script.js +0 -61
  107. package/cli/common/scripts-info.d.ts +0 -24
  108. package/cli/common/scripts-info.js +0 -69
  109. package/cli/export-quads-app.d.ts +0 -7
  110. package/cli/export-quads-app.js +0 -46
  111. package/cli/repl/commands/cfg.d.ts +0 -3
  112. package/cli/repl/commands/cfg.js +0 -37
  113. package/cli/repl/commands/commands.d.ts +0 -11
  114. package/cli/repl/commands/commands.js +0 -103
  115. package/cli/repl/commands/dataflow.d.ts +0 -3
  116. package/cli/repl/commands/dataflow.js +0 -34
  117. package/cli/repl/commands/execute.d.ts +0 -4
  118. package/cli/repl/commands/execute.js +0 -27
  119. package/cli/repl/commands/index.d.ts +0 -2
  120. package/cli/repl/commands/index.js +0 -19
  121. package/cli/repl/commands/main.d.ts +0 -39
  122. package/cli/repl/commands/main.js +0 -14
  123. package/cli/repl/commands/normalize.d.ts +0 -3
  124. package/cli/repl/commands/normalize.js +0 -34
  125. package/cli/repl/commands/parse.d.ts +0 -2
  126. package/cli/repl/commands/parse.js +0 -109
  127. package/cli/repl/commands/quit.d.ts +0 -2
  128. package/cli/repl/commands/quit.js +0 -12
  129. package/cli/repl/commands/version.d.ts +0 -16
  130. package/cli/repl/commands/version.js +0 -33
  131. package/cli/repl/core.d.ts +0 -39
  132. package/cli/repl/core.js +0 -116
  133. package/cli/repl/execute.d.ts +0 -28
  134. package/cli/repl/execute.js +0 -79
  135. package/cli/repl/index.d.ts +0 -5
  136. package/cli/repl/index.js +0 -22
  137. package/cli/repl/prompt.d.ts +0 -2
  138. package/cli/repl/prompt.js +0 -9
  139. package/cli/repl/server/connection.d.ts +0 -21
  140. package/cli/repl/server/connection.js +0 -218
  141. package/cli/repl/server/messages/analysis.d.ts +0 -71
  142. package/cli/repl/server/messages/analysis.js +0 -21
  143. package/cli/repl/server/messages/error.d.ts +0 -11
  144. package/cli/repl/server/messages/error.js +0 -3
  145. package/cli/repl/server/messages/hello.d.ts +0 -20
  146. package/cli/repl/server/messages/hello.js +0 -3
  147. package/cli/repl/server/messages/index.d.ts +0 -1
  148. package/cli/repl/server/messages/index.js +0 -3
  149. package/cli/repl/server/messages/messages.d.ts +0 -35
  150. package/cli/repl/server/messages/messages.js +0 -40
  151. package/cli/repl/server/messages/repl.d.ts +0 -33
  152. package/cli/repl/server/messages/repl.js +0 -37
  153. package/cli/repl/server/messages/slice.d.ts +0 -25
  154. package/cli/repl/server/messages/slice.js +0 -37
  155. package/cli/repl/server/net.d.ts +0 -49
  156. package/cli/repl/server/net.js +0 -63
  157. package/cli/repl/server/send.d.ts +0 -4
  158. package/cli/repl/server/send.js +0 -18
  159. package/cli/repl/server/server.d.ts +0 -20
  160. package/cli/repl/server/server.js +0 -66
  161. package/cli/repl/server/validate.d.ts +0 -15
  162. package/cli/repl/server/validate.js +0 -34
  163. package/cli/slicer-app.d.ts +0 -11
  164. package/cli/slicer-app.js +0 -81
  165. package/cli/statistics-app.d.ts +0 -11
  166. package/cli/statistics-app.js +0 -98
  167. package/cli/statistics-helper-app.d.ts +0 -11
  168. package/cli/statistics-helper-app.js +0 -83
  169. package/cli/summarizer-app.d.ts +0 -18
  170. package/cli/summarizer-app.js +0 -67
  171. package/flowr.d.ts +0 -27
  172. package/flowr.js +0 -137
  173. package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
  174. package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
  175. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
  176. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
  177. package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
  178. package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
  179. package/statistics/features/common-syntax-probability.d.ts +0 -31
  180. package/statistics/features/common-syntax-probability.js +0 -156
  181. package/statistics/features/feature.d.ts +0 -175
  182. package/statistics/features/feature.js +0 -30
  183. package/statistics/features/index.d.ts +0 -1
  184. package/statistics/features/index.js +0 -18
  185. package/statistics/features/post-processing.d.ts +0 -12
  186. package/statistics/features/post-processing.js +0 -21
  187. package/statistics/features/supported/assignments/assignments.d.ts +0 -11
  188. package/statistics/features/supported/assignments/assignments.js +0 -53
  189. package/statistics/features/supported/assignments/index.d.ts +0 -1
  190. package/statistics/features/supported/assignments/index.js +0 -6
  191. package/statistics/features/supported/assignments/post-process.d.ts +0 -3
  192. package/statistics/features/supported/assignments/post-process.js +0 -125
  193. package/statistics/features/supported/comments/comments.d.ts +0 -18
  194. package/statistics/features/supported/comments/comments.js +0 -133
  195. package/statistics/features/supported/comments/index.d.ts +0 -1
  196. package/statistics/features/supported/comments/index.js +0 -6
  197. package/statistics/features/supported/comments/post-process.d.ts +0 -3
  198. package/statistics/features/supported/comments/post-process.js +0 -50
  199. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  200. package/statistics/features/supported/control-flow/control-flow.js +0 -67
  201. package/statistics/features/supported/control-flow/index.d.ts +0 -1
  202. package/statistics/features/supported/control-flow/index.js +0 -6
  203. package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
  204. package/statistics/features/supported/control-flow/post-process.js +0 -65
  205. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  206. package/statistics/features/supported/data-access/data-access.js +0 -118
  207. package/statistics/features/supported/data-access/index.d.ts +0 -1
  208. package/statistics/features/supported/data-access/index.js +0 -6
  209. package/statistics/features/supported/data-access/post-process.d.ts +0 -3
  210. package/statistics/features/supported/data-access/post-process.js +0 -107
  211. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
  212. package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
  213. package/statistics/features/supported/defined-functions/index.d.ts +0 -1
  214. package/statistics/features/supported/defined-functions/index.js +0 -6
  215. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  216. package/statistics/features/supported/defined-functions/post-process.js +0 -177
  217. package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
  218. package/statistics/features/supported/expression-list/expression-list.js +0 -36
  219. package/statistics/features/supported/expression-list/index.d.ts +0 -1
  220. package/statistics/features/supported/expression-list/index.js +0 -6
  221. package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
  222. package/statistics/features/supported/expression-list/post-process.js +0 -44
  223. package/statistics/features/supported/index.d.ts +0 -10
  224. package/statistics/features/supported/index.js +0 -27
  225. package/statistics/features/supported/loops/index.d.ts +0 -1
  226. package/statistics/features/supported/loops/index.js +0 -6
  227. package/statistics/features/supported/loops/loops.d.ts +0 -20
  228. package/statistics/features/supported/loops/loops.js +0 -79
  229. package/statistics/features/supported/loops/post-process.d.ts +0 -3
  230. package/statistics/features/supported/loops/post-process.js +0 -72
  231. package/statistics/features/supported/used-functions/index.d.ts +0 -1
  232. package/statistics/features/supported/used-functions/index.js +0 -6
  233. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  234. package/statistics/features/supported/used-functions/post-process.js +0 -179
  235. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  236. package/statistics/features/supported/used-functions/used-functions.js +0 -95
  237. package/statistics/features/supported/used-packages/index.d.ts +0 -1
  238. package/statistics/features/supported/used-packages/index.js +0 -6
  239. package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
  240. package/statistics/features/supported/used-packages/post-process.js +0 -121
  241. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  242. package/statistics/features/supported/used-packages/used-packages.js +0 -130
  243. package/statistics/features/supported/values/index.d.ts +0 -1
  244. package/statistics/features/supported/values/index.js +0 -6
  245. package/statistics/features/supported/values/post-process.d.ts +0 -3
  246. package/statistics/features/supported/values/post-process.js +0 -72
  247. package/statistics/features/supported/values/values.d.ts +0 -14
  248. package/statistics/features/supported/values/values.js +0 -101
  249. package/statistics/features/supported/variables/index.d.ts +0 -1
  250. package/statistics/features/supported/variables/index.js +0 -6
  251. package/statistics/features/supported/variables/post-process.d.ts +0 -9
  252. package/statistics/features/supported/variables/post-process.js +0 -122
  253. package/statistics/features/supported/variables/variables.d.ts +0 -15
  254. package/statistics/features/supported/variables/variables.js +0 -70
  255. package/statistics/index.d.ts +0 -6
  256. package/statistics/index.js +0 -24
  257. package/statistics/meta-statistics.d.ts +0 -33
  258. package/statistics/meta-statistics.js +0 -17
  259. package/statistics/output/file-provider.d.ts +0 -37
  260. package/statistics/output/file-provider.js +0 -97
  261. package/statistics/output/index.d.ts +0 -4
  262. package/statistics/output/index.js +0 -21
  263. package/statistics/output/print-stats.d.ts +0 -17
  264. package/statistics/output/print-stats.js +0 -69
  265. package/statistics/output/statistics-file.d.ts +0 -37
  266. package/statistics/output/statistics-file.js +0 -69
  267. package/statistics/statistics.d.ts +0 -24
  268. package/statistics/statistics.js +0 -109
  269. package/util/summarizer/auto-detect.d.ts +0 -2
  270. package/util/summarizer/auto-detect.js +0 -32
  271. package/util/summarizer/benchmark/data.d.ts +0 -66
  272. package/util/summarizer/benchmark/data.js +0 -13
  273. package/util/summarizer/benchmark/first-phase/input.d.ts +0 -2
  274. package/util/summarizer/benchmark/first-phase/input.js +0 -59
  275. package/util/summarizer/benchmark/first-phase/process.d.ts +0 -10
  276. package/util/summarizer/benchmark/first-phase/process.js +0 -208
  277. package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
  278. package/util/summarizer/benchmark/second-phase/graph.js +0 -54
  279. package/util/summarizer/benchmark/second-phase/process.d.ts +0 -4
  280. package/util/summarizer/benchmark/second-phase/process.js +0 -89
  281. package/util/summarizer/benchmark/summarizer.d.ts +0 -35
  282. package/util/summarizer/benchmark/summarizer.js +0 -49
  283. package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
  284. package/util/summarizer/statistics/first-phase/process.js +0 -81
  285. package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
  286. package/util/summarizer/statistics/post-process/clusterer.js +0 -43
  287. package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
  288. package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
  289. package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
  290. package/util/summarizer/statistics/post-process/histogram.js +0 -128
  291. package/util/summarizer/statistics/post-process/index.d.ts +0 -4
  292. package/util/summarizer/statistics/post-process/index.js +0 -21
  293. package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
  294. package/util/summarizer/statistics/post-process/post-process-output.js +0 -104
  295. package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
  296. package/util/summarizer/statistics/second-phase/process.js +0 -117
  297. package/util/summarizer/statistics/summarizer.d.ts +0 -35
  298. package/util/summarizer/statistics/summarizer.js +0 -135
  299. package/util/summarizer/summarizer.js +0 -13
  300. /package/{statistics/output → util}/ansi.d.ts +0 -0
@@ -10,107 +10,38 @@ const child_process_1 = require("child_process");
10
10
  const lang_4_x_1 = require("./lang-4.x");
11
11
  const preload_1 = __importDefault(require("semver/preload"));
12
12
  const log_1 = require("../util/log");
13
- const fs_1 = __importDefault(require("fs"));
14
- const retriever_1 = require("./retriever");
13
+ const executorLog = log_1.log.getSubLogger({ name: 'RShellExecutor' });
15
14
  class RShellExecutor {
16
15
  options;
17
- log;
18
16
  prerequisites = [];
19
17
  constructor(options) {
20
18
  this.options = (0, objects_1.deepMergeObject)(shell_1.DEFAULT_R_SHELL_OPTIONS, options);
21
- this.log = log_1.log.getSubLogger({ name: 'RShellExecutor' });
22
19
  }
23
20
  continueOnError() {
24
- this.log.info('continue in case of Errors');
21
+ executorLog.info('continue in case of Errors');
25
22
  this.addPrerequisites('options(error=function() {})');
26
23
  return this;
27
24
  }
28
- injectLibPaths(...paths) {
29
- this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
30
- this.addPrerequisites(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
31
- return this;
32
- }
33
- tryToInjectHomeLibPath() {
34
- if (this.options.homeLibPath === undefined) {
35
- this.log.debug('ensuring home lib path exists (automatic inject)');
36
- this.addPrerequisites([
37
- 'if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }',
38
- '.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))'
39
- ]);
40
- }
41
- else {
42
- this.injectLibPaths(this.options.homeLibPath);
43
- }
44
- return this;
45
- }
46
25
  addPrerequisites(commands) {
47
26
  this.prerequisites.push(...(typeof commands == 'string' ? [commands] : commands));
48
27
  return this;
49
28
  }
50
29
  usedRVersion() {
51
30
  const version = this.run(`cat(paste0(R.version$major,".",R.version$minor), ${(0, lang_4_x_1.ts2r)(this.options.eol)})`);
52
- this.log.trace(`raw version: ${JSON.stringify(version)}`);
31
+ executorLog.trace(`raw version: ${JSON.stringify(version)}`);
53
32
  return preload_1.default.coerce(version);
54
33
  }
55
- allInstalledPackages() {
56
- this.log.debug('getting all installed packages');
57
- const packages = this.run(`cat(paste0(installed.packages()[,1], collapse=","),"${this.options.eol}")`);
58
- return packages.split(',');
59
- }
60
- isPackageInstalled(packageName) {
61
- this.log.debug(`checking if package "${packageName}" is installed`);
62
- return this.run(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`) === 'TRUE';
63
- }
64
- ensurePackageInstalled(packageName, autoload = false, force = false) {
65
- const packageExistedAlready = this.isPackageInstalled(packageName);
66
- if (!force && packageExistedAlready) {
67
- this.log.info(`package "${packageName}" is already installed`);
68
- if (autoload)
69
- this.addPrerequisites(`library(${(0, lang_4_x_1.ts2r)(packageName)})`);
70
- return { packageName, packageExistedAlready };
34
+ run(command, returnErr = false) {
35
+ command += ';base::quit()';
36
+ if (executorLog.settings.minLevel >= 1 /* LogLevel.Trace */) {
37
+ executorLog.trace(`> ${JSON.stringify(command)}`);
71
38
  }
72
- const tempDir = this.obtainTempDir();
73
- this.log.debug(`using temporary directory: "${tempDir}" to install package "${packageName}"`);
74
- this.run(`install.packages(${(0, lang_4_x_1.ts2r)(packageName)},repos="https://cloud.r-project.org/",quiet=FALSE,lib=temp)`);
75
- if (autoload)
76
- this.addPrerequisites(`library(${(0, lang_4_x_1.ts2r)(packageName)},lib.loc=temp)`);
77
- return { packageName, packageExistedAlready, libraryLocation: tempDir };
78
- }
79
- obtainTempDir() {
80
- const tempDir = this.run([
81
- 'temp <- tempdir()',
82
- `cat(temp, ${(0, lang_4_x_1.ts2r)(this.options.eol)})`
83
- ]);
84
- log_1.log.info(`obtained temp dir ${tempDir}`);
85
- const deleteOnExit = function () {
86
- if (fs_1.default.existsSync(tempDir)) {
87
- log_1.log.info(`deleting temp dir ${tempDir}`);
88
- fs_1.default.rmSync(tempDir, { recursive: true, force: true });
89
- }
90
- };
91
- process.on('SIGINT', deleteOnExit);
92
- process.on('SIGTERM', deleteOnExit);
93
- return tempDir;
94
- }
95
- getTokenMap() {
96
- this.ensurePackageInstalled('xmlparsedata', true);
97
- // we invert the token map to get a mapping back from the replacement
98
- const parsed = (0, lang_4_x_1.parseCSV)(this.run('write.table(xmlparsedata::xml_parse_token_map,sep=",",col.names=FALSE)').split('\n'));
99
- if (parsed.some(s => s.length !== 2))
100
- throw new Error(`Expected two columns in token map, but got ${JSON.stringify(parsed)}`);
101
- // we swap key and value to get the other direction, furthermore we remove quotes from keys if they are quoted
102
- const ret = {};
103
- for (const [key, value] of parsed)
104
- ret[value] = (0, retriever_1.removeTokenMapQuotationMarks)(key);
105
- return ret;
106
- }
107
- run(commands, returnErr = false) {
108
- this.log.trace(`> ${JSON.stringify(commands)}`);
109
39
  const returns = (0, child_process_1.spawnSync)(this.options.pathToRExecutable, this.options.commandLineOptions, {
110
40
  env: this.options.env,
111
41
  cwd: this.options.cwd,
42
+ windowsHide: true,
112
43
  encoding: 'utf8',
113
- input: [...this.prerequisites, commands].join(this.options.eol)
44
+ input: [...this.prerequisites, command].join(this.options.eol)
114
45
  });
115
46
  return (returnErr ? returns.stderr : returns.stdout).trim();
116
47
  }
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { type MergeableRecord } from '../util/objects';
3
3
  import type { SemVer } from 'semver';
4
- import type { TokenMap } from './retriever';
5
4
  export type OutputStreamSelector = 'stdout' | 'stderr' | 'both';
6
5
  export interface CollectorTimeout extends MergeableRecord {
7
6
  /**
@@ -60,6 +59,7 @@ export interface RShellSessionOptions extends RShellExecutionOptions {
60
59
  export interface RShellOptions extends RShellSessionOptions {
61
60
  readonly sessionName: string;
62
61
  }
62
+ export declare const DEFAULT_R_PATH: string;
63
63
  export declare const DEFAULT_R_SHELL_EXEC_OPTIONS: RShellExecutionOptions;
64
64
  export declare const DEFAULT_R_SHELL_OPTIONS: RShellOptions;
65
65
  /**
@@ -75,7 +75,6 @@ export declare class RShell {
75
75
  private session;
76
76
  private readonly log;
77
77
  private versionCache;
78
- private tokenMapCache;
79
78
  private tempDirs;
80
79
  constructor(options?: Partial<RShellOptions>);
81
80
  private revive;
@@ -85,13 +84,12 @@ export declare class RShell {
85
84
  */
86
85
  sendCommand(command: string): void;
87
86
  usedRVersion(): Promise<SemVer | null>;
87
+ injectLibPaths(...paths: string[]): void;
88
+ tryToInjectHomeLibPath(): void;
88
89
  /**
89
- * Retrieve the token map of the xmlparsedata package.
90
- *
91
- * @note For multiple calls, this makes use of caching
90
+ * checks if a given package is already installed on the system!
92
91
  */
93
- tokenMap(): Promise<TokenMap>;
94
- private retrieveTokenMap;
92
+ isPackageInstalled(packageName: string): Promise<boolean>;
95
93
  /**
96
94
  * Send a command and collect the output
97
95
  *
@@ -115,26 +113,6 @@ export declare class RShell {
115
113
  * continue working!
116
114
  */
117
115
  continueOnError(): void;
118
- injectLibPaths(...paths: string[]): void;
119
- tryToInjectHomeLibPath(): void;
120
- /**
121
- * checks if a given package is already installed on the system!
122
- */
123
- isPackageInstalled(packageName: string): Promise<boolean>;
124
- allInstalledPackages(): Promise<string[]>;
125
- /**
126
- * Installs the package using a temporary location
127
- *
128
- * @param packageName - The package to install
129
- * @param autoload - If true, the package will be loaded after installation
130
- * @param force - If true, the package will be installed no if it is already on the system and ready to be loaded
131
- */
132
- ensurePackageInstalled(packageName: string, autoload?: boolean, force?: boolean): Promise<{
133
- packageName: string;
134
- packageExistedAlready: boolean;
135
- /** the temporary directory used for the installation, undefined if none was used */
136
- libraryLocation?: string;
137
- }>;
138
116
  /**
139
117
  * Obtain the temporary directory used by R.
140
118
  * Additionally, this marks the directory for removal when the shell exits.
package/r-bridge/shell.js CHANGED
@@ -26,16 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.RShell = exports.DEFAULT_R_SHELL_OPTIONS = exports.DEFAULT_R_SHELL_EXEC_OPTIONS = exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = void 0;
29
+ exports.RShell = exports.DEFAULT_R_SHELL_OPTIONS = exports.DEFAULT_R_SHELL_EXEC_OPTIONS = exports.DEFAULT_R_PATH = exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = void 0;
30
30
  const child_process_1 = require("child_process");
31
31
  const objects_1 = require("../util/objects");
32
- const readline = __importStar(require("node:readline"));
32
+ const readline = __importStar(require("readline"));
33
33
  const lang_4_x_1 = require("./lang-4.x");
34
34
  const log_1 = require("../util/log");
35
35
  const preload_1 = __importDefault(require("semver/preload"));
36
36
  const os_1 = require("../util/os");
37
37
  const fs_1 = __importDefault(require("fs"));
38
- const retriever_1 = require("./retriever");
38
+ const config_1 = require("../config");
39
39
  exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
40
40
  from: 'stdout',
41
41
  postamble: `🐧${'-'.repeat(5)}🐧`,
@@ -47,13 +47,14 @@ exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
47
47
  automaticallyTrimOutput: true,
48
48
  errorStopsWaiting: true
49
49
  };
50
+ exports.DEFAULT_R_PATH = (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R';
50
51
  exports.DEFAULT_R_SHELL_EXEC_OPTIONS = {
51
- pathToRExecutable: (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R',
52
+ pathToRExecutable: (0, config_1.getConfig)().rPath ?? exports.DEFAULT_R_PATH,
52
53
  commandLineOptions: ['--vanilla', '--quiet', '--no-echo', '--no-save'],
53
54
  cwd: process.cwd(),
54
55
  env: process.env,
55
56
  eol: '\n',
56
- homeLibPath: (0, os_1.getPlatform)() === 'windows' ? undefined : '~/.r-libs',
57
+ homeLibPath: (0, os_1.getPlatform)() === 'windows' ? undefined : '~/.r-libs'
57
58
  };
58
59
  exports.DEFAULT_R_SHELL_OPTIONS = {
59
60
  ...exports.DEFAULT_R_SHELL_EXEC_OPTIONS,
@@ -74,7 +75,6 @@ class RShell {
74
75
  session;
75
76
  log;
76
77
  versionCache = null;
77
- tokenMapCache = null;
78
78
  // should never be more than one, but let's be sure
79
79
  tempDirs = new Set();
80
80
  constructor(options) {
@@ -116,30 +116,28 @@ class RShell {
116
116
  this.versionCache = preload_1.default.coerce(result[0]);
117
117
  return result.length === 1 ? this.versionCache : null;
118
118
  }
119
- /**
120
- * Retrieve the token map of the xmlparsedata package.
121
- *
122
- * @note For multiple calls, this makes use of caching
123
- */
124
- async tokenMap() {
125
- if (this.tokenMapCache === null) {
126
- this.tokenMapCache = await this.retrieveTokenMap();
127
- }
128
- return this.tokenMapCache;
119
+ injectLibPaths(...paths) {
120
+ this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
121
+ this._sendCommand(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
129
122
  }
130
- async retrieveTokenMap() {
131
- await this.ensurePackageInstalled('xmlparsedata', true /* use some kind of environment in the future */);
132
- // we invert the token map to get a mapping back from the replacement
133
- const parsed = (0, lang_4_x_1.parseCSV)(await this.sendCommandWithOutput('write.table(xmlparsedata::xml_parse_token_map,sep=",",col.names=FALSE)'));
134
- if (parsed.some(s => s.length !== 2)) {
135
- throw new Error(`Expected two columns in token map, but got ${JSON.stringify(parsed)}`);
123
+ tryToInjectHomeLibPath() {
124
+ // ensure the path exists first
125
+ if (this.options.homeLibPath === undefined) {
126
+ this.log.debug('ensuring home lib path exists (automatic inject)');
127
+ this.sendCommand('if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }');
128
+ this.sendCommand('.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))');
136
129
  }
137
- // we swap key and value to get the other direction, furthermore we remove quotes from keys if they are quoted
138
- const cache = {};
139
- for (const [key, value] of parsed) {
140
- cache[value] = (0, retriever_1.removeTokenMapQuotationMarks)(key);
130
+ else {
131
+ this.injectLibPaths(this.options.homeLibPath);
141
132
  }
142
- return cache;
133
+ }
134
+ /**
135
+ * checks if a given package is already installed on the system!
136
+ */
137
+ async isPackageInstalled(packageName) {
138
+ this.log.debug(`checking if package "${packageName}" is installed`);
139
+ const result = await this.sendCommandWithOutput(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`);
140
+ return result.length === 1 && result[0] === 'TRUE';
143
141
  }
144
142
  /**
145
143
  * Send a command and collect the output
@@ -197,69 +195,6 @@ class RShell {
197
195
  this.log.info('continue in case of Errors');
198
196
  this._sendCommand('options(error=function() {})');
199
197
  }
200
- injectLibPaths(...paths) {
201
- this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
202
- this._sendCommand(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
203
- }
204
- tryToInjectHomeLibPath() {
205
- // ensure the path exists first
206
- if (this.options.homeLibPath === undefined) {
207
- this.log.debug('ensuring home lib path exists (automatic inject)');
208
- this.sendCommand('if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }');
209
- this.sendCommand('.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))');
210
- }
211
- else {
212
- this.injectLibPaths(this.options.homeLibPath);
213
- }
214
- }
215
- /**
216
- * checks if a given package is already installed on the system!
217
- */
218
- async isPackageInstalled(packageName) {
219
- this.log.debug(`checking if package "${packageName}" is installed`);
220
- const result = await this.sendCommandWithOutput(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`);
221
- return result.length === 1 && result[0] === 'TRUE';
222
- }
223
- async allInstalledPackages() {
224
- this.log.debug('getting all installed packages');
225
- const [packages] = await this.sendCommandWithOutput(`cat(paste0(installed.packages()[,1], collapse=","),"${this.options.eol}")`);
226
- return packages.split(',');
227
- }
228
- /**
229
- * Installs the package using a temporary location
230
- *
231
- * @param packageName - The package to install
232
- * @param autoload - If true, the package will be loaded after installation
233
- * @param force - If true, the package will be installed no if it is already on the system and ready to be loaded
234
- */
235
- async ensurePackageInstalled(packageName, autoload = false, force = false) {
236
- const packageExistedAlready = await this.isPackageInstalled(packageName);
237
- if (!force && packageExistedAlready) {
238
- this.log.info(`package "${packageName}" is already installed`);
239
- if (autoload) {
240
- this.sendCommand(`library(${(0, lang_4_x_1.ts2r)(packageName)})`);
241
- }
242
- return {
243
- packageName,
244
- packageExistedAlready: true
245
- };
246
- }
247
- // obtain a temporary directory
248
- const tempdir = await this.obtainTmpDir();
249
- this.log.debug(`using temporary directory: "${tempdir}" to install package "${packageName}"`);
250
- await this.sendCommandWithOutput(`install.packages(${(0, lang_4_x_1.ts2r)(packageName)},repos="https://cloud.r-project.org/",quiet=FALSE,lib=temp)`, {
251
- ms: 750_000,
252
- resetOnNewData: true
253
- });
254
- if (autoload) {
255
- this.sendCommand(`library(${(0, lang_4_x_1.ts2r)(packageName)},lib.loc=temp)`);
256
- }
257
- return {
258
- packageName,
259
- libraryLocation: tempdir,
260
- packageExistedAlready
261
- };
262
- }
263
198
  /**
264
199
  * Obtain the temporary directory used by R.
265
200
  * Additionally, this marks the directory for removal when the shell exits.
@@ -307,7 +242,9 @@ class RShellSession {
307
242
  input: this.bareSession.stderr,
308
243
  terminal: false
309
244
  });
310
- this.onExit(() => { this.end(); });
245
+ this.onExit(() => {
246
+ this.end();
247
+ });
311
248
  this.options = options;
312
249
  this.log = log;
313
250
  this.setupRSessionLoggers();
@@ -351,7 +288,9 @@ class RShellSession {
351
288
  this.collectionTimeout = makeTimer();
352
289
  }
353
290
  };
354
- error = () => { resolve(result); };
291
+ error = () => {
292
+ resolve(result);
293
+ };
355
294
  this.onExit(error);
356
295
  this.on(from, 'line', handler);
357
296
  action?.();
@@ -17,7 +17,7 @@ exports.voidFormatter = new class {
17
17
  reset() {
18
18
  return '';
19
19
  }
20
- };
20
+ }();
21
21
  /**
22
22
  * This does not work if the {@link setFormatter | formatter} is void. Tries to format the text with a bold font weight.
23
23
  */
package/util/args.d.ts CHANGED
@@ -4,11 +4,15 @@
4
4
  * @module
5
5
  */
6
6
  /**
7
- * This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
7
+ * This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
8
8
  *
9
- * Given an input string like `a "b c" d` with a space character as split this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
9
+ * Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
10
+ * this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
11
+ *
12
+ * When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
10
13
  *
11
14
  * @param inputString - The string to split
12
- * @param split - The **single** character to split on (can not be the backslash or quote)
15
+ * @param escapeQuote - Keep quotes in args
16
+ * @param split - The **single** character to split on (can not be backslash or quote)
13
17
  */
14
- export declare function splitAtEscapeSensitive(inputString: string, split?: string): string[];
18
+ export declare function splitAtEscapeSensitive(inputString: string, escapeQuote?: boolean, split?: string): string[];
package/util/args.js CHANGED
@@ -7,14 +7,18 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.splitAtEscapeSensitive = void 0;
9
9
  /**
10
- * This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
10
+ * This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
11
11
  *
12
- * Given an input string like `a "b c" d` with a space character as split this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
12
+ * Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
13
+ * this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
14
+ *
15
+ * When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
13
16
  *
14
17
  * @param inputString - The string to split
15
- * @param split - The **single** character to split on (can not be the backslash or quote)
18
+ * @param escapeQuote - Keep quotes in args
19
+ * @param split - The **single** character to split on (can not be backslash or quote)
16
20
  */
17
- function splitAtEscapeSensitive(inputString, split = ' ') {
21
+ function splitAtEscapeSensitive(inputString, escapeQuote = true, split = ' ') {
18
22
  const args = [];
19
23
  let current = '';
20
24
  let inQuotes = false;
@@ -50,6 +54,9 @@ function splitAtEscapeSensitive(inputString, split = ' ') {
50
54
  }
51
55
  else if (c === '"' || c === "'") {
52
56
  inQuotes = !inQuotes;
57
+ if (!escapeQuote) {
58
+ current += c;
59
+ }
53
60
  }
54
61
  else if (c === '\\') {
55
62
  escaped = true;
@@ -49,7 +49,7 @@ class ControlFlowGraphExecutionTraceVisitor {
49
49
  return predecessors;
50
50
  }
51
51
  visit(cfg) {
52
- const visited = new Set;
52
+ const visited = new Set();
53
53
  for (const id of cfg.entryPoints) {
54
54
  const node = cfg.graph.vertices().get(id);
55
55
  (0, assert_1.guard)(node !== undefined, `Node with id ${id} not present`);
package/util/files.d.ts CHANGED
@@ -52,3 +52,9 @@ export declare function readLineByLine(filePath: string, onLine: (line: Buffer,
52
52
  * See {@link readLineByLine} for an asynchronous version.
53
53
  */
54
54
  export declare function readLineByLineSync(filePath: string, onLine: (line: Buffer, lineNumber: number) => void): void;
55
+ /**
56
+ * Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
57
+ * If an absolute path is passed, the returned path is also absolute.
58
+ * @param directory - The directory whose parent to return
59
+ */
60
+ export declare function getParentDirectory(directory: string): string;
package/util/files.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.readLineByLineSync = exports.readLineByLine = exports.writeTableAsCsv = exports.allRFilesFrom = exports.allRFiles = exports.getAllFiles = void 0;
29
+ exports.getParentDirectory = exports.readLineByLineSync = exports.readLineByLine = exports.writeTableAsCsv = exports.allRFilesFrom = exports.allRFiles = exports.getAllFiles = void 0;
30
30
  const fs_1 = __importStar(require("fs"));
31
31
  const path_1 = __importDefault(require("path"));
32
32
  const log_1 = require("./log");
@@ -141,4 +141,14 @@ function readLineByLineSync(filePath, onLine) {
141
141
  }
142
142
  }
143
143
  exports.readLineByLineSync = readLineByLineSync;
144
+ /**
145
+ * Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
146
+ * If an absolute path is passed, the returned path is also absolute.
147
+ * @param directory - The directory whose parent to return
148
+ */
149
+ function getParentDirectory(directory) {
150
+ // apparently this is somehow the best way to do it in node, what
151
+ return directory.split(path_1.default.sep).slice(0, -1).join(path_1.default.sep);
152
+ }
153
+ exports.getParentDirectory = getParentDirectory;
144
154
  //# sourceMappingURL=files.js.map
package/util/log.js CHANGED
@@ -34,6 +34,9 @@ class FlowrLogger extends tslog_1.Logger {
34
34
  exports.FlowrLogger = FlowrLogger;
35
35
  function getActiveLog() {
36
36
  return new FlowrLogger({
37
+ // set the default minimum level as Warn, and let all apps
38
+ // (like the REPL) update it to whatever they want it to be
39
+ minLevel: 4 /* LogLevel.Warn */,
37
40
  type: 'pretty',
38
41
  name: 'main',
39
42
  stylePrettyLogs: true,
@@ -1,4 +1,4 @@
1
- import type { MergeableRecord } from '../objects';
1
+ import type { MergeableRecord } from './objects';
2
2
  export declare const enum SummarizerType {
3
3
  Benchmark = "benchmark",
4
4
  Statistics = "statistics"
@@ -6,6 +6,17 @@ export declare const enum SummarizerType {
6
6
  export interface CommonSummarizerConfiguration extends MergeableRecord {
7
7
  logger: (message: string) => void;
8
8
  }
9
+ export interface SummarizedMeasurement<T = number> {
10
+ min: T;
11
+ max: T;
12
+ median: T;
13
+ /** total may be useless for some measurements, especially if they are weighted before (it is just the sum...)*/
14
+ total: T;
15
+ /** average */
16
+ mean: number;
17
+ /** standard deviation */
18
+ std: number;
19
+ }
9
20
  export declare abstract class Summarizer<Output, Configuration extends CommonSummarizerConfiguration> {
10
21
  protected readonly config: Configuration;
11
22
  protected readonly log: CommonSummarizerConfiguration['logger'];
@@ -23,3 +34,6 @@ export declare abstract class Summarizer<Output, Configuration extends CommonSum
23
34
  */
24
35
  abstract summarizePhase(): Promise<Output>;
25
36
  }
37
+ export declare function summarizedMeasurement2Csv(a: SummarizedMeasurement): string;
38
+ export declare function summarizedMeasurement2CsvHeader(prefix?: string): string;
39
+ export declare function summarizeMeasurement(data: number[], totalNumberOfDataPoints?: number): SummarizedMeasurement;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizeMeasurement = exports.summarizedMeasurement2CsvHeader = exports.summarizedMeasurement2Csv = exports.Summarizer = void 0;
4
+ const arrays_1 = require("./arrays");
5
+ class Summarizer {
6
+ config;
7
+ log;
8
+ constructor(config) {
9
+ this.config = config;
10
+ this.log = this.config.logger;
11
+ }
12
+ }
13
+ exports.Summarizer = Summarizer;
14
+ function summarizedMeasurement2Csv(a) {
15
+ return `${a.min},${a.max},${a.median},${a.mean},${a.std},${a.total}`;
16
+ }
17
+ exports.summarizedMeasurement2Csv = summarizedMeasurement2Csv;
18
+ const summarizedKeys = ['min', 'max', 'median', 'mean', 'std', 'total'];
19
+ function summarizedMeasurement2CsvHeader(prefix) {
20
+ return summarizedKeys.map(k => prefix ? `${prefix}-${k}` : k).join(',');
21
+ }
22
+ exports.summarizedMeasurement2CsvHeader = summarizedMeasurement2CsvHeader;
23
+ function summarizeMeasurement(data, totalNumberOfDataPoints) {
24
+ // just to avoid in-place modification
25
+ const sorted = [...data].sort((a, b) => a - b);
26
+ const min = sorted[0];
27
+ const max = sorted[sorted.length - 1];
28
+ const median = sorted[Math.floor(sorted.length / 2)];
29
+ const total = (0, arrays_1.sum)(sorted);
30
+ const length = totalNumberOfDataPoints ?? sorted.length;
31
+ const mean = total / length;
32
+ // sqrt(sum(x-mean)^2 / n)
33
+ const std = Math.sqrt(sorted.map(x => (x - mean) ** 2).reduce((a, b) => a + b, 0) / length);
34
+ return { min, max, median, mean, std, total };
35
+ }
36
+ exports.summarizeMeasurement = summarizeMeasurement;
37
+ //# sourceMappingURL=summarizer.js.map
@@ -0,0 +1,2 @@
1
+ import { SemVer } from 'semver';
2
+ export declare function flowrVersion(): SemVer;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flowrVersion = void 0;
4
+ const package_json_1 = require("../../package.json");
5
+ const semver_1 = require("semver");
6
+ function flowrVersion() {
7
+ return new semver_1.SemVer(package_json_1.version);
8
+ }
9
+ exports.flowrVersion = flowrVersion;
10
+ //# sourceMappingURL=version.js.map
@@ -1,3 +0,0 @@
1
- export * from './stats';
2
- export * from './slicer';
3
- export * from './stopwatch';
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./stats"), exports);
18
- __exportStar(require("./slicer"), exports);
19
- __exportStar(require("./stopwatch"), exports);
20
- //# sourceMappingURL=index.js.map