Skip to content

Commit 565a681

Browse files
committed
prettier
1 parent 8e9ecb2 commit 565a681

32 files changed

+538
-550
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
BasedOnStyle: Google
2-
ColumnLimit: 0
2+
ColumnLimit: 0

.github/workflows/main.yml

+31-31
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ name: CI
66
# events but only for the master branch
77
on:
88
push:
9-
branches: [ master ]
9+
branches: [master]
1010
pull_request:
11-
branches: [ master ]
11+
branches: [master]
1212

1313
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1414
jobs:
@@ -18,47 +18,47 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
platform: [ ubuntu-latest, macos-latest ]
21+
platform: [ubuntu-latest, macos-latest]
2222

2323
# The type of runner that the job will run on
2424
runs-on: ${{matrix.platform}}
2525

2626
# Steps represent a sequence of tasks that will be executed as part of the job
2727
steps:
28-
- name: Setup Node.js environment
29-
uses: actions/setup-node@v1
30-
with:
31-
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0
32-
node-version: 12.x
28+
- name: Setup Node.js environment
29+
uses: actions/setup-node@v1
30+
with:
31+
# Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0
32+
node-version: 12.x
3333

34-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35-
- uses: actions/checkout@v2
34+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35+
- uses: actions/checkout@v2
3636

37-
- name: Cache dependencies
38-
uses: actions/cache@v2
39-
with:
40-
path: "**/.yarn/cache"
41-
key: ${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
37+
- name: Cache dependencies
38+
uses: actions/cache@v2
39+
with:
40+
path: "**/.yarn/cache"
41+
key: ${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
4242

43-
- name: Install dependencies
44-
run: yarn install --immutable
45-
env:
46-
YARN_ENABLE_SCRIPTS: 0
43+
- name: Install dependencies
44+
run: yarn install --immutable
45+
env:
46+
YARN_ENABLE_SCRIPTS: 0
4747

48-
- name: Test debug
49-
run: make clean && yarn test
48+
- name: Test debug
49+
run: make clean && yarn test
5050

51-
- name: Prettier
52-
run: yarn run prettier-check
51+
- name: Prettier
52+
run: yarn run prettier-check
5353

54-
- name: Build release
55-
run: yarn make-release && yarn build && yarn tarball
54+
- name: Build release
55+
run: yarn make-release && yarn build && yarn tarball
5656

57-
- name: Test release
58-
run: yarn run mocha
57+
- name: Test release
58+
run: yarn run mocha
5959

60-
- name: Test release with NodeJS/Typescript example
61-
run: yarn smoketest-node
60+
- name: Test release with NodeJS/Typescript example
61+
run: yarn smoketest-node
6262

63-
- name: Test release with create-react-app/Typescript example
64-
run: yarn smoketest-cra
63+
- name: Test release with create-react-app/Typescript example
64+
run: yarn smoketest-cra

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ ts/ffi.ts
22
ts/ffi-asyncify.ts
33
*.emscripten-module.js
44
dist/*
5+
quickjs
6+
.yarn
7+
doc
8+
test/json-generator-dot-com-1024-rows.json

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"tabWidth": 2,
33
"useTabs": false,
44
"printWidth": 100,
5+
"singleQuote": false,
56
"semi": false
67
}

.vscode/c_cpp_properties.json

+16-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
{
2-
"configurations": [
3-
{
4-
"name": "Mac",
5-
"includePath": [
6-
"${workspaceFolder}/**"
7-
],
8-
"defines": [
9-
"QTS_ASYNCIFY=1",
10-
"QTS_DEBUG=1"
11-
],
12-
"macFrameworkPath": [
13-
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
14-
],
15-
"compilerPath": "/usr/bin/clang",
16-
"cStandard": "c17",
17-
"cppStandard": "c++98",
18-
"intelliSenseMode": "macos-clang-arm64"
19-
}
20-
],
21-
"version": 4
22-
}
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": ["${workspaceFolder}/**"],
6+
"defines": ["QTS_ASYNCIFY=1", "QTS_DEBUG=1"],
7+
"macFrameworkPath": [
8+
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
9+
],
10+
"compilerPath": "/usr/bin/clang",
11+
"cStandard": "c17",
12+
"cppStandard": "c++98",
13+
"intelliSenseMode": "macos-clang-arm64"
14+
}
15+
],
16+
"version": 4
17+
}

.vscode/settings.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
2-
"cSpell.words": [
3-
"Asyncified",
4-
"ASYNCIFY"
5-
],
2+
"cSpell.words": ["Asyncified", "ASYNCIFY"],
63
"files.associations": {
74
"cutils.h": "c",
85
"quickjs.h": "c",
96
"quickjs-libc.h": "c",
107
"stdio.h": "c"
118
}
12-
}
9+
}

CHANGELOG.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ runtime limits, memory limits, and pending jobs moved to `QuickJSRuntime`.
5656

5757
1. Replace usages with QuickJSContext.
5858
2. Replace the following methods:
59-
- `vm.hasPendingJob` -> `context.runtime.hasPendingJob`
60-
- `vm.setInterruptHandler` -> `context.runtime.setInterruptHandler`
61-
- `vm.removeInterruptHandler` -> `context.runtime.removeInterruptHandler`
62-
- `vm.executePendingJobs` -> `context.runtime.executePendingJobs`
63-
- `vm.setMemoryLimit` -> `context.runtime.setMemoryLimit`
64-
- `vm.computeMemoryUsage` -> `context.runtime.computeMemoryUsage`
59+
- `vm.hasPendingJob` -> `context.runtime.hasPendingJob`
60+
- `vm.setInterruptHandler` -> `context.runtime.setInterruptHandler`
61+
- `vm.removeInterruptHandler` -> `context.runtime.removeInterruptHandler`
62+
- `vm.executePendingJobs` -> `context.runtime.executePendingJobs`
63+
- `vm.setMemoryLimit` -> `context.runtime.setMemoryLimit`
64+
- `vm.computeMemoryUsage` -> `context.runtime.computeMemoryUsage`
6565

6666
**`QuickJS.createVm()` is removed.**
6767

README.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ C by Fabrice Bellard](https://bellard.org/quickjs/) compiled to WebAssembly.
88
- Expose host functions to the QuickJS runtime.
99

1010
```typescript
11-
import { getQuickJS } from 'quickjs-emscripten'
11+
import { getQuickJS } from "quickjs-emscripten"
1212

1313
async function main() {
1414
const QuickJS = await getQuickJS()
1515
const vm = QuickJS.createVm()
1616

17-
const world = vm.newString('world')
18-
vm.setProp(vm.global, 'NAME', world)
17+
const world = vm.newString("world")
18+
vm.setProp(vm.global, "NAME", world)
1919
world.dispose()
2020

2121
const result = vm.evalCode(`"Hello " + NAME + "!"`)
2222
if (result.error) {
23-
console.log('Execution failed:', vm.dump(result.error))
23+
console.log("Execution failed:", vm.dump(result.error))
2424
result.error.dispose()
2525
} else {
26-
console.log('Success:', vm.dump(result.value))
26+
console.log("Success:", vm.dump(result.value))
2727
result.value.dispose()
2828
}
2929

@@ -49,10 +49,10 @@ function to directly access the singleton engine in your synchronous code.
4949
See [QuickJS.evalCode](https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/quickjs.md#evalcode)
5050

5151
```typescript
52-
import { getQuickJS, shouldInterruptAfterDeadline } from 'quickjs-emscripten'
52+
import { getQuickJS, shouldInterruptAfterDeadline } from "quickjs-emscripten"
5353

54-
getQuickJS().then(QuickJS => {
55-
const result = QuickJS.evalCode('1 + 1', {
54+
getQuickJS().then((QuickJS) => {
55+
const result = QuickJS.evalCode("1 + 1", {
5656
shouldInterrupt: shouldInterruptAfterDeadline(Date.now() + 1000),
5757
memoryLimitBytes: 1024 * 1024,
5858
})
@@ -73,15 +73,15 @@ limit. See the documentation for details.
7373
const vm = QuickJS.createVm()
7474
let state = 0
7575

76-
const fnHandle = vm.newFunction('nextId', () => {
76+
const fnHandle = vm.newFunction("nextId", () => {
7777
return vm.newNumber(++state)
7878
})
7979

80-
vm.setProp(vm.global, 'nextId', fnHandle)
80+
vm.setProp(vm.global, "nextId", fnHandle)
8181
fnHandle.dispose()
8282

8383
const nextId = vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`))
84-
console.log('vm result:', vm.getNumber(nextId), 'native state:', state)
84+
console.log("vm result:", vm.getNumber(nextId), "native state:", state)
8585

8686
nextId.dispose()
8787
vm.dispose()
@@ -121,20 +121,20 @@ method in the reverse order in which they're added to the scope. Here's the
121121
"Interfacing with the interpreter" example re-written using `Scope`:
122122

123123
```typescript
124-
Scope.withScope(scope => {
124+
Scope.withScope((scope) => {
125125
const vm = scope.manage(QuickJS.createVm())
126126
let state = 0
127127

128128
const fnHandle = scope.manage(
129-
vm.newFunction('nextId', () => {
129+
vm.newFunction("nextId", () => {
130130
return vm.newNumber(++state)
131131
})
132132
)
133133

134-
vm.setProp(vm.global, 'nextId', fnHandle)
134+
vm.setProp(vm.global, "nextId", fnHandle)
135135

136136
const nextId = scope.manage(vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)))
137-
console.log('vm result:', vm.getNumber(nextId), 'native state:', state)
137+
console.log("vm result:", vm.getNumber(nextId), "native state:", state)
138138

139139
// When the withScope block exits, it calls scope.dispose(), which in turn calls
140140
// the .dispose() methods of all the disposables managed by the scope.
@@ -158,12 +158,12 @@ Here's the "Interfacing with interpreter" example re-written using `.consume()`:
158158
const vm = QuickJS.createVm()
159159
let state = 0
160160

161-
vm.newFunction('nextId', () => {
161+
vm.newFunction("nextId", () => {
162162
return vm.newNumber(++state)
163-
}).consume(fnHandle => vm.setProp(vm.global, 'nextId', fnHandle))
163+
}).consume((fnHandle) => vm.setProp(vm.global, "nextId", fnHandle))
164164

165-
vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)).consume(nextId =>
166-
console.log('vm result:', vm.getNumber(nextId), 'native state:', state)
165+
vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)).consume((nextId) =>
166+
console.log("vm result:", vm.getNumber(nextId), "native state:", state)
167167
)
168168

169169
vm.dispose()
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { getQuickJS } from 'quickjs-emscripten'
1+
import { getQuickJS } from "quickjs-emscripten"
22
async function main() {
33
const QuickJS = await getQuickJS()
44
console.log(QuickJS.evalCode('"QuickJS.evalCode successful"'))
55

66
const vm = QuickJS.createContext()
77
const memoryUsage = vm.runtime.dumpMemoryUsage()
8-
console.log('Empty VM memory usage:', memoryUsage)
8+
console.log("Empty VM memory usage:", memoryUsage)
99
}
1010
main()

examples/website/public/index.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
8+
<meta name="description" content="Web site created using create-react-app" />
129
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
1310
<!--
1411
manifest.json provides metadata used when your web app is installed on a

examples/website/src/App.test.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from 'react'
2-
import { render } from '@testing-library/react'
3-
import App from './App'
1+
import React from "react"
2+
import { render } from "@testing-library/react"
3+
import App from "./App"
44

5-
test('renders something', () => {
5+
test("renders something", () => {
66
const { getByText } = render(<App />)
77
const linkElement = getByText(/QuickJS/)
88
expect(linkElement).toBeInTheDocument()

examples/website/src/App.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useEffect } from 'react'
2-
import './App.css'
3-
import { getQuickJS } from 'quickjs-emscripten'
1+
import React, { useEffect } from "react"
2+
import "./App.css"
3+
import { getQuickJS } from "quickjs-emscripten"
44

55
function stringify(val: unknown) {
6-
if (typeof val === 'undefined') {
7-
return 'undefined'
6+
if (typeof val === "undefined") {
7+
return "undefined"
88
}
99

1010
return JSON.stringify(val, undefined, 2)
@@ -22,10 +22,10 @@ function App() {
2222
const QuickJS = await getQuickJS()
2323
try {
2424
const result = QuickJS.evalCode(js)
25-
console.log('eval result:', result)
25+
console.log("eval result:", result)
2626
setEvalResult(result)
2727
} catch (err) {
28-
console.log('eval error:', err)
28+
console.log("eval error:", err)
2929
setEvalResult(err)
3030
}
3131
}, [js, setEvalResult])
@@ -46,16 +46,16 @@ function App() {
4646
<li>Expose host functions to the QuickJS runtime.</li>
4747
</ul>
4848
<p>
49-
<a href="https://github.com/justjake/quickjs-emscripten">Github</a> -{' '}
49+
<a href="https://github.com/justjake/quickjs-emscripten">Github</a> -{" "}
5050
<a href="https://github.com/justjake/quickjs-emscripten/blob/master/doc/globals.md">
5151
Documentation
52-
</a>{' '}
52+
</a>{" "}
5353
- <a href="https://www.npmjs.com/package/quickjs-emscripten">NPM</a>
5454
</p>
5555
<h2>Eval JS code safely</h2>
5656
<label htmlFor="js">This code is evaluated in a QuickJS virtual machine:</label>
5757
<div>
58-
<textarea id="js" value={js} onChange={e => setJs(e.target.value)} />
58+
<textarea id="js" value={js} onChange={(e) => setJs(e.target.value)} />
5959
</div>
6060
<h3>Eval result:</h3>
6161
<pre>{stringify(evalResult)}</pre>

examples/website/src/index.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
body {
22
margin: 0;
3-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
4-
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
3+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
4+
"Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
55
-webkit-font-smoothing: antialiased;
66
-moz-osx-font-smoothing: grayscale;
77
}

0 commit comments

Comments
 (0)