Skip to content

Commit 604db27

Browse files
jimmywartingzbjornson
authored andcommitted
Run standard --fix
1 parent 324134b commit 604db27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2276
-2279
lines changed

benchmarks/run.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* milliseconds to complete.
55
*/
66

7-
var createCanvas = require('../').createCanvas
8-
var canvas = createCanvas(200, 200)
9-
var largeCanvas = createCanvas(1000, 1000)
10-
var ctx = canvas.getContext('2d')
7+
const { createCanvas } = require('../')
8+
const canvas = createCanvas(200, 200)
9+
const largeCanvas = createCanvas(1000, 1000)
10+
const ctx = canvas.getContext('2d')
1111

12-
var initialTimes = 10
13-
var minDurationMs = 2000
12+
const initialTimes = 10
13+
const minDurationMs = 2000
1414

15-
var queue = []
16-
var running = false
15+
const queue = []
16+
let running = false
1717

1818
function bm (label, fn) {
1919
queue.push({ label: label, fn: fn })
@@ -28,11 +28,11 @@ function next () {
2828

2929
function run (benchmark, n, start) {
3030
running = true
31-
var originalN = n
32-
var fn = benchmark.fn
31+
const originalN = n
32+
const fn = benchmark.fn
3333

3434
if (fn.length) { // async
35-
var pending = n
35+
let pending = n
3636

3737
while (n--) {
3838
fn(function () {
@@ -46,12 +46,12 @@ function run (benchmark, n, start) {
4646
}
4747

4848
function done (benchmark, times, start, isAsync) {
49-
var duration = Date.now() - start
49+
const duration = Date.now() - start
5050

5151
if (duration < minDurationMs) {
5252
run(benchmark, times * 2, Date.now())
5353
} else {
54-
var opsSec = times / duration * 1000
54+
const opsSec = times / duration * 1000
5555
if (isAsync) {
5656
console.log(' - \x1b[33m%s\x1b[0m %s ops/sec (%s times, async)', benchmark.label, opsSec.toLocaleString(), times)
5757
} else {
@@ -97,7 +97,7 @@ bm('strokeRect()', function () {
9797
})
9898

9999
bm('linear gradients', function () {
100-
var lingrad = ctx.createLinearGradient(0, 50, 0, 95)
100+
const lingrad = ctx.createLinearGradient(0, 50, 0, 95)
101101
lingrad.addColorStop(0.5, '#000')
102102
lingrad.addColorStop(1, 'rgba(0,0,0,0)')
103103
ctx.fillStyle = lingrad
@@ -157,7 +157,7 @@ bm('getImageData(0,0,100,100)', function () {
157157
})
158158

159159
bm('PNGStream 200x200', function (done) {
160-
var stream = canvas.createPNGStream()
160+
const stream = canvas.createPNGStream()
161161
stream.on('data', function (chunk) {
162162
// whatever
163163
})

examples/backends.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
var fs = require('fs')
2-
var resolve = require('path').resolve
1+
const fs = require('fs')
2+
const { resolve } = require('path')
33

4-
var Canvas = require('..')
4+
const Canvas = require('..')
55

6-
var imagebackend = new Canvas.backends.ImageBackend(800, 600)
6+
const imagebackend = new Canvas.backends.ImageBackend(800, 600)
77

8-
var canvas = new Canvas.Canvas(imagebackend)
9-
var ctx = canvas.getContext('2d')
8+
const canvas = new Canvas.Canvas(imagebackend)
9+
const ctx = canvas.getContext('2d')
1010

1111
console.log('Width: ' + canvas.width + ', Height: ' + canvas.height)
1212

1313
ctx.fillStyle = '#00FF00'
1414
ctx.fillRect(50, 50, 100, 100)
1515

16-
var outPath = resolve(__dirname, 'rectangle.png')
16+
const outPath = resolve(__dirname, 'rectangle.png')
1717

1818
canvas.createPNGStream().pipe(fs.createWriteStream(outPath))

examples/clock.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('..')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('..')
44

55
function getX (angle) {
66
return -Math.sin(angle + Math.PI)
@@ -11,8 +11,8 @@ function getY (angle) {
1111
}
1212

1313
function clock (ctx) {
14-
var x, y, i
15-
var now = new Date()
14+
let x, y, i
15+
const now = new Date()
1616

1717
ctx.clearRect(0, 0, 320, 320)
1818

@@ -53,9 +53,9 @@ function clock (ctx) {
5353
}
5454
}
5555

56-
var sec = now.getSeconds()
57-
var min = now.getMinutes()
58-
var hr = now.getHours() % 12
56+
const sec = now.getSeconds()
57+
const min = now.getMinutes()
58+
const hr = now.getHours() % 12
5959

6060
ctx.fillStyle = 'black'
6161

@@ -104,8 +104,8 @@ function clock (ctx) {
104104
module.exports = clock
105105

106106
if (require.main === module) {
107-
var canvas = Canvas.createCanvas(320, 320)
108-
var ctx = canvas.getContext('2d')
107+
const canvas = Canvas.createCanvas(320, 320)
108+
const ctx = canvas.getContext('2d')
109109

110110
clock(ctx)
111111

examples/crop.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('canvas')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('canvas')
44

5-
var img = new Canvas.Image()
5+
const img = new Canvas.Image()
66

77
img.onerror = function (err) {
88
throw err
99
}
1010

1111
img.onload = function () {
12-
var w = img.width / 2
13-
var h = img.height / 2
14-
var canvas = Canvas.createCanvas(w, h)
15-
var ctx = canvas.getContext('2d')
12+
const w = img.width / 2
13+
const h = img.height / 2
14+
const canvas = Canvas.createCanvas(w, h)
15+
const ctx = canvas.getContext('2d')
1616

1717
ctx.drawImage(img, 0, 0, w, h, 0, 0, w, h)
1818

19-
var out = fs.createWriteStream(path.join(__dirname, 'crop.jpg'))
20-
var stream = canvas.createJPEGStream({
19+
const out = fs.createWriteStream(path.join(__dirname, 'crop.jpg'))
20+
const stream = canvas.createJPEGStream({
2121
bufsize: 2048,
2222
quality: 80
2323
})

examples/fill-evenodd.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('..')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('..')
44

5-
var canvas = Canvas.createCanvas(100, 100)
6-
var ctx = canvas.getContext('2d')
5+
const canvas = Canvas.createCanvas(100, 100)
6+
const ctx = canvas.getContext('2d')
77

88
ctx.fillStyle = '#f00'
99
ctx.rect(0, 0, 100, 50)

examples/font.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('..')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('..')
44

55
function fontFile (name) {
66
return path.join(__dirname, '/pfennigFont/', name)
@@ -15,8 +15,8 @@ Canvas.registerFont(fontFile('PfennigBold.ttf'), { family: 'pfennigFont', weight
1515
Canvas.registerFont(fontFile('PfennigItalic.ttf'), { family: 'pfennigFont', style: 'italic' })
1616
Canvas.registerFont(fontFile('PfennigBoldItalic.ttf'), { family: 'pfennigFont', weight: 'bold', style: 'italic' })
1717

18-
var canvas = Canvas.createCanvas(320, 320)
19-
var ctx = canvas.getContext('2d')
18+
const canvas = Canvas.createCanvas(320, 320)
19+
const ctx = canvas.getContext('2d')
2020

2121
ctx.font = 'normal normal 50px Helvetica'
2222

examples/globalAlpha.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('..')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('..')
44

5-
var canvas = Canvas.createCanvas(150, 150)
6-
var ctx = canvas.getContext('2d')
5+
const canvas = Canvas.createCanvas(150, 150)
6+
const ctx = canvas.getContext('2d')
77

88
ctx.fillStyle = '#FD0'
99
ctx.fillRect(0, 0, 75, 75)
@@ -23,7 +23,7 @@ ctx.fillStyle = '#FFF'
2323
ctx.globalAlpha = 0.2
2424

2525
// Draw semi transparent circles
26-
for (var i = 0; i < 7; i++) {
26+
for (let i = 0; i < 7; i++) {
2727
ctx.beginPath()
2828
ctx.arc(75, 75, 10 + 10 * i, 0, Math.PI * 2, true)
2929
ctx.fill()

examples/gradients.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('..')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('..')
44

5-
var canvas = Canvas.createCanvas(320, 320)
6-
var ctx = canvas.getContext('2d')
5+
const canvas = Canvas.createCanvas(320, 320)
6+
const ctx = canvas.getContext('2d')
77

88
// Create gradients
9-
var lingrad = ctx.createLinearGradient(0, 0, 0, 150)
9+
const lingrad = ctx.createLinearGradient(0, 0, 0, 150)
1010
lingrad.addColorStop(0, '#00ABEB')
1111
lingrad.addColorStop(0.5, '#fff')
1212
lingrad.addColorStop(0.5, '#26C000')
1313
lingrad.addColorStop(1, '#fff')
1414

15-
var lingrad2 = ctx.createLinearGradient(0, 50, 0, 95)
15+
const lingrad2 = ctx.createLinearGradient(0, 50, 0, 95)
1616
lingrad2.addColorStop(0.5, '#000')
1717
lingrad2.addColorStop(1, 'rgba(0,0,0,0)')
1818

examples/image-src-svg.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var fs = require('fs')
2-
var path = require('path')
3-
var Canvas = require('..')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Canvas = require('..')
44

5-
var canvas = Canvas.createCanvas(500, 500)
6-
var ctx = canvas.getContext('2d')
5+
const canvas = Canvas.createCanvas(500, 500)
6+
const ctx = canvas.getContext('2d')
77
ctx.fillStyle = 'white'
88
ctx.fillRect(0, 0, 500, 500)
99

examples/indexed-png-alpha.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var Canvas = require('..')
2-
var fs = require('fs')
3-
var path = require('path')
4-
var canvas = Canvas.createCanvas(200, 200)
5-
var ctx = canvas.getContext('2d', { pixelFormat: 'A8' })
1+
const Canvas = require('..')
2+
const fs = require('fs')
3+
const path = require('path')
4+
const canvas = Canvas.createCanvas(200, 200)
5+
const ctx = canvas.getContext('2d', { pixelFormat: 'A8' })
66

77
// Matches the "fillStyle" browser test, made by using alpha fillStyle value
8-
var palette = new Uint8ClampedArray(37 * 4)
9-
var i, j
10-
var k = 0
8+
const palette = new Uint8ClampedArray(37 * 4)
9+
let i, j
10+
let k = 0
1111
// First value is opaque white:
1212
palette[k++] = 255
1313
palette[k++] = 255
@@ -23,8 +23,8 @@ for (i = 0; i < 6; i++) {
2323
}
2424
for (i = 0; i < 6; i++) {
2525
for (j = 0; j < 6; j++) {
26-
var index = i * 6 + j + 1.5 // 0.5 to bias rounding
27-
var fraction = index / 255
26+
const index = i * 6 + j + 1.5 // 0.5 to bias rounding
27+
const fraction = index / 255
2828
ctx.fillStyle = 'rgba(0,0,0,' + fraction + ')'
2929
ctx.fillRect(j * 25, i * 25, 25, 25)
3030
}

examples/indexed-png-image-data.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var Canvas = require('..')
2-
var fs = require('fs')
3-
var path = require('path')
4-
var canvas = Canvas.createCanvas(200, 200)
5-
var ctx = canvas.getContext('2d', { pixelFormat: 'A8' })
1+
const Canvas = require('..')
2+
const fs = require('fs')
3+
const path = require('path')
4+
const canvas = Canvas.createCanvas(200, 200)
5+
const ctx = canvas.getContext('2d', { pixelFormat: 'A8' })
66

77
// Matches the "fillStyle" browser test, made by manipulating imageData
8-
var palette = new Uint8ClampedArray(37 * 4)
9-
var k = 0
10-
var i, j
8+
const palette = new Uint8ClampedArray(37 * 4)
9+
let k = 0
10+
let i, j
1111
// First value is opaque white:
1212
palette[k++] = 255
1313
palette[k++] = 255
@@ -21,13 +21,13 @@ for (i = 0; i < 6; i++) {
2121
palette[k++] = 255
2222
}
2323
}
24-
var idata = ctx.getImageData(0, 0, 200, 200)
24+
const idata = ctx.getImageData(0, 0, 200, 200)
2525
for (i = 0; i < 6; i++) {
2626
for (j = 0; j < 6; j++) {
27-
var index = j * 6 + i
27+
const index = j * 6 + i
2828
// fill rect:
29-
for (var xr = j * 25; xr < j * 25 + 25; xr++) {
30-
for (var yr = i * 25; yr < i * 25 + 25; yr++) {
29+
for (let xr = j * 25; xr < j * 25 + 25; xr++) {
30+
for (let yr = i * 25; yr < i * 25 + 25; yr++) {
3131
idata.data[xr * 200 + yr] = index + 1
3232
}
3333
}

0 commit comments

Comments
 (0)