Skip to content

Commit

Permalink
Make attrs optional for builder functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Nov 19, 2023
1 parent d683aba commit b8780a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { copyElement, createHtml, serialize, xmlElement, xmlGenerator, xmlTextNo
* Create a {@link Strophe.Builder}
* This is an alias for `new Strophe.Builder(name, attrs)`.
* @param {string} name - The root element name.
* @param {Object.<string,string|number>} attrs - The attributes for the root element in object notation.
* @param {Object.<string,string|number>} [attrs] - The attributes for the root element in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $build(name, attrs) {
Expand All @@ -14,7 +14,7 @@ export function $build(name, attrs) {

/**
* Create a {@link Strophe.Builder} with a `<message/>` element as the root.
* @param {Object.<string,string>} attrs - The <message/> element attributes in object notation.
* @param {Object.<string,string>} [attrs] - The <message/> element attributes in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $msg(attrs) {
Expand All @@ -23,7 +23,7 @@ export function $msg(attrs) {

/**
* Create a {@link Strophe.Builder} with an `<iq/>` element as the root.
* @param {Object.<string,string>} attrs - The <iq/> element attributes in object notation.
* @param {Object.<string,string>} [attrs] - The <iq/> element attributes in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $iq(attrs) {
Expand All @@ -32,7 +32,7 @@ export function $iq(attrs) {

/**
* Create a {@link Strophe.Builder} with a `<presence/>` element as the root.
* @param {Object.<string,string>} attrs - The <presence/> element attributes in object notation.
* @param {Object.<string,string>} [attrs] - The <presence/> element attributes in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $pres(attrs) {
Expand Down Expand Up @@ -76,7 +76,7 @@ class Builder {
/**
* The attributes should be passed in object notation.
* @param {string} name - The name of the root element.
* @param {StanzaAttrs} attrs - The attributes for the root element in object notation.
* @param {StanzaAttrs} [attrs] - The attributes for the root element in object notation.
* @example const b = new Builder('message', {to: 'you', from: 'me'});
* @example const b = new Builder('messsage', {'xml:lang': 'en'});
*/
Expand Down
20 changes: 10 additions & 10 deletions src/types/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
* Create a {@link Strophe.Builder}
* This is an alias for `new Strophe.Builder(name, attrs)`.
* @param {string} name - The root element name.
* @param {Object.<string,string|number>} attrs - The attributes for the root element in object notation.
* @param {Object.<string,string|number>} [attrs] - The attributes for the root element in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $build(name: string, attrs: {
export function $build(name: string, attrs?: {
[x: string]: string | number;
}): Builder;
/**
* Create a {@link Strophe.Builder} with a `<message/>` element as the root.
* @param {Object.<string,string>} attrs - The <message/> element attributes in object notation.
* @param {Object.<string,string>} [attrs] - The <message/> element attributes in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $msg(attrs: {
export function $msg(attrs?: {
[x: string]: string;
}): Builder;
/**
* Create a {@link Strophe.Builder} with an `<iq/>` element as the root.
* @param {Object.<string,string>} attrs - The <iq/> element attributes in object notation.
* @param {Object.<string,string>} [attrs] - The <iq/> element attributes in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $iq(attrs: {
export function $iq(attrs?: {
[x: string]: string;
}): Builder;
/**
* Create a {@link Strophe.Builder} with a `<presence/>` element as the root.
* @param {Object.<string,string>} attrs - The <presence/> element attributes in object notation.
* @param {Object.<string,string>} [attrs] - The <presence/> element attributes in object notation.
* @return {Builder} A new Strophe.Builder object.
*/
export function $pres(attrs: {
export function $pres(attrs?: {
[x: string]: string;
}): Builder;
export default Builder;
Expand Down Expand Up @@ -69,11 +69,11 @@ declare class Builder {
/**
* The attributes should be passed in object notation.
* @param {string} name - The name of the root element.
* @param {StanzaAttrs} attrs - The attributes for the root element in object notation.
* @param {StanzaAttrs} [attrs] - The attributes for the root element in object notation.
* @example const b = new Builder('message', {to: 'you', from: 'me'});
* @example const b = new Builder('messsage', {'xml:lang': 'en'});
*/
constructor(name: string, attrs: {
constructor(name: string, attrs?: {
[x: string]: string | number;
});
nodeTree: Element;
Expand Down

0 comments on commit b8780a2

Please sign in to comment.