sqlmath 2022.3.5 → 2022.4.28

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.
package/.npmignore CHANGED
@@ -8,3 +8,4 @@
8
8
  !_binary_*
9
9
  !jslint.mjs
10
10
  !sqlmath.mjs
11
+ !sqlmath_custom.mjs
package/CHANGELOG.md CHANGED
@@ -1,8 +1,30 @@
1
1
  # Changelog
2
2
 
3
3
  # Todo
4
+ - sqlmath - migrate test to jsTestXxx
4
5
  - none
5
6
 
7
+ # v2022.4.28
8
+ - jslint - update jslint v2022.4.28
9
+ - sqlite - update to sqlite v3.38.2
10
+ - sqlmath - bugfix - fix crash from sql-fnc kthpercentile(), when passed with empty-list
11
+
12
+ # v2022.3.20
13
+ - sqlmath - add builtin sql-function jenks() which is a fast 1d, ml classifier
14
+ - sqlmath - merge/streamline buildstep sqlmath_custom.c into sqlmath_base.c
15
+ - sqlmath - remove unused responseType = lastMatrixDouble
16
+ - sqlmath - export c-function dbExec to wasm
17
+ - sqlmath - replace Str99 with sqlite-builtin JsonString
18
+ - update to sqlite v3.38.1
19
+ - ci - add fileCount check
20
+ - sqlmath - re-enable building shell-executable
21
+ - sqlmath - use sqlite-builtin jsonstring instead of str99 for extension kthpercentile
22
+ - sqlmath - remove zlib.h and use handcoded headers instead
23
+ - split build-step sqlite3_c to sqlite3_c, sqlite3_ext_c, to deduplicate definition SQLITE3_C2
24
+ - add shell-function shCiBuildWasm() to build wasm binaries with online demo spa.sqlchart.html
25
+ - update to sqlite v3.38.0
26
+ - create github-branch-artifact to upload shared binaries
27
+
6
28
  # v2022.3.5
7
29
  - update jslint v2022.2.20
8
30
  - add sqlite-function RANDOM1() generating random-float between 0 <= xx < 1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  # Status
5
- | Branch | [master<br>(v2022.3.5)](https://github.com/sqlmath/sqlmath/tree/master) | [beta<br>(Web Demo)](https://github.com/sqlmath/sqlmath/tree/beta) | [alpha<br>(Development)](https://github.com/sqlmath/sqlmath/tree/alpha) |
5
+ | Branch | [master<br>(v2022.4.28)](https://github.com/sqlmath/sqlmath/tree/master) | [beta<br>(Web Demo)](https://github.com/sqlmath/sqlmath/tree/beta) | [alpha<br>(Development)](https://github.com/sqlmath/sqlmath/tree/alpha) |
6
6
  |--:|:--:|:--:|:--:|
7
7
  | CI | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Amaster) | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=beta)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Abeta) | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=alpha)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Aalpha) |
8
8
  | Coverage | [![coverage](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/index.html) | [![coverage](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/index.html) | [![coverage](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/index.html) |
Binary file
Binary file
package/jslint.mjs CHANGED
@@ -94,50 +94,47 @@
94
94
  /*jslint beta, node*/
95
95
 
96
96
  /*property
97
- fud_stmt,
98
- is_fart,
99
- mode_conditional,
100
97
  JSLINT_BETA, NODE_V8_COVERAGE, a, all, argv, arity, artifact,
101
98
  assertErrorThrownAsync, assertJsonEqual, assertOrThrow, assign, async, b,
102
99
  beta, bitwise, block, body, browser, c, calls, catch, catch_list,
103
- catch_stack, causes, char, children, clear, closer,
104
- closure, code, column, concat, consoleError, console_error, console_log,
105
- constant, context, convert, count, coverageDir, create, cwd, d, dead,
106
- debugInline, default, delta, devel, directive, directive_list,
107
- directive_quiet, directives, dirname, disrupt, dot, edition, elem_list,
108
- ellipsis, else, end, endOffset, endsWith, entries, env, error, eval, every,
109
- example_list, exec, execArgv, exit, export_dict, exports, expression, extra,
110
- file, fileList, fileURLToPath, filter, finally, flag, floor, for, forEach,
111
- formatted_message, free, freeze, from, froms,
112
- fsWriteFileWithParents, functionName, function_list, function_stack,
113
- functions, get, getset, github_repo, global, global_dict, global_list,
114
- holeList, htmlEscape, id, identifier, import, import_list, inc, indent2,
115
- index, indexOf, init, initial, isArray, isBlockCoverage, isHole, isNaN,
116
- is_equal, is_weird, join, jslint, jslint_apidoc, jslint_assert,
117
- jslint_charset_ascii, jslint_cli, jslint_edition, jslint_phase1_split,
118
- jslint_phase2_lex, jslint_phase3_parse, jslint_phase4_walk,
119
- jslint_phase5_whitage, jslint_report, json, jstestDescribe, jstestIt,
120
- jstestOnExit, keys, label, lbp, led_infix, length, level, line, lineList,
121
- line_list, line_offset, line_source, lines, linesCovered, linesTotal, live,
122
- log, long, loop, m, main, map, margin, match, max, message, meta, min,
123
- mkdir, modeCoverageIgnoreFile, modeIndex, mode_cli, mode_json, mode_module,
124
- mode_noop, mode_property, mode_shebang, mode_stop, module, moduleFsInit,
125
- moduleName, module_list, name, names, node, noop, now,
126
- nr, nud_prefix, objectDeepCopyWithKeysSorted, ok, on, open, opening, option,
127
- option_dict, order, package_name, padEnd, padStart, parameters, parent,
128
- parentIi, parse, pathname, platform, pop, processArgv, process_argv,
129
- process_env, process_exit, process_version, promises, property,
130
- property_dict, push, quote, ranges, readFile, readdir, readonly, recursive,
131
- reduce, repeat, replace, resolve, result, reverse, rm, rmdir, role, round,
132
- scriptId, search, set, shebang, shift, signature, single, slice, some, sort,
133
- source, spawn, splice, split, stack, stack_trace, start, startOffset,
134
- startsWith, statement, statement_prv, stdio, stop, stop_at, stringify,
135
- switch, syntax_dict, tenure, test, test_cause, test_internal_error, this,
136
- thru, toString, token, token_global, token_list, token_nxt, token_tree,
137
- tokens, trace, tree, trim, trimEnd, trimRight, try, type, unlink, unordered,
138
- unshift, url, used, v8CoverageListMerge, v8CoverageReportCreate, value,
139
- variable, version, versions, warn, warn_at, warning, warning_list, warnings,
140
- white, wrapped, writeFile
100
+ catch_stack, causes, char, children, clear, closer, closure, code, column,
101
+ concat, consoleError, console_error, console_log, constant, context,
102
+ convert, count, coverageDir, create, cwd, d, dead, debugInline, default,
103
+ delta, devel, directive, directive_list, directive_quiet, directives,
104
+ dirname, disrupt, dot, edition, elem_list, ellipsis, else, end, endOffset,
105
+ endsWith, entries, env, error, eval, every, example_list, exec, execArgv,
106
+ exit, exitCode, export_dict, exports, expression, extra, file, fileList,
107
+ fileURLToPath, filter, finally, flag, floor, for, forEach,
108
+ formatted_message, free, freeze, from, froms, fsWriteFileWithParents,
109
+ fud_stmt, functionName, function_list, function_stack, functions, get,
110
+ getset, github_repo, global, global_dict, global_list, holeList, htmlEscape,
111
+ id, identifier, import, import_list, inc, indent2, index, indexOf, init,
112
+ initial, isArray, isBlockCoverage, isHole, isNaN, is_equal, is_fart,
113
+ is_weird, join, jslint, jslint_apidoc, jslint_assert, jslint_charset_ascii,
114
+ jslint_cli, jslint_edition, jslint_phase1_split, jslint_phase2_lex,
115
+ jslint_phase3_parse, jslint_phase4_walk, jslint_phase5_whitage,
116
+ jslint_report, json, jstestDescribe, jstestIt, jstestOnExit, keys, label,
117
+ lbp, led_infix, length, level, line, lineList, line_list, line_offset,
118
+ line_source, lines, linesCovered, linesTotal, live, log, long, loop, m, map,
119
+ margin, match, max, message, meta, min, mkdir, modeCoverageIgnoreFile,
120
+ modeIndex, mode_cli, mode_conditional, mode_json, mode_module, mode_noop,
121
+ mode_property, mode_shebang, mode_stop, module, moduleFsInit, moduleName,
122
+ module_list, name, names, node, noop, now, nr, nud_prefix,
123
+ objectDeepCopyWithKeysSorted, ok, on, open, opening, option, option_dict,
124
+ order, package_name, padEnd, padStart, parameters, parent, parentIi, parse,
125
+ pathname, platform, pop, processArgv, process_argv, process_env,
126
+ process_exit, promises, property, property_dict, push, quote, ranges,
127
+ readFile, readdir, readonly, recursive, reduce, repeat, replace, resolve,
128
+ result, reverse, role, round, scriptId, search, set, shebang, shift,
129
+ signature, single, slice, some, sort, source, spawn, splice, split, stack,
130
+ stack_trace, start, startOffset, startsWith, statement, statement_prv,
131
+ stdio, stop, stop_at, stringify, switch, syntax_dict, tenure, test,
132
+ test_cause, test_internal_error, this, thru, toString, token, token_global,
133
+ token_list, token_nxt, token_tree, tokens, trace, tree, trim, trimEnd,
134
+ trimRight, try, type, unlink, unordered, unshift, url, used,
135
+ v8CoverageListMerge, v8CoverageReportCreate, value, variable, version,
136
+ versions, warn, warn_at, warning, warning_list, warnings, white, wrapped,
137
+ writeFile
141
138
  */
142
139
 
143
140
  // init debugInline
@@ -167,11 +164,96 @@ let jslint_charset_ascii = (
167
164
  + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
168
165
  + "`abcdefghijklmnopqrstuvwxyz{|}~\u007f"
169
166
  );
170
- let jslint_edition = "v2022.2.20";
167
+ let jslint_edition = "v2022.5.1-beta";
171
168
  let jslint_export; // The jslint object to be exported.
172
169
  let jslint_fudge = 1; // Fudge starting line and starting
173
170
  // ... column to 1.
174
171
  let jslint_import_meta_url = ""; // import.meta.url used by cli.
172
+ let jslint_rgx_cap = (
173
+ /^[A-Z]/
174
+ );
175
+ let jslint_rgx_crlf = (
176
+ /\n|\r\n?/
177
+ );
178
+ let jslint_rgx_digits_bits = (
179
+ /^[01_]*/
180
+ );
181
+ let jslint_rgx_digits_decimals = (
182
+ /^[0-9_]*/
183
+ );
184
+ let jslint_rgx_digits_hexs = (
185
+ /^[0-9A-F_]*/i
186
+ );
187
+ let jslint_rgx_digits_octals = (
188
+ /^[0-7_]*/
189
+ );
190
+ let jslint_rgx_directive = (
191
+ /^(jslint|property|global)\s+(.*)$/
192
+ );
193
+ let jslint_rgx_directive_part = (
194
+ /([a-zA-Z$_][a-zA-Z0-9$_]*)(?::\s*(true|false))?,?\s*|$/g
195
+ );
196
+ let jslint_rgx_identifier = (
197
+ /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/
198
+ );
199
+ let jslint_rgx_json_number = (
200
+
201
+ // https://datatracker.ietf.org/doc/html/rfc7159#section-6
202
+ // number = [ minus ] int [ frac ] [ exp ]
203
+
204
+ /^-?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][\-+]?\d+)?$/
205
+ );
206
+ let jslint_rgx_mega = (
207
+
208
+ // Vim-hack - vim-editor has trouble parsing naked '`' in regexp
209
+
210
+ /[\u0060\\]|\$\{/
211
+ );
212
+ let jslint_rgx_module = (
213
+ /^[a-zA-Z0-9_$:.@\-\/]+$/
214
+ );
215
+ let jslint_rgx_numeric_separator_illegal = (
216
+ /__|_$|_n$/m
217
+ );
218
+ let jslint_rgx_slash_star_or_slash = (
219
+ /\/\*|\/$/
220
+ );
221
+ let jslint_rgx_tab = (
222
+ /\t/g
223
+ );
224
+ let jslint_rgx_todo = (
225
+ /\b(?:todo|TO\s?DO|HACK)\b/
226
+ );
227
+ let jslint_rgx_token = new RegExp(
228
+ "^("
229
+ + "(\\s+)"
230
+ + "|([a-zA-Z_$][a-zA-Z0-9_$]*)"
231
+ + "|[(){}\\[\\],:;'\"~\\`]"
232
+ + "|\\?[?.]?"
233
+ + "|=(?:==?|>)?"
234
+ + "|\\.+"
235
+ + "|\\*[*\\/=]?"
236
+ + "|\\/[*\\/]?"
237
+ + "|\\+[=+]?"
238
+ + "|-[=\\-]?"
239
+ + "|[\\^%]=?"
240
+ + "|&[&=]?"
241
+ + "|\\"
242
+ + "|[|=]?"
243
+ + "|>{1,3}=?"
244
+ + "|<<?=?"
245
+ + "|!(?:!|==?)?"
246
+
247
+ // PR-351 - Add BigInt support.
248
+ // PR-390 - Add numeric-separator support.
249
+
250
+ + "|((?:0_?|[1-9][0-9_]*)n?)"
251
+ + ")"
252
+ + "(.*)$"
253
+ );
254
+ let jslint_rgx_weird_property = (
255
+ /^_|\$|Sync$|_$/m
256
+ );
175
257
  let jstestCountFailed = 0;
176
258
  let jstestCountTotal = 0;
177
259
  let jstestItCount = 0;
@@ -307,10 +389,7 @@ function jslint(
307
389
  let import_list = []; // The array collecting all import-from strings.
308
390
  let line_list = String( // The array containing source lines.
309
391
  "\n" + source
310
- ).split(
311
- // rx_crlf
312
- /\n|\r\n?/
313
- ).map(function (line_source) {
392
+ ).split(jslint_rgx_crlf).map(function (line_source) {
314
393
  return {
315
394
  line_source
316
395
  };
@@ -355,8 +434,6 @@ function jslint(
355
434
  }
356
435
 
357
436
  function is_equal(aa, bb) {
358
- let aa_value;
359
- let bb_value;
360
437
 
361
438
  // test_cause:
362
439
  // ["0&&0", "is_equal", "", "", 0]
@@ -377,6 +454,7 @@ function jslint(
377
454
 
378
455
  // test_cause:
379
456
  // ["`${0}`&&`${0}`", "is_equal", "recurse_isArray", "", 0]
457
+ // ["`${0}`&&`${1}`", "is_equal", "recurse_isArray", "", 0]
380
458
 
381
459
  test_cause("recurse_isArray");
382
460
  return is_equal(value, bb[index]);
@@ -390,21 +468,19 @@ function jslint(
390
468
  // }
391
469
 
392
470
  jslint_assert(!Array.isArray(bb), `Expected !Array.isArray(bb).`);
393
- if (aa.id === "(number)" && bb.id === "(number)") {
471
+ switch (aa.id === bb.id && aa.id) {
472
+ case "(number)":
473
+ case "(string)":
394
474
  return aa.value === bb.value;
395
- }
396
- if (aa.id === "(string)") {
397
- aa_value = aa.value;
398
- } else if (aa.id === "`" && aa.constant) {
399
- aa_value = aa.value[0];
400
- }
401
- if (bb.id === "(string)") {
402
- bb_value = bb.value;
403
- } else if (bb.id === "`" && bb.constant) {
404
- bb_value = bb.value[0];
405
- }
406
- if (typeof aa_value === "string") {
407
- return aa_value === bb_value;
475
+
476
+ // PR-394 - Bugfix
477
+ // Fix jslint falsely believing megastring literals `0` and `1` are similar.
478
+
479
+ case "`":
480
+ if (!is_equal(aa.value, bb.value)) {
481
+ return false;
482
+ }
483
+ break;
408
484
  }
409
485
  if (is_weird(aa) || is_weird(bb)) {
410
486
 
@@ -687,6 +763,12 @@ function jslint(
687
763
  // case "function_in_loop":
688
764
  // mm = `Don't create functions within a loop.`;
689
765
  // break;
766
+
767
+ // PR-390 - Add numeric-separator check.
768
+
769
+ case "illegal_num_separator":
770
+ mm = `Illegal numeric separator '_' at column ${column}.`;
771
+ break;
690
772
  case "infix_in":
691
773
  mm = (
692
774
  `Unexpected 'in'. Compare with undefined,`
@@ -1841,6 +1923,8 @@ function jslint_phase2_lex(state) {
1841
1923
  let line_mega; // The starting line of megastring.
1842
1924
  let line_source = ""; // The remaining line source string.
1843
1925
  let line_whole = ""; // The whole line source string.
1926
+ let mode_digits_empty_string = 1;
1927
+ let mode_digits_numeric_separator = 2;
1844
1928
  let mode_directive = true; // true if directives are still allowed.
1845
1929
  let mode_mega = false; // true if currently parsing a megastring
1846
1930
  // ... literal.
@@ -1848,33 +1932,7 @@ function jslint_phase2_lex(state) {
1848
1932
  // ... this line.
1849
1933
  let paren_backtrack_list = []; // List of most recent "(" tokens at any
1850
1934
  // ... paren-depth.
1851
- let paren_depth = 0; // Keeps track of current paren-depth.
1852
- let rx_token = new RegExp(
1853
- "^("
1854
- + "(\\s+)"
1855
- + "|([a-zA-Z_$][a-zA-Z0-9_$]*)"
1856
- + "|[(){}\\[\\],:;'\"~\\`]"
1857
- + "|\\?[?.]?"
1858
- + "|=(?:==?|>)?"
1859
- + "|\\.+"
1860
- + "|\\*[*\\/=]?"
1861
- + "|\\/[*\\/]?"
1862
- + "|\\+[=+]?"
1863
- + "|-[=\\-]?"
1864
- + "|[\\^%]=?"
1865
- + "|&[&=]?"
1866
- + "|\\"
1867
- + "|[|=]?"
1868
- + "|>{1,3}=?"
1869
- + "|<<?=?"
1870
- + "|!(?:!|==?)?"
1871
-
1872
- // PR-351 - Add BigInt support.
1873
-
1874
- + "|(0n?|[1-9][0-9]*n?)"
1875
- + ")"
1876
- + "(.*)$"
1877
- );
1935
+ let paren_depth = 0; // Keeps track of current paren-depth.
1878
1936
  let snippet = ""; // A piece of string.
1879
1937
  let token_1; // The first token.
1880
1938
  let token_prv = token_global; // The previous token including
@@ -1956,7 +2014,7 @@ function jslint_phase2_lex(state) {
1956
2014
 
1957
2015
  warn_at("unexpected_a", line, column, char);
1958
2016
  }
1959
- if (read_digits("x") > 5) {
2017
+ if (read_digits("x", undefined) > 5) {
1960
2018
 
1961
2019
  // test_cause:
1962
2020
  // ["\"\\u{123456}\"", "char_after_escape", "too_many_digits", "", 11]
@@ -1973,7 +2031,7 @@ function jslint_phase2_lex(state) {
1973
2031
  return char_after();
1974
2032
  }
1975
2033
  char_before();
1976
- if (read_digits("x", true) < 4) {
2034
+ if (read_digits("x", mode_digits_empty_string) < 4) {
1977
2035
 
1978
2036
  // test_cause:
1979
2037
  // ["\"\\u0\"", "char_after_escape", "expected_four_digits", "", 5]
@@ -2008,6 +2066,26 @@ function jslint_phase2_lex(state) {
2008
2066
  return char;
2009
2067
  }
2010
2068
 
2069
+ function check_numeric_separator(digits, column) {
2070
+
2071
+ // This function will check for illegal numeric-separator in <digits>.
2072
+
2073
+ digits.replace((
2074
+ jslint_rgx_numeric_separator_illegal
2075
+ ), function (ignore, ii) {
2076
+
2077
+ // test_cause:
2078
+ // ["0x0_0_;", "check_numeric_separator", "illegal_num_separator", "", 6]
2079
+ // ["0x0_0__0;", "check_numeric_separator", "illegal_num_separator", "", 6]
2080
+ // ["aa=1_2_;", "check_numeric_separator", "illegal_num_separator", "", 7]
2081
+ // ["aa=1_2__3;", "check_numeric_separator", "illegal_num_separator", "", 7]
2082
+ // ["aa=1_2_n;", "check_numeric_separator", "illegal_num_separator", "", 7]
2083
+
2084
+ warn_at("illegal_num_separator", line, column + ii + 1);
2085
+ return "";
2086
+ });
2087
+ }
2088
+
2011
2089
  function lex_comment() {
2012
2090
  let body;
2013
2091
  let ii = 0;
@@ -2046,12 +2124,12 @@ function jslint_phase2_lex(state) {
2046
2124
  // Lex/loop through each line until "*/".
2047
2125
 
2048
2126
  while (true) {
2049
- // rx_star_slash
2127
+ // jslint_rgx_star_slash
2050
2128
  ii = line_source.indexOf("*/");
2051
2129
  if (ii >= 0) {
2052
2130
  break;
2053
2131
  }
2054
- // rx_slash_star
2132
+ // jslint_rgx_slash_star
2055
2133
  ii = line_source.indexOf("/*");
2056
2134
  if (ii >= 0) {
2057
2135
 
@@ -2071,8 +2149,7 @@ function jslint_phase2_lex(state) {
2071
2149
  }
2072
2150
  }
2073
2151
  jj = line_source.slice(0, ii).search(
2074
- // rx_slash_star_or_slash
2075
- /\/\*|\/$/
2152
+ jslint_rgx_slash_star_or_slash
2076
2153
  );
2077
2154
  if (jj >= 0) {
2078
2155
 
@@ -2090,13 +2167,7 @@ function jslint_phase2_lex(state) {
2090
2167
 
2091
2168
  // Uncompleted work comment.
2092
2169
 
2093
- if (
2094
- !option_dict.devel
2095
- && (
2096
- // rx_todo
2097
- /\b(?:todo|TO\s?DO|HACK)\b/
2098
- ).test(snippet)
2099
- ) {
2170
+ if (!option_dict.devel && jslint_rgx_todo.test(snippet)) {
2100
2171
 
2101
2172
  // test_cause:
2102
2173
  // ["//todo", "lex_comment", "todo_comment", "(comment)", 1] //jslint-quiet
@@ -2108,10 +2179,7 @@ function jslint_phase2_lex(state) {
2108
2179
 
2109
2180
  [
2110
2181
  the_comment.directive, body
2111
- ] = Array.from(snippet.match(
2112
- // rx_directive
2113
- /^(jslint|property|global)\s+(.*)$/
2114
- ) || []).slice(1);
2182
+ ] = Array.from(snippet.match(jslint_rgx_directive) || []).slice(1);
2115
2183
  if (the_comment.directive === undefined) {
2116
2184
  return the_comment;
2117
2185
  }
@@ -2133,10 +2201,12 @@ function jslint_phase2_lex(state) {
2133
2201
  // Lex/loop through each directive in /*...*/
2134
2202
 
2135
2203
  ii = 0;
2136
- body.replace((
2137
- // rx_directive_part
2138
- /([a-zA-Z$_][a-zA-Z0-9$_]*)(?::\s*(true|false))?,?\s*|$/g
2139
- ), function (match0, key, val, jj) {
2204
+ body.replace(jslint_rgx_directive_part, function (
2205
+ match0,
2206
+ key,
2207
+ val,
2208
+ jj
2209
+ ) {
2140
2210
  if (ii !== jj) {
2141
2211
 
2142
2212
  // test_cause:
@@ -2210,13 +2280,7 @@ function jslint_phase2_lex(state) {
2210
2280
  // string.
2211
2281
 
2212
2282
  while (true) {
2213
- match = line_source.match(
2214
-
2215
- // Vim-hack - vim-editor has trouble parsing '`' in regexp
2216
-
2217
- // rx_mega
2218
- /[\u0060\\]|\$\{/
2219
- ) || {
2283
+ match = line_source.match(jslint_rgx_mega) || {
2220
2284
  "0": "",
2221
2285
  index: 0
2222
2286
  };
@@ -2293,12 +2357,16 @@ function jslint_phase2_lex(state) {
2293
2357
 
2294
2358
  function lex_number() {
2295
2359
  let prefix = snippet;
2360
+
2361
+ // PR-390 - Add numeric-separator check.
2362
+
2363
+ check_numeric_separator(prefix, column - prefix.length);
2296
2364
  char_after();
2297
2365
  switch (prefix === "0" && char) {
2298
2366
  case "b":
2299
2367
  case "o":
2300
2368
  case "x":
2301
- read_digits(char);
2369
+ read_digits(char, mode_digits_numeric_separator);
2302
2370
 
2303
2371
  // PR-351 - Ignore BigInt suffix 'n'.
2304
2372
 
@@ -2308,14 +2376,14 @@ function jslint_phase2_lex(state) {
2308
2376
  break;
2309
2377
  default:
2310
2378
  if (char === ".") {
2311
- read_digits("d");
2379
+ read_digits("d", mode_digits_numeric_separator);
2312
2380
  }
2313
2381
  if (char === "E" || char === "e") {
2314
2382
  char_after(char);
2315
2383
  if (char !== "+" && char !== "-") {
2316
2384
  char_before();
2317
2385
  }
2318
- read_digits("d");
2386
+ read_digits("d", mode_digits_numeric_separator);
2319
2387
  }
2320
2388
  }
2321
2389
 
@@ -2585,7 +2653,7 @@ function jslint_phase2_lex(state) {
2585
2653
  }
2586
2654
  break;
2587
2655
  case "{":
2588
- if (read_digits("d", true) === 0) {
2656
+ if (read_digits("d", mode_digits_empty_string) === 0) {
2589
2657
 
2590
2658
  // test_cause:
2591
2659
  // ["aa=/aa{/", "lex_regexp_group", "expected_a_before_b", ",", 8]
@@ -2598,7 +2666,7 @@ function jslint_phase2_lex(state) {
2598
2666
  // ["aa=/.{,/", "lex_regexp_group", "comma", "", 0]
2599
2667
 
2600
2668
  test_cause("comma");
2601
- read_digits("d", true);
2669
+ read_digits("d", mode_digits_empty_string);
2602
2670
  }
2603
2671
  if (char_after("}") === "?") {
2604
2672
 
@@ -2891,7 +2959,7 @@ function jslint_phase2_lex(state) {
2891
2959
  }
2892
2960
  }
2893
2961
  from = column;
2894
- match = line_source.match(rx_token);
2962
+ match = line_source.match(jslint_rgx_token);
2895
2963
 
2896
2964
  // match[1] token
2897
2965
  // match[2] whitespace
@@ -3274,41 +3342,48 @@ import moduleHttps from "https";
3274
3342
  return true;
3275
3343
  }
3276
3344
 
3277
- function read_digits(base, quiet) {
3345
+ function read_digits(base, mode) {
3278
3346
  let digits = line_source.match(
3279
3347
  base === "b"
3280
- ? (
3281
- // rx_bits
3282
- /^[01]*/
3283
- )
3348
+ ? jslint_rgx_digits_bits
3284
3349
  : base === "o"
3285
- ? (
3286
- // rx_octals
3287
- /^[0-7]*/
3288
- )
3350
+ ? jslint_rgx_digits_octals
3289
3351
  : base === "x"
3290
- ? (
3291
- // rx_hexs
3292
- /^[0-9A-F]*/i
3293
- )
3294
- : (
3295
- // rx_digits
3296
- /^[0-9]*/
3297
- )
3352
+ ? jslint_rgx_digits_hexs
3353
+ : jslint_rgx_digits_decimals
3298
3354
  )[0];
3299
- let length = digits.length;
3300
- if (!quiet && length === 0) {
3355
+ if (
3356
+ (mode !== mode_digits_empty_string && digits.length === 0)
3357
+ || digits[0] === "_"
3358
+ ) {
3301
3359
 
3302
3360
  // test_cause:
3303
3361
  // ["0x", "read_digits", "expected_digits_after_a", "0x", 2]
3362
+ // ["0x_", "read_digits", "expected_digits_after_a", "0x", 2]
3304
3363
 
3305
3364
  warn_at("expected_digits_after_a", line, column, snippet);
3306
3365
  }
3307
- column += length;
3308
- line_source = line_source.slice(length);
3366
+
3367
+ // PR-390 - Add numeric-separator check.
3368
+
3369
+ if (mode === mode_digits_numeric_separator) {
3370
+ check_numeric_separator(digits, column);
3371
+ } else if (digits.indexOf("_") >= 0) {
3372
+
3373
+ // test_cause:
3374
+ // ["\"\\u{1_2}\"", "read_digits", "illegal_num_separator", "", 6]
3375
+
3376
+ warn_at(
3377
+ "illegal_num_separator",
3378
+ line,
3379
+ column + digits.indexOf("_") + 1
3380
+ );
3381
+ }
3382
+ column += digits.length;
3383
+ line_source = line_source.slice(digits.length);
3309
3384
  snippet += digits;
3310
3385
  char_after();
3311
- return length;
3386
+ return digits.length;
3312
3387
  }
3313
3388
 
3314
3389
  function read_line() {
@@ -3379,6 +3454,7 @@ import moduleHttps from "https";
3379
3454
  test_cause("line_disable");
3380
3455
  line_source = "";
3381
3456
  }
3457
+ // jslint_rgx_tab
3382
3458
  if (line_source.indexOf("\t") >= 0) {
3383
3459
  if (!option_dict.white) {
3384
3460
 
@@ -3387,10 +3463,7 @@ import moduleHttps from "https";
3387
3463
 
3388
3464
  warn_at("use_spaces", line, line_source.indexOf("\t") + 1);
3389
3465
  }
3390
- line_source = line_source.replace((
3391
- // rx_tab
3392
- /\t/g
3393
- ), " ");
3466
+ line_source = line_source.replace(jslint_rgx_tab, " ");
3394
3467
  }
3395
3468
  if (!option_dict.white && line_source.endsWith(" ")) {
3396
3469
 
@@ -3564,9 +3637,6 @@ function jslint_phase3_parse(state) {
3564
3637
  let catchage = catch_stack[0]; // The current catch-block.
3565
3638
  let functionage = token_global; // The current function.
3566
3639
  let mode_var; // "var" if using var; "let" if using let.
3567
- let rx_identifier = (
3568
- /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/
3569
- );
3570
3640
  let token_ii = 0; // The number of the next token.
3571
3641
  let token_now = token_global; // The current token being examined in
3572
3642
  // ... the parse.
@@ -3583,7 +3653,7 @@ function jslint_phase3_parse(state) {
3583
3653
  anon = token_now.id;
3584
3654
  } else if (
3585
3655
  token_now.id === "(string)"
3586
- && rx_identifier.test(token_now.value)
3656
+ && jslint_rgx_identifier.test(token_now.value)
3587
3657
  ) {
3588
3658
  anon = token_now.value;
3589
3659
  }
@@ -4233,7 +4303,7 @@ function jslint_phase3_parse(state) {
4233
4303
  let the_subscript = parse_expression(0);
4234
4304
  if (the_subscript.id === "(string)" || the_subscript.id === "`") {
4235
4305
  name = survey(the_subscript);
4236
- if (rx_identifier.test(name)) {
4306
+ if (jslint_rgx_identifier.test(name)) {
4237
4307
 
4238
4308
  // test_cause:
4239
4309
  // ["aa[`aa`]", "infix_lbracket", "subscript_a", "aa", 4]
@@ -4594,13 +4664,7 @@ function jslint_phase3_parse(state) {
4594
4664
  let negative;
4595
4665
  switch (token_nxt.id) {
4596
4666
  case "(number)":
4597
- if (!(
4598
-
4599
- // https://datatracker.ietf.org/doc/html/rfc7159#section-6
4600
- // number = [ minus ] int [ frac ] [ exp ]
4601
-
4602
- /^-?(?:0|[1-9]\d*?)(?:\.\d*?)?(?:[eE][+\-]?\d+?)?$/
4603
- ).test(token_nxt.value)) {
4667
+ if (!jslint_rgx_json_number.test(token_nxt.value)) {
4604
4668
 
4605
4669
  // test_cause:
4606
4670
  // ["[-.0]", "parse_json", "unexpected_a", ".", 3]
@@ -6100,10 +6164,7 @@ function jslint_phase3_parse(state) {
6100
6164
  advance("from");
6101
6165
  advance("(string)");
6102
6166
  the_import.import = token_now;
6103
- if (!(
6104
- // rx_module
6105
- /^[a-zA-Z0-9_$:.@\-\/]+$/
6106
- ).test(token_now.value)) {
6167
+ if (!jslint_rgx_module.test(token_now.value)) {
6107
6168
 
6108
6169
  // test_cause:
6109
6170
  // ["import aa from \"!aa\"", "stmt_import", "bad_module_name_a", "!aa", 16]
@@ -6714,13 +6775,13 @@ function jslint_phase3_parse(state) {
6714
6775
 
6715
6776
  if (id === "(string)") {
6716
6777
  id = name.value;
6717
- if (!rx_identifier.test(id)) {
6778
+ if (!jslint_rgx_identifier.test(id)) {
6718
6779
  return id;
6719
6780
  }
6720
6781
  } else if (id === "`") {
6721
6782
  if (name.value.length === 1) {
6722
6783
  id = name.value[0].value;
6723
- if (!rx_identifier.test(id)) {
6784
+ if (!jslint_rgx_identifier.test(id)) {
6724
6785
  return id;
6725
6786
  }
6726
6787
  }
@@ -6753,10 +6814,7 @@ function jslint_phase3_parse(state) {
6753
6814
  } else if (
6754
6815
  !option_dict.name
6755
6816
  && name.identifier
6756
- && (
6757
- // rx_weird_property
6758
- /^_|\$|Sync$|_$/m
6759
- ).test(id)
6817
+ && jslint_rgx_weird_property.test(id)
6760
6818
  ) {
6761
6819
 
6762
6820
  // test_cause:
@@ -7510,10 +7568,7 @@ function jslint_phase4_walk(state) {
7510
7568
  test_cause("cack");
7511
7569
  cack = !cack;
7512
7570
  }
7513
- if ((
7514
- // rx_cap
7515
- /^[A-Z]/
7516
- ).test(left.name.id) !== cack) {
7571
+ if (jslint_rgx_cap.test(left.name.id) !== cack) {
7517
7572
  if (the_new !== undefined) {
7518
7573
 
7519
7574
  // test_cause:
@@ -7690,6 +7745,11 @@ function jslint_phase4_walk(state) {
7690
7745
  || thing.expression[0].constant === true
7691
7746
  || is_equal(thing.expression[1], thing.expression[2])
7692
7747
  ) {
7748
+
7749
+ // test_cause:
7750
+ // ["let aa=(aa?`${0}`:`${0}`);", "post_t", "unexpected_a", "?", 11]
7751
+ // ["let aa=(aa?`0`:`0`);", "post_t", "unexpected_a", "?", 11]
7752
+
7693
7753
  warn("unexpected_a", thing);
7694
7754
  } else if (is_equal(thing.expression[0], thing.expression[1])) {
7695
7755
 
@@ -9382,6 +9442,9 @@ body {
9382
9442
  : "global"
9383
9443
  );
9384
9444
  if (global.length + froms.length + exports.length > 0) {
9445
+ if (functions.length === 0) {
9446
+ html += "<br>\n";
9447
+ }
9385
9448
  html += "<div class=\"level level0\">\n";
9386
9449
  html += detail(module, global);
9387
9450
  html += detail("import from", froms);
@@ -9546,14 +9609,14 @@ function jstestIt(description, testFunction, mode) {
9546
9609
  }));
9547
9610
  }
9548
9611
 
9549
- function jstestOnExit(exitCode, processExit, countFailed) {
9612
+ function jstestOnExit(exitCode, mode) {
9550
9613
 
9551
9614
  // This function will on process-exit, print test-report
9552
9615
  // and exit with non-zero exit-code if any test failed.
9553
9616
 
9554
9617
  let message = (
9555
9618
  (
9556
- (jstestCountFailed || countFailed)
9619
+ (jstestCountFailed || mode === "testsFailed")
9557
9620
  ? "\n\u001b[31m"
9558
9621
  : "\n\u001b[32m"
9559
9622
  )
@@ -9561,11 +9624,10 @@ function jstestOnExit(exitCode, processExit, countFailed) {
9561
9624
  + " tests failed - " + jstestCountFailed + "\n"
9562
9625
  + "\u001b[39m"
9563
9626
  );
9564
- if (!processExit) {
9627
+ if (mode !== "testsFailed") {
9565
9628
  console.error(message);
9566
- processExit = process.exit;
9567
9629
  }
9568
- processExit(exitCode || jstestCountFailed);
9630
+ process.exitCode = exitCode || jstestCountFailed;
9569
9631
  return message;
9570
9632
  }
9571
9633
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "email": "kaizhu256@gmail.com",
4
4
  "name": "kai zhu"
5
5
  },
6
- "counter": 1,
6
+ "counter": 10,
7
7
  "cpu": [
8
8
  "x64"
9
9
  ],
@@ -11,7 +11,7 @@
11
11
  "engines": {
12
12
  "node": ">=14"
13
13
  },
14
- "fileCount": 21,
14
+ "fileCount": 28,
15
15
  "homepage": "https://github.com/sqlmath/sqlmath",
16
16
  "keywords": [
17
17
  "data-science",
@@ -32,10 +32,10 @@
32
32
  "url": "https://github.com/sqlmath/sqlmath"
33
33
  },
34
34
  "scripts": {
35
- "build": "sh jslint_ci.sh shCiBuild",
36
- "test": "sh jslint_ci.sh shCiTest",
35
+ "build": "sh jslint_ci.sh shCiBuildNodejs",
36
+ "test": "sh jslint_ci.sh shCiTestNodejs",
37
37
  "test2": "sh jslint_ci.sh shCiBase",
38
38
  "test_win32": "node -e \"require('child_process').spawn('C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe',['-c','npm run test' + ' ' + process.argv.slice(1).join(' ')],{stdio:['ignore',1,2]});\""
39
39
  },
40
- "version": "2022.3.5"
40
+ "version": "2022.4.28"
41
41
  }
package/sqlmath.mjs CHANGED
@@ -211,8 +211,6 @@ file sqlmath.js
211
211
  (
212
212
  responseType === "lastBlob"
213
213
  ? 1
214
- : responseType === "lastMatrixDouble"
215
- ? 2
216
214
  : 0
217
215
  )
218
216
  ].concat(serialize.bufSharedList));
@@ -221,8 +219,6 @@ file sqlmath.js
221
219
  case "arraybuffer":
222
220
  case "lastBlob":
223
221
  return result;
224
- case "lastMatrixDouble":
225
- return new Float64Array(result);
226
222
  case "list":
227
223
  return JSON.parse(new TextDecoder().decode(result));
228
224
  default:
@@ -274,21 +270,6 @@ file sqlmath.js
274
270
  });
275
271
  }
276
272
 
277
- function dbGetLastMatrixDouble({
278
- bindList = [],
279
- db,
280
- sql
281
- }) {
282
- // this function will exec <sql> in <db> and return last SELECT-statement
283
- // from execution as row x col matrix of doubles
284
- return dbExecAsync({
285
- bindList,
286
- db,
287
- responseType: "lastMatrixDouble",
288
- sql
289
- });
290
- }
291
-
292
273
  async function dbMemoryLoadAsync({
293
274
  db,
294
275
  filename
@@ -1042,50 +1023,6 @@ Definition of the CSV Format
1042
1023
  dd
1043
1024
  });
1044
1025
  });
1045
- // test dbGetLastMatrixDouble's bind handling-behavior
1046
- [
1047
- aa
1048
- ].forEach(async function (aa) {
1049
- let cc = Number(
1050
- typeof aa === "symbol"
1051
- ? 0
1052
- : aa
1053
- ) || 0;
1054
- let dd = await dbGetLastMatrixDouble({
1055
- bindList: [
1056
- aa
1057
- ],
1058
- db,
1059
- sql: "SELECT 1, 2, 3; SELECT 1, 2, ?"
1060
- });
1061
- switch (typeof(aa)) {
1062
- case "bigint":
1063
- aa = String(aa);
1064
- break;
1065
- case "object":
1066
- if (typeof aa?.getUTCFullYear === "function") {
1067
- cc = aa.getUTCFullYear();
1068
- }
1069
- break;
1070
- }
1071
- cc = new Float64Array([
1072
- 1, 3, 1, 2, cc
1073
- ]);
1074
- // debugInline(ii, aa, bb, cc, dd);
1075
- cc.forEach(function (val, jj) {
1076
- assertJsonEqual(
1077
- val,
1078
- dd[jj],
1079
- {
1080
- ii,
1081
- aa, //jslint-quiet
1082
- bb,
1083
- cc,
1084
- dd
1085
- }
1086
- );
1087
- });
1088
- });
1089
1026
  // test dbExecAsync's responseType handling-behavior
1090
1027
  [
1091
1028
  "arraybuffer",
@@ -1391,8 +1328,8 @@ SELECT * FROM testDbExecAsync2;
1391
1328
  "COTH(-1)", -1.31303528549933,
1392
1329
  "COTH(0)", null,
1393
1330
  "COTH(1)", 1.31303528549933,
1394
- "ROUNDORZERO(NULL)", 0,
1395
1331
  "ROUNDORZERO(NULL, NULL)", 0,
1332
+ "ROUNDORZERO(NULL, 0)", 0,
1396
1333
  "ROUNDORZERO(NULL, 0.5)", 0,
1397
1334
  "ROUNDORZERO(0.5, NULL)", 1,
1398
1335
  "ROUNDORZERO(0.5, 0.5)", 1,
@@ -1776,6 +1713,8 @@ SELECT * FROM testDbExecAsync2;
1776
1713
  db,
1777
1714
  sql: (`
1778
1715
  SELECT kthpercentile(val, ${kk}) AS val FROM __tmp${ii};
1716
+ -- test null-case handling-behavior
1717
+ SELECT kthpercentile(val, ${kk}) AS val FROM __tmp${ii} WHERE 0;
1779
1718
  `),
1780
1719
  tmpRowList: data.map(function (val) {
1781
1720
  return {
@@ -0,0 +1,4 @@
1
+ /*jslint node, beta*/
2
+ import sqlmath from "./sqlmath.mjs";
3
+ let exportDict = {};
4
+ export default Object.freeze(Object.assign({}, sqlmath, exportDict));