code: function convertGroupsToRanks(groups) {
    const rankObject = groups.reduce(function(res, group, index) {
      if (typeof group === 'string') {
        group = [group]
      }
      group.forEach(function(groupItem) {
        if (types.indexOf(groupItem) === -1) {
          throw new Error('Incorrect configuration of the rule: Unknown type `' +
            JSON.stringify(groupItem) + '`')
        }
        if (res[groupItem] !== undefined) {
          throw new Error('Incorrect configuration of the rule: `' + groupItem + '` is duplicated')
        }
        res[groupItem] = index
      })
      return res
    }, {})
  
    const omittedTypes = types.filter(function(type) {
      return rankObject[type] === undefined
    })
  
    return omittedTypes.reduce(function(res, type) {
      res[type] = groups.length
      return res
    }, rankObject)
  }
docs: Creates an object with type-rank pairs. Example: { index: 0, sibling: 1, parent: 1, external: 1, builtin: 2, internal: 2 } Will throw an error if it contains a type that does not exist, or has a duplicate