johno / dom-stats

Parse and return statistics for an html string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dom-stats Build Status js-standard-style

Parse and return stats for a given html string.

Installation

npm i -S dom-stats

Usage

const domStats = require('dom-stats')

const stats = domStats('<span id="foo"><i class="hi" id="foo"</i></span>')
console.log(stats)
// {
//   totalTags: 2,
//   totalClasses: 1,
//   totalIds: 2,
//   averageClassCount: 0.5,
//   duplicateIds: ['foo'],
//   duplicateIdsCount: 1,
//   tagCounts: { span: 1, a: 1 }
// }

License

MIT

Related

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Crafted with <3 by John Otander (@4lpine).


This package was initially generated with yeoman and the p generator.

About

Parse and return statistics for an html string

License:MIT License


Languages

Language:JavaScript 100.0%