npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

extract-html-class

1.0.1

@yoshuawuyts

npmHomeRepoSnykSocket
Downloads:0
$ npm install extract-html-class
DailyWeeklyMonthlyYearly

extract-html-class stability

npm version build status downloads js-standard-style

Extract all classes from html

Usage

var extract = require('extract-html-class')
var assert = require('assert')

var html = `
  <div class="foo bar">
    <p class="bin baz">hello planet</p>
  </div>
`
var expected = [ 'foo', 'bar', 'bin', 'baz' ]
assert.deepEqual(extract(html), expected, 'array was same')

API

classes = extract(html)

Get an array of classes for the given string. Uses a regex so safe to run on non-html strings too. Returns an empty array if no matches are found.

License

MIT