Skip to content

Commit 498ba0f

Browse files
committed
Add index getter
1 parent 94953c5 commit 498ba0f

12 files changed

+60
-57
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scrollsdk",
3-
"version": "87.1.0",
3+
"version": "88.0.0",
44
"description": "This npm package includes the Particles class, the Parsers compiler-compiler, a Parsers IDE, and more, all implemented in Particles, Parsers, and TypeScript.",
55
"types": "./built/scrollsdk.node.d.ts",
66
"main": "./products/Particle.js",

particle/Particle.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,8 +1741,8 @@ testParticles.getIndex = equal => {
17411741
const subparticle1 = particle.getParticle("r2")
17421742

17431743
// Act/Assert
1744-
equal(subparticle0.getIndex(), 0, "Has correct index")
1745-
equal(subparticle1.getIndex(), 1, "Has correct index")
1744+
equal(subparticle0.index, 0, "Has correct index")
1745+
equal(subparticle1.index, 1, "Has correct index")
17461746
}
17471747

17481748
testParticles.simpleParticleLanguage = equal => {

particle/Particle.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Particle extends AbstractParticle {
171171

172172
getOlderSiblings() {
173173
if (this.isRoot()) return []
174-
return this.parent.slice(0, this.getIndex())
174+
return this.parent.slice(0, this.index)
175175
}
176176

177177
protected _getClosestOlderSibling(): Particle | undefined {
@@ -181,7 +181,7 @@ class Particle extends AbstractParticle {
181181

182182
getYoungerSiblings() {
183183
if (this.isRoot()) return []
184-
return this.parent.slice(this.getIndex() + 1)
184+
return this.parent.slice(this.index + 1)
185185
}
186186

187187
getSiblings() {
@@ -670,11 +670,11 @@ class Particle extends AbstractParticle {
670670
protected _getPathVector(relativeTo?: Particle): particlesTypes.pathVector {
671671
if (this.isRoot(relativeTo)) return []
672672
const path = this.parent._getPathVector(relativeTo)
673-
path.push(this.getIndex())
673+
path.push(this.index)
674674
return path
675675
}
676676

677-
getIndex(): int {
677+
get index(): int {
678678
return this.parent._indexOfParticle(this)
679679
}
680680

@@ -1208,11 +1208,11 @@ class Particle extends AbstractParticle {
12081208
}
12091209

12101210
get isLast() {
1211-
return this.getIndex() === this.parent.length - 1
1211+
return this.index === this.parent.length - 1
12121212
}
12131213

12141214
get isFirst() {
1215-
return this.getIndex() === 0
1215+
return this.index === 0
12161216
}
12171217

12181218
getFrom(prefix: string) {
@@ -1280,7 +1280,7 @@ class Particle extends AbstractParticle {
12801280

12811281
get next(): Particle {
12821282
if (this.isRoot()) return this
1283-
const index = this.getIndex()
1283+
const index = this.index
12841284
const parent = this.parent
12851285
const length = parent.length
12861286
const next = index + 1
@@ -1289,7 +1289,7 @@ class Particle extends AbstractParticle {
12891289

12901290
get previous(): Particle {
12911291
if (this.isRoot()) return this
1292-
const index = this.getIndex()
1292+
const index = this.index
12931293
const parent = this.parent
12941294
const length = parent.length
12951295
const prev = index - 1
@@ -2155,11 +2155,11 @@ class Particle extends AbstractParticle {
21552155
}
21562156

21572157
prependSibling(line: string, subparticles: string) {
2158-
return this.parent.insertLineAndSubparticles(line, subparticles, this.getIndex())
2158+
return this.parent.insertLineAndSubparticles(line, subparticles, this.index)
21592159
}
21602160

21612161
appendSibling(line: string, subparticles: string) {
2162-
return this.parent.insertLineAndSubparticles(line, subparticles, this.getIndex() + 1)
2162+
return this.parent.insertLineAndSubparticles(line, subparticles, this.index + 1)
21632163
}
21642164

21652165
setContentWithSubparticles(text: string) {
@@ -2195,7 +2195,7 @@ class Particle extends AbstractParticle {
21952195
}
21962196

21972197
duplicate() {
2198-
return this.parent._insertLineAndSubparticles(this.getLine(), this.subparticlesToString(), this.getIndex() + 1)
2198+
return this.parent._insertLineAndSubparticles(this.getLine(), this.subparticlesToString(), this.index + 1)
21992199
}
22002200

22012201
trim() {
@@ -2387,7 +2387,7 @@ class Particle extends AbstractParticle {
23872387

23882388
replaceParticle(fn: (thisStr: string) => string) {
23892389
const parent = this.parent
2390-
const index = this.getIndex()
2390+
const index = this.index
23912391
const newParticles = new Particle(fn(this.toString()))
23922392
const returnedParticles: Particle[] = []
23932393
newParticles.forEach((subparticle, subparticleIndex) => {
@@ -2630,15 +2630,15 @@ class Particle extends AbstractParticle {
26302630
const grandParent = <Particle>this._getGrandParent()
26312631
if (!grandParent) return this
26322632

2633-
const parentIndex = this.parent.getIndex()
2633+
const parentIndex = this.parent.index
26342634
const newParticle = grandParent.insertLineAndSubparticles(this.getLine(), this.length ? this.subparticlesToString() : undefined, parentIndex + 1)
26352635
this.destroy()
26362636
return newParticle
26372637
}
26382638

26392639
pasteText(text: string) {
26402640
const parent = this.parent
2641-
const index = this.getIndex()
2641+
const index = this.index
26422642
const newParticles = new Particle(text)
26432643
const firstParticle = newParticles.particleAt(0)
26442644
if (firstParticle) {
@@ -3071,7 +3071,7 @@ class Particle extends AbstractParticle {
30713071
return str ? indent + str.replace(/\n/g, indent) : ""
30723072
}
30733073

3074-
static getVersion = () => "87.1.0"
3074+
static getVersion = () => "88.0.0"
30753075

30763076
static fromDisk(path: string): Particle {
30773077
const format = this._getFileFormat(path)

particleComponentFramework/ParticleComponentFramework.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ ${new stumpParser(this.toStumpCode()).compile()}
15371537

15381538
protected _updateHtml() {
15391539
const stumpParticleToMountOn = <abstractHtmlTag>this._htmlStumpParticle.parent
1540-
const currentIndex = this._htmlStumpParticle.getIndex()
1540+
const currentIndex = this._htmlStumpParticle.index
15411541
this._removeHtml()
15421542
this._mountHtml(stumpParticleToMountOn, this._toLoadedOrLoadingStumpCode(), currentIndex)
15431543
}

particleComponentFramework/sweepercraft/SweeperCraft.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,11 @@ class squareComponent extends AbstractSweeperCraftComponent {
897897
}
898898

899899
getRow() {
900-
return this.parent.getIndex()
900+
return this.parent.index
901901
}
902902

903903
getColumn() {
904-
return this.getIndex()
904+
return this.index
905905
}
906906

907907
get game() {

products/Particle.browser.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ class Particle extends AbstractParticle {
136136
}
137137
getOlderSiblings() {
138138
if (this.isRoot()) return []
139-
return this.parent.slice(0, this.getIndex())
139+
return this.parent.slice(0, this.index)
140140
}
141141
_getClosestOlderSibling() {
142142
const olderSiblings = this.getOlderSiblings()
143143
return olderSiblings[olderSiblings.length - 1]
144144
}
145145
getYoungerSiblings() {
146146
if (this.isRoot()) return []
147-
return this.parent.slice(this.getIndex() + 1)
147+
return this.parent.slice(this.index + 1)
148148
}
149149
getSiblings() {
150150
if (this.isRoot()) return []
@@ -556,10 +556,10 @@ class Particle extends AbstractParticle {
556556
_getPathVector(relativeTo) {
557557
if (this.isRoot(relativeTo)) return []
558558
const path = this.parent._getPathVector(relativeTo)
559-
path.push(this.getIndex())
559+
path.push(this.index)
560560
return path
561561
}
562-
getIndex() {
562+
get index() {
563563
return this.parent._indexOfParticle(this)
564564
}
565565
isTerminal() {
@@ -1012,10 +1012,10 @@ class Particle extends AbstractParticle {
10121012
return particles
10131013
}
10141014
get isLast() {
1015-
return this.getIndex() === this.parent.length - 1
1015+
return this.index === this.parent.length - 1
10161016
}
10171017
get isFirst() {
1018-
return this.getIndex() === 0
1018+
return this.index === 0
10191019
}
10201020
getFrom(prefix) {
10211021
const hit = this.filter(particle => particle.getLine().startsWith(prefix))[0]
@@ -1071,15 +1071,15 @@ class Particle extends AbstractParticle {
10711071
}
10721072
get next() {
10731073
if (this.isRoot()) return this
1074-
const index = this.getIndex()
1074+
const index = this.index
10751075
const parent = this.parent
10761076
const length = parent.length
10771077
const next = index + 1
10781078
return next === length ? parent._getSubparticlesArray()[0] : parent._getSubparticlesArray()[next]
10791079
}
10801080
get previous() {
10811081
if (this.isRoot()) return this
1082-
const index = this.getIndex()
1082+
const index = this.index
10831083
const parent = this.parent
10841084
const length = parent.length
10851085
const prev = index - 1
@@ -1788,10 +1788,10 @@ class Particle extends AbstractParticle {
17881788
return this
17891789
}
17901790
prependSibling(line, subparticles) {
1791-
return this.parent.insertLineAndSubparticles(line, subparticles, this.getIndex())
1791+
return this.parent.insertLineAndSubparticles(line, subparticles, this.index)
17921792
}
17931793
appendSibling(line, subparticles) {
1794-
return this.parent.insertLineAndSubparticles(line, subparticles, this.getIndex() + 1)
1794+
return this.parent.insertLineAndSubparticles(line, subparticles, this.index + 1)
17951795
}
17961796
setContentWithSubparticles(text) {
17971797
// todo: deprecate
@@ -1821,7 +1821,7 @@ class Particle extends AbstractParticle {
18211821
return this
18221822
}
18231823
duplicate() {
1824-
return this.parent._insertLineAndSubparticles(this.getLine(), this.subparticlesToString(), this.getIndex() + 1)
1824+
return this.parent._insertLineAndSubparticles(this.getLine(), this.subparticlesToString(), this.index + 1)
18251825
}
18261826
trim() {
18271827
// todo: could do this so only the trimmed rows are deleted.
@@ -1979,7 +1979,7 @@ class Particle extends AbstractParticle {
19791979
}
19801980
replaceParticle(fn) {
19811981
const parent = this.parent
1982-
const index = this.getIndex()
1982+
const index = this.index
19831983
const newParticles = new Particle(fn(this.toString()))
19841984
const returnedParticles = []
19851985
newParticles.forEach((subparticle, subparticleIndex) => {
@@ -2176,14 +2176,14 @@ class Particle extends AbstractParticle {
21762176
shiftLeft() {
21772177
const grandParent = this._getGrandParent()
21782178
if (!grandParent) return this
2179-
const parentIndex = this.parent.getIndex()
2179+
const parentIndex = this.parent.index
21802180
const newParticle = grandParent.insertLineAndSubparticles(this.getLine(), this.length ? this.subparticlesToString() : undefined, parentIndex + 1)
21812181
this.destroy()
21822182
return newParticle
21832183
}
21842184
pasteText(text) {
21852185
const parent = this.parent
2186-
const index = this.getIndex()
2186+
const index = this.index
21872187
const newParticles = new Particle(text)
21882188
const firstParticle = newParticles.particleAt(0)
21892189
if (firstParticle) {
@@ -2579,7 +2579,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species
25792579
4.9,2.5,4.5,1.7,virginica
25802580
5.1,3.5,1.4,0.2,setosa
25812581
5,3.4,1.5,0.2,setosa`
2582-
Particle.getVersion = () => "87.1.0"
2582+
Particle.getVersion = () => "88.0.0"
25832583
class AbstractExtendibleParticle extends Particle {
25842584
_getFromExtended(firstAtomPath) {
25852585
const hit = this._getParticleFromExtended(firstAtomPath)

0 commit comments

Comments
 (0)