Skip to content

Commit 9d8b248

Browse files
committed
feat: replace jq-web with emuto
1 parent a8529ad commit 9d8b248

File tree

5 files changed

+49
-16
lines changed

5 files changed

+49
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"dependencies": {
2828
"billboard.js": "^1.4.1",
2929
"d3": "4.10.0",
30+
"emuto": "^1.37.0",
3031
"fast-deep-equal": "^2.0.1",
3132
"fd-slicer": "^1.1.0",
32-
"jq-web": "^0.1.3",
3333
"sassline": "^2.1.2",
3434
"spinkit": "^1.2.5",
3535
"yamljs": "^0.3.0"

src/components/base/render.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import with_spinner from './spinner'
2-
import jq from '../../jq-web.js'
2+
import emuto from '../../jq-web.js'
33
import show_error_message from './error_handling'
44
import { format_data } from './state_handling'
55

@@ -15,8 +15,8 @@ const call_render_function = (args, instance_args, selection, element) =>
1515

1616
const execute_query = (query, data) =>
1717
(reject) => (resolve) =>
18-
jq(data, query)
19-
.then((data) => resolve(data))
18+
emuto(data, query)
19+
.then((result) => {console.log('data!!!', result); return resolve(result)}) // eslint-disable-line
2020
.catch((error) => {reject(error)})
2121

2222
const render_component_with_query = (args, instance_args, selection,

src/jq-web.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
const jq = async (...args) => {
3-
const jq_ = await import(/* webpackChunkName: "jq-web" */ 'jq-web')
4-
console.log(jq_) // eslint-disable-line
5-
return jq_.default(...args)
2+
const emuto = async (data, query) => {
3+
const emuto_ = await import(/* webpackChunkName: "emuto" */ 'emuto/lib/interpreter')
4+
console.log(emuto_) // eslint-disable-line
5+
return emuto_.default(query)(data)
66
}
77

8-
export default jq
8+
export default emuto

src/manual_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const render_dashboard = (data) => {
1313
render_dashboard(`
1414
dashboard "Cereals":
1515
- h1 text:
16-
- attr:query: '.[0].a'
16+
- attr:query: '$[0].a'
1717
- data: file:///foo/bar.csv
1818
- h2 text: "By calories"
1919
- dropdown my_var=~last:
@@ -23,10 +23,10 @@ dashboard "Cereals":
2323
- p text: "foo \${my_var} bar"
2424
- p text: "foo \${my_var} bar"
2525
- bar chart:
26-
- attr:query: '{"columns": [(sort_by(-(.calories | tonumber)) | .[] | [.name, .calories])]}'
26+
- attr:query: 'map ($ => [$.name, $.calories * 1]) | sortBy ($ => $[1] * -1) | { "columns": $ }'
2727
- data: https://gist.githubusercontent.com/ZeningQu/6184eaf8faa533e320abc938c4738c3e/raw/40f237de825061faa8721c2293b79c46979780b4/cereals.csv
2828
- h2 text: "By nutritional profile"
2929
- 4 columns:
30-
- attr:query: '.[] | {"component": "rows", "data": [{"component": "text", "args": {"tagName": "h3"}, "data": .name}, {"component": "chart", "args": {"type": "pie"}, "data": {"columns": [["protein", .protein], ["carbo", .carbo], ["sugars", .sugars], ["fat", .fat]]}}]}'
30+
- attr:query: 'map ($ => {"component": "rows", "data": [{"component": "text", "args": {"tagName": "h3"}, "data": .name}, {"component": "chart", "args": {"type": "pie"}, "data": {"columns": ["protein": .protein, "fat": .fat, "carbo": .carbo]}}]})'
3131
- data: https://gist.githubusercontent.com/ZeningQu/6184eaf8faa533e320abc938c4738c3e/raw/40f237de825061faa8721c2293b79c46979780b4/cereals.csv
3232
`)

yarn.lock

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,13 @@ cardinal@^2.1.1:
19291929
ansicolors "~0.3.2"
19301930
redeyed "~2.1.0"
19311931

1932+
cartesian-product-generator@^1.1.0:
1933+
version "1.1.0"
1934+
resolved "https://registry.yarnpkg.com/cartesian-product-generator/-/cartesian-product-generator-1.1.0.tgz#8bc32b44b7406eeadac5acfbeb42d6a1acfa433c"
1935+
integrity sha512-wKHdWUaIrqY4lgnmyCN5Oac0Xb1+Fvo6vUrsrEuRvpO/RTKrqFmZACDDNTctRBnuqnSNc/D0fsBuqYxi13ltOg==
1936+
dependencies:
1937+
ind2sub "^2.0.0"
1938+
19321939
caseless@~0.12.0:
19331940
version "0.12.0"
19341941
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
@@ -2200,6 +2207,11 @@ columnify@~1.5.4:
22002207
strip-ansi "^3.0.0"
22012208
wcwidth "^1.0.0"
22022209

2210+
combinations-generator@^1.0.1:
2211+
version "1.0.1"
2212+
resolved "https://registry.yarnpkg.com/combinations-generator/-/combinations-generator-1.0.1.tgz#f0cb4da0cbcb55cce3bbe18612d19323fb939d14"
2213+
integrity sha1-8MtNoMvLVczju+GGEtGTI/uTnRQ=
2214+
22032215
combined-stream@1.0.6, combined-stream@~1.0.5:
22042216
version "1.0.6"
22052217
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818"
@@ -3392,6 +3404,16 @@ emojis-list@^2.0.0:
33923404
version "2.1.0"
33933405
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
33943406

3407+
emuto@^1.37.0:
3408+
version "1.37.0"
3409+
resolved "https://registry.yarnpkg.com/emuto/-/emuto-1.37.0.tgz#9417439ea0b1db9701d61dbbb04339d05392feca"
3410+
integrity sha512-8J/L6OM2aA/THYcqnqrxMp6riAuJX4WkxYDvw1Joskr9H8KnCWdZKoyKY2N+zE0rY+oMUeWgCX052Lr1SXxu2A==
3411+
dependencies:
3412+
cartesian-product-generator "^1.1.0"
3413+
combinations-generator "^1.0.1"
3414+
flow "^0.2.3"
3415+
parsimmon "^1.12.0"
3416+
33953417
encodeurl@~1.0.2:
33963418
version "1.0.2"
33973419
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
@@ -4040,6 +4062,11 @@ flatted@^2.0.0:
40404062
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.0.tgz#55122b6536ea496b4b44893ee2608141d10d9916"
40414063
integrity sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==
40424064

4065+
flow@^0.2.3:
4066+
version "0.2.3"
4067+
resolved "https://registry.yarnpkg.com/flow/-/flow-0.2.3.tgz#f8da65efa249127ec99376a28896572a9795d1af"
4068+
integrity sha1-+Npl76JJEn7Jk3aiiJZXKpeV0a8=
4069+
40434070
flush-write-stream@^1.0.0:
40444071
version "1.0.3"
40454072
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.0.3.tgz#c5d586ef38af6097650b49bc41b55fabb19f35bd"
@@ -4883,6 +4910,11 @@ in-publish@^2.0.0:
48834910
version "2.0.0"
48844911
resolved "https://registry.yarnpkg.com/in-publish/-/in-publish-2.0.0.tgz#e20ff5e3a2afc2690320b6dc552682a9c7fadf51"
48854912

4913+
ind2sub@^2.0.0:
4914+
version "2.0.0"
4915+
resolved "https://registry.yarnpkg.com/ind2sub/-/ind2sub-2.0.0.tgz#323158a584fb4ed494ec600508b87af2fcd38219"
4916+
integrity sha512-xvb/V5SoBlJ36hYYzn5ZXGEPeGi6qDwFQu/luxa4eEoHYwlZFZChESsPl2cQVPE4kAsBHg5OQ5alEWtyktYXBg==
4917+
48864918
indent-string@^2.1.0:
48874919
version "2.1.0"
48884920
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80"
@@ -5315,10 +5347,6 @@ java-properties@^0.2.9:
53155347
version "0.2.10"
53165348
resolved "https://registry.yarnpkg.com/java-properties/-/java-properties-0.2.10.tgz#2551560c25fa1ad94d998218178f233ad9b18f60"
53175349

5318-
jq-web@^0.1.3:
5319-
version "0.1.5"
5320-
resolved "https://registry.yarnpkg.com/jq-web/-/jq-web-0.1.5.tgz#3de502424831b0117e443f0550c670bef83884e1"
5321-
53225350
js-base64@^2.1.8:
53235351
version "2.4.5"
53245352
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.5.tgz#e293cd3c7c82f070d700fc7a1ca0a2e69f101f92"
@@ -7361,6 +7389,11 @@ parseurl@~1.3.2:
73617389
version "1.3.2"
73627390
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"
73637391

7392+
parsimmon@^1.12.0:
7393+
version "1.12.0"
7394+
resolved "https://registry.yarnpkg.com/parsimmon/-/parsimmon-1.12.0.tgz#886a442fb30b5fc3c8e7c4994050f5cdcfe0ea90"
7395+
integrity sha512-uC/BjuSfb4jfaWajKCp1mVncXXq+V1twbcYChbTxN3GM7fn+8XoHwUdvUz+PTaFtDSCRQxU8+Rnh+iMhAkVwdw==
7396+
73647397
pascalcase@^0.1.1:
73657398
version "0.1.1"
73667399
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"

0 commit comments

Comments
 (0)