Skip to content

Commit b996e55

Browse files
committed
Renamed Top -> First and TopN -> Peek.
1 parent 64cba29 commit b996e55

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

mathjax3-ts/input/tex/Stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export default class Stack {
146146
*/
147147
public Prev(noPop?: boolean): MmlNode | void {
148148
const top = this.Top();
149-
return noPop ? top.Last : top.Pop();
149+
return noPop ? top.First : top.Pop();
150150
}
151151

152152

mathjax3-ts/input/tex/StackItem.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface NodeStack {
4545
* Get or set the topmost element on the node stack without removing it.
4646
* @return {MmlNode} The topmost node on the stack.
4747
*/
48-
Top: MmlNode;
48+
First: MmlNode;
4949

5050
/**
5151
* Get or set the last element on the node stack without removing it.
@@ -69,7 +69,7 @@ export interface NodeStack {
6969
* @param {number=} n Number of elements that should be returned.
7070
* @return {MmlNode[]} List of nodes on top of stack.
7171
*/
72-
TopN(n?: number): MmlNode[];
72+
Peek(n?: number): MmlNode[];
7373

7474
/**
7575
* @return {number} The size of the stack.
@@ -129,15 +129,15 @@ export abstract class MmlStack implements NodeStack {
129129
/**
130130
* @override
131131
*/
132-
public get Top(): MmlNode {
132+
public get First(): MmlNode {
133133
return this._nodes[this.Size() - 1];
134134
}
135135

136136

137137
/**
138138
* @override
139139
*/
140-
public set Top(node: MmlNode) {
140+
public set First(node: MmlNode) {
141141
this._nodes[this.Size() - 1] = node;
142142
}
143143

@@ -161,7 +161,7 @@ export abstract class MmlStack implements NodeStack {
161161
/**
162162
* @override
163163
*/
164-
public TopN(n?: number): MmlNode[] {
164+
public Peek(n?: number): MmlNode[] {
165165
if (n == null) {
166166
n = 1;
167167
}
@@ -192,7 +192,7 @@ export abstract class MmlStack implements NodeStack {
192192
*/
193193
public toMml(inferred: boolean = true, forceRow?: boolean) {
194194
if (this._nodes.length === 1 && !forceRow) {
195-
return this.Top;
195+
return this.First;
196196
}
197197
// @test Two Identifiers
198198
return this.create(
@@ -440,7 +440,7 @@ export abstract class BaseItem extends MmlStack implements StackItem {
440440
if (!item.isFinal) {
441441
return true;
442442
}
443-
this.Push(item.Top);
443+
this.Push(item.First);
444444
return false;
445445
}
446446

mathjax3-ts/input/tex/TexParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default class TexParser {
218218
if (!this.stack.Top().isKind('mml')) {
219219
return null;
220220
}
221-
let node = this.stack.Top().Top;
221+
let node = this.stack.Top().First;
222222
this.configuration.popParser();
223223
return node;
224224
}

mathjax3-ts/input/tex/ams/AmsMethods.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ AmsMethods.xArrow = function(parser: TexParser, name: string,
223223
chr: number, l: number, r: number) {
224224
let def = {width: '+' + (l + r) + 'mu', lspace: l + 'mu'};
225225
let bot = parser.GetBrackets(name);
226-
let top = parser.ParseArg(name);
226+
let first = parser.ParseArg(name);
227227
let arrow = parser.create('token',
228228
'mo', {stretchy: true, texClass: TEXCLASS.REL}, String.fromCharCode(chr));
229229
let mml = parser.create('node', 'munderover', [arrow]) as MmlMunderover;
230-
let mpadded = parser.create('node', 'mpadded', [top], def);
230+
let mpadded = parser.create('node', 'mpadded', [first], def);
231231
NodeUtil.setProperties(mpadded, {voffset: '.15em'});
232232
NodeUtil.setChild(mml, mml.over, mpadded);
233233
if (bot) {

mathjax3-ts/input/tex/base/BaseItems.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class PrimeItem extends BaseItem {
181181
* @override
182182
*/
183183
public checkItem(item: StackItem) {
184-
let [top0, top1] = this.TopN(2);
184+
let [top0, top1] = this.Peek(2);
185185
if (!NodeUtil.isType(top0, 'msubsup')) {
186186
// @test Prime, Double Prime
187187
const node = this.create('node', 'msup', [top0, top1]);
@@ -224,7 +224,7 @@ export class SubsupItem extends BaseItem {
224224
if (item.isKind('open') || item.isKind('left')) {
225225
return true;
226226
}
227-
const top = this.Top;
227+
const top = this.First;
228228
const position = this.getProperty('position') as number;
229229
if (item.isKind('mml')) {
230230
if (this.getProperty('primes')) {
@@ -234,11 +234,11 @@ export class SubsupItem extends BaseItem {
234234
} else {
235235
// @test Prime on Prime
236236
NodeUtil.setProperties(this.getProperty('primes') as MmlNode, {variantForm: true});
237-
const node = this.create('node', 'mrow', [this.getProperty('primes') as MmlNode, item.Top]);
238-
item.Top = node;
237+
const node = this.create('node', 'mrow', [this.getProperty('primes') as MmlNode, item.First]);
238+
item.First = node;
239239
}
240240
}
241-
NodeUtil.setChild(top, position, item.Top);
241+
NodeUtil.setChild(top, position, item.First);
242242
if (this.getProperty('movesupsub') != null) {
243243
// @test Limits Subsup (currently does not work! Check again!)
244244
NodeUtil.setProperties(top, {movesupsub: this.getProperty('movesupsub')} as PropertyList);
@@ -567,15 +567,15 @@ export class FnItem extends BaseItem {
567567
* @override
568568
*/
569569
public checkItem(item: StackItem) {
570-
const top = this.Top;
570+
const top = this.First;
571571
if (top) {
572572
if (item.isOpen) {
573573
// @test Fn Stretchy
574574
return true;
575575
}
576576
if (!item.isKind('fn')) {
577577
// @test Named Function
578-
let mml = item.Top;
578+
let mml = item.First;
579579
if (!item.isKind('mml') || !mml) {
580580
// @test Mathop Super
581581
return [top, item];
@@ -630,9 +630,9 @@ export class NotItem extends BaseItem {
630630
return true;
631631
}
632632
if (item.isKind('mml') &&
633-
(NodeUtil.isType(item.Top, 'mo') || NodeUtil.isType(item.Top, 'mi') ||
634-
NodeUtil.isType(item.Top, 'mtext'))) {
635-
mml = item.Top;
633+
(NodeUtil.isType(item.First, 'mo') || NodeUtil.isType(item.First, 'mi') ||
634+
NodeUtil.isType(item.First, 'mtext'))) {
635+
mml = item.First;
636636
c = NodeUtil.getText(mml as TextNode);
637637
if (c.length === 1 && !NodeUtil.getProperty(mml, 'movesupsub') &&
638638
NodeUtil.getChildren(mml).length === 1) {
@@ -675,7 +675,7 @@ export class DotsItem extends BaseItem {
675675
return true;
676676
}
677677
let dots = this.getProperty('ldots') as MmlNode;
678-
let top = item.Top;
678+
let top = item.First;
679679
// @test Operator Dots
680680
if (item.isKind('mml') && NodeUtil.isEmbellished(top)) {
681681
const tclass = NodeUtil.getTexClass(NodeUtil.getCoreMO(top));

mathjax3-ts/input/tex/base/BaseMethods.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ BaseMethods.Superscript = function(parser: TexParser, c: string) {
114114
const top = parser.stack.Top();
115115
if (top.isKind('prime')) {
116116
// @test Prime on Prime
117-
[base, primes] = top.TopN(2);
117+
[base, primes] = top.Peek(2);
118118
parser.stack.Pop();
119119
} else {
120120
// @test Empty base2, Square, Cube
@@ -174,7 +174,7 @@ BaseMethods.Subscript = function(parser: TexParser, c: string) {
174174
const top = parser.stack.Top();
175175
if (top.isKind('prime')) {
176176
// @test Prime on Sub
177-
[base, primes] = top.TopN(2);
177+
[base, primes] = top.Peek(2);
178178
parser.stack.Pop();
179179
} else {
180180
base = parser.stack.Prev();

0 commit comments

Comments
 (0)