Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dustinspecker/parse-css-class-id-selector
Retreive class names and id from a CSS selector
https://github.com/dustinspecker/parse-css-class-id-selector
Last synced: 2 days ago
JSON representation
Retreive class names and id from a CSS selector
- Host: GitHub
- URL: https://github.com/dustinspecker/parse-css-class-id-selector
- Owner: dustinspecker
- License: mit
- Created: 2016-02-14T01:59:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-28T20:11:43.000Z (over 7 years ago)
- Last Synced: 2024-09-18T03:19:28.252Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# parse-css-class-id-selector
[![NPM version](https://badge.fury.io/js/parse-css-class-id-selector.svg)](https://badge.fury.io/js/parse-css-class-id-selector) [![Build Status](https://travis-ci.org/dustinspecker/parse-css-class-id-selector.svg)](https://travis-ci.org/dustinspecker/parse-css-class-id-selector) [![Coverage Status](https://img.shields.io/coveralls/dustinspecker/parse-css-class-id-selector.svg)](https://coveralls.io/r/dustinspecker/parse-css-class-id-selector?branch=master)[![Code Climate](https://codeclimate.com/github/dustinspecker/parse-css-class-id-selector/badges/gpa.svg)](https://codeclimate.com/github/dustinspecker/parse-css-class-id-selector) [![Dependencies](https://david-dm.org/dustinspecker/parse-css-class-id-selector.svg)](https://david-dm.org/dustinspecker/parse-css-class-id-selector/#info=dependencies&view=table) [![DevDependencies](https://david-dm.org/dustinspecker/parse-css-class-id-selector/dev-status.svg)](https://david-dm.org/dustinspecker/parse-css-class-id-selector/#info=devDependencies&view=table)
> Retreive class names and id from a CSS selector
## Install
```
npm install --save parse-css-class-id-selector
```## Usage
```javascript
import parseCssClassIdSelector from 'parse-css-class-id-selector'parseCssClassIdSelector('.hello#world.good-bye')
// => {id: 'world', classNames: ['hello', 'good-bye']}parseCssClassIdSelector('#world')
// => {id: 'world', classNames: []}parseCssClassIdSelector('.hello.good-bye')
// => {id: null, classNames: ['hello', 'good-bye']}
```## API
### parseCssClassIdSelector(selector)
Returns an object with a `classNames` array and an `id`. An empty array is return if no class names found. Null is return if no id is found.
#### selector
type: `String`A string consisting of only class and/or id selectors.
## LICENSE
MIT © [Dustin Specker](https://github.com/dustinspecker)