Skip to content

Commit 890819c

Browse files
authored
Merge pull request #15 from Secreto31126:conditional-chains
Removed unecessary conditional chainings
2 parents 3d15f2c + 576b6b1 commit 890819c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

types/contacts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Contacts {
1515
* @throws {Error} If contact contains more than one organization component
1616
*/
1717
constructor(...contact) {
18-
if (!contact?.length) throw new Error("Contacts must have at least one contact");
18+
if (!contact.length) throw new Error("Contacts must have at least one contact");
1919

2020
this.contacts = [];
2121

types/interactive.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ActionList {
134134
constructor(button, ...sections) {
135135
if (!button) throw new Error("Action must have a button content");
136136
if (button.length > 20) throw new Error("Button content must be 20 characters or less");
137-
if (!sections?.length || sections.length > 10) throw new Error("Action must have between 1 and 10 sections");
137+
if (!sections.length || sections.length > 10) throw new Error("Action must have between 1 and 10 sections");
138138
if (sections.length > 1) sections.forEach(s => { if (!s.title) throw new Error("Sections must have a title if more than 1 section is provided") });
139139

140140
this._ = "list";
@@ -160,7 +160,7 @@ class Section {
160160
*/
161161
constructor(title, ...rows) {
162162
if (title && title.length > 24) throw new Error("Section title must be 24 characters or less");
163-
if (!rows?.length || rows.length > 10) throw new Error("Section must have between 1 and 10 rows");
163+
if (!rows.length || rows.length > 10) throw new Error("Section must have between 1 and 10 rows");
164164

165165
if (title) this.title = title;
166166
this.rows = rows;
@@ -216,7 +216,7 @@ class ActionButtons {
216216
* @throws {Error} If two or more buttons have the same title
217217
*/
218218
constructor(...button) {
219-
if (!button?.length || button.length > 3) throw new Error("Reply buttons must have between 1 and 3 buttons");
219+
if (!button.length || button.length > 3) throw new Error("Reply buttons must have between 1 and 3 buttons");
220220

221221
// Find if there are duplicates in button.id
222222
const ids = button.map(b => b[b.type].id);

types/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class ButtonComponent {
124124
*/
125125
constructor(sub_type, ...parameters) {
126126
if (!["url", "quick_reply"].includes(sub_type)) throw new Error("ButtonComponent sub_type must be either 'url' or 'quick_reply'");
127-
if (!parameters?.length) throw new Error("ButtonComponent must have at least 1 parameter");
127+
if (!parameters.length) throw new Error("ButtonComponent must have at least 1 parameter");
128128
if (parameters.length > 3) throw new Error("ButtonComponent can only have up to 3 parameters");
129129

130130
const buttonType = sub_type === "url" ? "text" : "payload";

0 commit comments

Comments
 (0)