Skip to content

Commit 2f9a528

Browse files
committed
docs(all): changes from lint
1 parent c3f4133 commit 2f9a528

File tree

19 files changed

+204
-207
lines changed

19 files changed

+204
-207
lines changed

jsdoc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"packages/modeling/src/operations/offsets",
2929
"packages/modeling/src/operations/extrusions",
3030
"packages/modeling/src/operations/hulls",
31+
"packages/modeling/src/operations/minkowski",
3132
"packages/modeling/src/operations/modifiers",
3233
"packages/modeling/src/operations/transforms",
3334
"packages/modeling/src/primitives",

packages/io/dxf-deserializer/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ const deserialize = (options, src) => {
596596
}
597597
options = Object.assign({}, defaults, options)
598598

599-
src = ensureString(src);
599+
src = ensureString(src)
600600
return options.output === 'script' ? translate(src, options) : instantiate(src, options)
601601
}
602602

packages/io/dxf-deserializer/tests/test-2d-entities.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ test('ASCII DXF 2D Donuts from Autocad 2017 to Object Conversion', (t) => {
110110
t.is(objs.length, 23)
111111
// NOTE: the extra ojbects are from the page layout
112112
t.true(path2.isA(objs[20]))
113-
t.is(path2.toPoints(objs[20]).length, 18) // line
113+
t.is(path2.toPoints(objs[20]).length, 16) // line
114114
t.true(path2.isA(objs[21]))
115-
t.is(path2.toPoints(objs[21]).length, 18) // line
115+
t.is(path2.toPoints(objs[21]).length, 16) // line
116116
t.true(path2.isA(objs[22]))
117-
t.is(path2.toPoints(objs[22]).length, 18) // arc
117+
t.is(path2.toPoints(objs[22]).length, 16) // arc
118118
})
119119

120120
test('ASCII DXF 2D Ellipses from Autocad 2017 to Object Conversion', (t) => {

packages/io/dxf-serializer/tests/path2ToDxf.test.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava'
22

3-
import { arc, path2 } from '@jscad/modeling'
3+
import { arc, path2, TAU } from '@jscad/modeling'
44

55
import { serialize } from '../src/index.js'
66
import { dxfHeaders, dxfClasses, dxfTables, dxfBlocks, dxfObjects } from '../src/autocad_AC2017.js'
@@ -12,7 +12,7 @@ test('2D Path to DXF LWPOLYLINE', (t) => {
1212
const exp1 = [empty]
1313
t.deepEqual(obs1, exp1)
1414

15-
const p2 = arc({ center: [5, 5], endAngle: 45, segments: 16 })
15+
const p2 = arc({ center: [5, 5], endAngle: TAU / 4, segments: 16 })
1616

1717
const obs2 = serialize({}, p2)
1818
const exp2 = [lwpolyline0]
@@ -74,25 +74,29 @@ CAD00001
7474
100
7575
AcDbPolyline
7676
90
77-
4
77+
5
7878
70
7979
0
8080
10
8181
6
8282
20
8383
5
8484
10
85-
5.943009745777588
85+
5.923879532511287
8686
20
87-
5.33276511140516
87+
5.38268343236509
8888
10
89-
5.778534761263023
89+
5.707106781186548
9090
20
91-
5.627601486219662
91+
5.707106781186548
9292
10
93-
5.525321988817728
93+
5.38268343236509
9494
20
95-
5.850903524534119
95+
5.923879532511287
96+
10
97+
5
98+
20
99+
6
96100
0
97101
ENDSEC
98102
${dxfObjects({})}

packages/io/io-utils/src/ensureString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
export const ensureString = (stringOrArrayBuffer, defaultBinaryEncoding = 'utf-8') => {
77
if (typeof (stringOrArrayBuffer) === 'string') {
8-
return stringOrArrayBuffer;
8+
return stringOrArrayBuffer
99
}
1010

11-
return new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer));
11+
return new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer))
1212
}

packages/io/json-deserializer/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const deserialize = (options, input) => {
3939
options = Object.assign({}, defaults, options)
4040

4141
// convert the JSON notation into anonymous object(s)
42-
input = ensureString(input);
42+
input = ensureString(input)
4343
let objects = JSON.parse(input)
4444

4545
// cleanup the objects

packages/io/json-serializer/tests/path2ToJson.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ test('2D Path to JSON', (t) => {
1919
const obs1 = serialize({}, path1)
2020
t.is(countOf('points', obs1[0]), 1)
2121
t.is(countOf('transforms', obs1[0]), 1)
22-
t.is(countOf('[', obs1[0]), 7)
23-
t.is(countOf(']', obs1[0]), 7)
24-
t.is(countOf(',', obs1[0]), 24)
22+
t.is(countOf('[', obs1[0]), 6)
23+
t.is(countOf(']', obs1[0]), 6)
24+
t.is(countOf(',', obs1[0]), 22)
2525

2626
const path2 = arc({ segments: 72 })
2727
const obs2 = serialize({}, path2)
2828
t.is(countOf('points', obs2[0]), 1)
2929
t.is(countOf('transforms', obs2[0]), 1)
30-
t.is(countOf('[', obs2[0]), 76)
31-
t.is(countOf(']', obs2[0]), 76)
32-
t.is(countOf(',', obs2[0]), 162)
30+
t.is(countOf('[', obs2[0]), 75)
31+
t.is(countOf(']', obs2[0]), 75)
32+
t.is(countOf(',', obs2[0]), 160)
3333

3434
const obs3 = serialize({}, [path1, path2])
3535
t.is(countOf('points', obs3[0]), 2)
3636
t.is(countOf('transforms', obs3[0]), 2)
37-
t.is(countOf('[', obs3[0]), 82)
38-
t.is(countOf(']', obs3[0]), 82)
39-
t.is(countOf(',', obs3[0]), 187)
37+
t.is(countOf('[', obs3[0]), 80)
38+
t.is(countOf(']', obs3[0]), 80)
39+
t.is(countOf(',', obs3[0]), 183)
4040
})

packages/io/svg-deserializer/tests/instantiate.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,21 +246,21 @@ test('deserialize : instantiate svg (path: arc) to objects', (t) => {
246246
t.is(observed.length, 2)
247247
let shape = observed[0]
248248
t.is(shape.outlines.length, 1)
249-
t.is(shape.outlines[0].length, 27)
249+
t.is(shape.outlines[0].length, 26)
250250

251251
observed = deserialize({ output: 'geometry', target: 'path', addMetaData: false }, sourceSvg)
252252
t.is(observed.length, 2)
253253
shape = observed[0]
254-
t.is(shape.points.length, 27)
254+
t.is(shape.points.length, 26)
255255

256256
observed = deserialize({ output: 'geometry', target: 'path', addMetaData: false, segments: 16 }, sourceSvg)
257257
t.is(observed.length, 2)
258258
shape = observed[0]
259-
t.is(shape.points.length, 15) // segments double on a 3/4 circle
260-
t.deepEqual(measureBoundingBox(shape), [[64.91110599999999, -77.611105, 0], [90.21850570104527, -52.30370029895471, 0]])
259+
t.is(shape.points.length, 14) // segments double on a 3/4 circle
260+
t.deepEqual(measureBoundingBox(shape), [[64.91110599999999, -77.611105, 0], [90.31110299999999, -52.211102999999994, 0]])
261261
shape = observed[1]
262-
t.is(shape.points.length, 15) // segments double on a 3/4 circle
263-
t.deepEqual(measureBoundingBox(shape), [[50.799996, -136.03302387090216, 0], [72.27222493929787, -110.6793647936299, 0]])
262+
t.is(shape.points.length, 14) // segments double on a 3/4 circle
263+
t.deepEqual(measureBoundingBox(shape), [[50.799996, -136.05619433226602, 0], [72.48025212106914, -110.65619433226604, 0]])
264264
})
265265

266266
// ################################
@@ -443,15 +443,15 @@ test('deserialize : instantiate shape with a hole to objects', (t) => {
443443
t.is(observed.length, 1)
444444
let shape = observed[0]
445445
t.is(shape.outlines.length, 2)
446-
t.is(shape.outlines[0].length, 38)
447-
t.is(shape.outlines[1].length, 38)
446+
t.is(shape.outlines[0].length, 30)
447+
t.is(shape.outlines[1].length, 30)
448448

449449
observed = deserialize({ output: 'geometry', target: 'path', addMetaData: false }, sourceSvg)
450450
t.is(observed.length, 2)
451451
shape = observed[0]
452-
t.is(shape.points.length, 38)
452+
t.is(shape.points.length, 30)
453453
shape = observed[1]
454-
t.is(shape.points.length, 38)
454+
t.is(shape.points.length, 30)
455455
})
456456

457457
// ################################
@@ -467,12 +467,12 @@ test('deserialize : instantiate shape with a nested hole to objects', (t) => {
467467
t.is(observed.length, 1)
468468
let shape = observed[0]
469469
t.is(shape.outlines.length, 4)
470-
t.is(shape.outlines[0].length, 38)
470+
t.is(shape.outlines[0].length, 30)
471471

472472
observed = deserialize({ output: 'geometry', target: 'path', addMetaData: false }, sourceSvg)
473473
t.is(observed.length, 4)
474474
shape = observed[0]
475-
t.is(shape.points.length, 38)
475+
t.is(shape.points.length, 30)
476476
})
477477

478478
// ################################

packages/modeling/src/geometries/path2/appendArc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const appendArc = (options, geometry) => {
120120
}
121121

122122
// Ok, we have the center point and angle range (from theta1, deltatheta radians) so we can create the ellipse
123-
let numSteps = Math.ceil(Math.abs(deltatheta) / TAU * segments) + 1
123+
let numSteps = Math.floor(segments * (Math.abs(deltatheta) / TAU))
124124
if (numSteps < 1) numSteps = 1
125125
for (let step = 1; step < numSteps; step++) {
126126
const theta = theta1 + step / numSteps * deltatheta

packages/modeling/src/geometries/path2/appendArc.test.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,43 @@ test('appendArc: appending to a path produces a new path', (t) => {
2323
const p2 = fromPoints({}, [[27, -22], [27, -3]])
2424
obs = appendArc({ endpoint: [12, -22], radius: [15, -20] }, p2)
2525
pts = toPoints(obs)
26-
t.is(pts.length, 7)
26+
t.is(pts.length, 5)
2727

2828
// test segments
2929
obs = appendArc({ endpoint: [12, -22], radius: [15, -20], segments: 64 }, p2)
3030
pts = toPoints(obs)
31-
t.is(pts.length, 19)
31+
t.is(pts.length, 17)
3232

3333
// test clockwise
3434
obs = appendArc({ endpoint: [12, -22], radius: [15, -20], clockwise: true }, p2)
3535
pts = toPoints(obs)
3636
let exp = [
3737
[27, -22],
3838
[27, -3],
39-
[26.086451657912605, -8.941047736250177],
40-
[23.87938869625451, -14.243872270248309],
41-
[20.58174906029909, -18.420882475791835],
42-
[16.49674848226545, -21.0880050920699],
43-
[11.999999999999998, -22]
39+
[24.7485593841743, -12.579008396887021],
40+
[19.29019838402471, -19.492932330409836],
41+
[12, -22]
4442
]
45-
t.is(pts.length, 7)
43+
t.is(pts.length, 5)
4644
t.true(comparePoints(pts, exp))
4745

4846
// test large
4947
obs = appendArc({ endpoint: [12, -22], radius: [15, -20], large: true }, p2)
5048
pts = toPoints(obs)
51-
t.is(pts.length, 16)
49+
t.is(pts.length, 14)
5250

5351
// test xaxisRotation
5452
obs = appendArc({ endpoint: [12, -22], radius: [15, -20], xaxisRotation: TAU / 4 }, p2)
5553
pts = toPoints(obs)
5654
exp = [
5755
[27, -22],
5856
[27, -3],
59-
[21.830323320631795, -4.401628923214028],
60-
[17.364704977487236, -6.805886946199115],
57+
[19.486852090983938, -5.488140907400943],
6158
[13.940501387124588, -10.031143708098092],
62-
[11.816394990371812, -13.833746263211978],
63-
[11.15285201325494, -17.926425912558045],
64-
[12, -22.000000000000004]
59+
[11.296247566821858, -15.862906638006239],
60+
[12, -22]
6561
]
66-
t.is(pts.length, 8)
62+
t.is(pts.length, 6)
6763
t.true(comparePoints(pts, exp))
6864

6965
// test small arc between far points

0 commit comments

Comments
 (0)