Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wankdanker/node-tag-string

Parse and manage a string of tags
https://github.com/wankdanker/node-tag-string

Last synced: 14 days ago
JSON representation

Parse and manage a string of tags

Awesome Lists containing this project

README

        

tag-string
----------

Parse and manage a string of tags

install
-------

```bash
npm install tag-string
```

usage
-----

```js
var ts = require('tag-string');
var t = ts('bulk,updated,ready,other-thing');

t.add('fixed');
t.del('bulk');

console.log(t.get());
//updated,ready,other-thing,fixed
```

api
---

### Constructor

require(tag-string)(string);

### .add(tag)

Adds a new tag to the collection of tags only if it does not already exist.

* tag - The tag to add.
* return - When the tag has been added the new count of tags in the collection
is returned. When the tag is not added, `false` is returned.

### .del([tag])

Removes a tag from the collection of tags.

* tag - optional - The tag to be removed from collection
* If tag is not provided all tags are removed
* return - When the tag has been removed the new count of tags in the collection
is returend. When the tag is not removed, `false` is returned.

### .get([tag])

Get the string of tags

### .has(tag)

Check to see if a tag exists within the collection of tags

* tag - the tag to look up

license
-------

MIT