UNPKG

586 BJavaScriptView Raw
1'use strict'
2
3/**
4 * @description Get the next tag from a node list
5 *
6 * @method getNextTag
7 *
8 * @param {Array} nodes Nodes
9 * @param {Number} i Accumulator
10 *
11 * @return {Array} [] Array containing the next tag
12 */
13function getNextTag (nodes, i) {
14 // loop until we get the next tag (bypassing newlines etc)
15 while (i < nodes.length) {
16 const node = nodes[i]
17
18 if (typeof node === 'object') {
19 return [i, node]
20 } else {
21 i++
22 }
23 }
24
25 return [i, { tag: undefined }]
26}
27
28/**
29 * @module tags
30 *
31 * @type {Function}
32 */
33module.exports = getNextTag