Skip to content

Commit 4e630a5

Browse files
committed
made p5.sound class, p5 class and p5. prefix constants
1 parent b93c599 commit 4e630a5

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/scripts/parsers/reference.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,17 @@ export const parseLibraryReference =
6666
if (!soundData) throw new Error('Error generating p5.sound reference data!');
6767

6868
// Fix p5.sound classes and map global methods to the 'p5' class
69+
const P5_SOUND_CLASS = 'p5.sound';
70+
const P5_CLASS = 'p5';
71+
const P5_PREFIX = 'p5.';
72+
6973
const classKeys = Object.keys(soundData.classes);
7074
for (const key of classKeys) {
7175
let newName = soundData.classes[key].name;
72-
if (newName === 'p5.sound') {
73-
newName = 'p5';
74-
} else if (!newName.startsWith('p5.')) {
75-
newName = `p5.${newName}`;
76+
if (newName === P5_SOUND_CLASS) {
77+
newName = P5_CLASS;
78+
} else if (!newName.startsWith(P5_PREFIX)) {
79+
newName = `${P5_PREFIX}${newName}`;
7680
}
7781

7882
if (newName !== soundData.classes[key].name) {
@@ -85,10 +89,10 @@ export const parseLibraryReference =
8589
}
8690
}
8791
for (const item of soundData.classitems) {
88-
if (item.class === 'p5.sound') {
89-
item.class = 'p5';
90-
} else if (!item.class.startsWith('p5.')) {
91-
item.class = `p5.${item.class}`;
92+
if (item.class === P5_SOUND_CLASS) {
93+
item.class = P5_CLASS;
94+
} else if (!item.class.startsWith(P5_PREFIX)) {
95+
item.class = `${P5_PREFIX}${item.class}`;
9296
}
9397
}
9498

0 commit comments

Comments
 (0)