Skip to content

Commit

Permalink
chore(utilities): update JSDoc and declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Dec 8, 2020
1 parent f18c362 commit 048e609
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
29 changes: 18 additions & 11 deletions lib/utilities.d.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
// TypeScript Version: 3.3
// TypeScript Version: 4.1

import { DomElement } from 'domhandler';

/**
* Formats DOM attributes to a hash map.
*
* @param attributes - The list of attributes to format.
* @returns - A map of attribute name to value.
* @param attributes - List of attributes.
* @return - Map of attribute name to value.
*/
export function formatAttributes(attributes: NamedNodeMap): {[name: string]: string};
export function formatAttributes(
attributes: NamedNodeMap
): { [name: string]: string };

/**
* Formats the browser DOM nodes to mimic the output of `htmlparser2.parseDOM()`.
*
* @param nodes - The DOM nodes to format.
* @param parentObj - The formatted parent node of the given DOM nodes.
* @param directive - The directive.
* @param nodes - DOM nodes.
* @param parentNode - Formatted parent node.
* @param directive - Directive.
* @return - DOM elements.
*/
export function formatDOM(nodes: NodeList, parentObj?: DomElement, directive?: string): DomElement[];
export function formatDOM(
nodes: NodeList,
parentNode?: DomElement,
directive?: string
): DomElement[];

/**
* Detects IE with or without version.
* Detects if browser is Internet Explorer.
*
* @param version - The IE version to detect.
* @returns - Whether IE or the version has been detected.
* @param version - IE version to detect.
* @return - Whether IE or the version is detected.
*/
export function isIE(version?: number): boolean;
24 changes: 12 additions & 12 deletions lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) {
/**
* Gets case-sensitive tag name.
*
* @param {String} tagName - Tag name in lowercase.
* @return {String|undefined}
* @param {string} tagName - Tag name in lowercase.
* @return {string|undefined} - Case-sensitive tag name.
*/
function getCaseSensitiveTagName(tagName) {
return caseSensitiveTagNamesMap[tagName];
Expand All @@ -20,8 +20,8 @@ function getCaseSensitiveTagName(tagName) {
/**
* Formats DOM attributes to a hash map.
*
* @param {NamedNodeMap} attributes - The list of attributes.
* @return {Object} - A map of attribute name to value.
* @param {NamedNodeMap} attributes - List of attributes.
* @return {object} - Map of attribute name to value.
*/
function formatAttributes(attributes) {
var result = {};
Expand All @@ -38,8 +38,8 @@ function formatAttributes(attributes) {
* Corrects the tag name if it is case-sensitive (SVG).
* Otherwise, returns the lowercase tag name (HTML).
*
* @param {String} tagName - The lowercase tag name.
* @return {String} - The formatted tag name.
* @param {string} tagName - Lowercase tag name.
* @return {string} - Formatted tag name.
*/
function formatTagName(tagName) {
tagName = tagName.toLowerCase();
Expand All @@ -53,10 +53,10 @@ function formatTagName(tagName) {
/**
* Formats the browser DOM nodes to mimic the output of `htmlparser2.parseDOM()`.
*
* @param {NodeList} nodes - DOM nodes.
* @param {Object} [parentNode] - Formatted parent node.
* @param {String} [directive] - Directive.
* @return {Object[]} - Formatted DOM object.
* @param {NodeList} nodes - DOM nodes.
* @param {object} [parentNode] - Formatted parent node.
* @param {string} [directive] - Directive.
* @return {DomElement[]} - Formatted DOM object.
*/
function formatDOM(nodes, parentNode, directive) {
parentNode = parentNode || null;
Expand Down Expand Up @@ -143,8 +143,8 @@ function formatDOM(nodes, parentNode, directive) {
/**
* Detects if browser is Internet Explorer.
*
* @param {Number} [version] - IE version to detect.
* @return {Boolean}
* @param {number} [version] - IE version to detect.
* @return {boolean} - Whether IE or the version is detected.
*/
function isIE(version) {
if (version) {
Expand Down

0 comments on commit 048e609

Please sign in to comment.