Socket
Socket
Sign inDemoInstall

tagx

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tagx

Tag utility module


Version published
Weekly downloads
3
Maintainers
1
Created
Weekly downloads
 

Readme

Source

tagx

A tag composer module for Node.js

This module lets you build a set of tags by combining and expanding existing lists of tags. Tags are character strings that don't contain any punctuation or spaces. The tags are parsed out of a comma or space separated line of text, and duplicates are removed.

For example:

"foo, bar, zoo" -> ['foo','bar','zoo']
"foo bar zoo" -> ['foo','bar','zoo']

Support

If you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger

This module works on both Node.js and browsers.

Current Version: 0.1.2

Tested on: Node.js 0.10.29, Chrome 29, Firefox 23, Safari 5.1, Opera 12.11

Build Status

Quick examples

To parse a string containing tags:

var tagx = require('tagx')

var tags = tagx("foo bar zoo")

// prints [ 'foo', 'bar', 'zoo' ]
console.log(tags)  

You can combine multiple tag strings:

var tagx = require('tagx')

tags = tagx("a b c","d e f")

// prints [ 'a', 'b', 'c', 'd', 'e', 'f' ]
console.log(tags)  

You can make tags case-insensitive:

var uncase = tagx({case:false})
tags = uncase("a A bb bB BB")

// prints [ 'a', 'bb' ]
console.log(tags)

You can define fixed tags that get added to any parsed tags:

var abc = tagx({},'a b c')
tags = abc("x y z")

// prints [ 'a', 'b', 'c', 'x', 'y', 'z' ]
console.log(tags)

You can define negative tags (prefix with !) that cancel out positive tags:

tags = tagx("a  b !b  !c c")

// prints [ 'a' ]
console.log(tags)

You can also define tag expansions, where certain tags expand to become a set of tags (negatives still work, and infinite cycles are detected):

var expand = tagx({expand:{ foo:'a b c !d', u:'v', v:'u' }})
tags = expand("foo !c d e f u")

// prints [ 'a', 'b', 'e', 'f', 'u' ]
// foo -> a,b as !c and d cancel c !d
// u -> v -> u and stops
console.log(tags)

Development

You'll need:

sudo npm install phantomjs uglify-js -g

Test with:

npm test

Keywords

FAQs

Last updated on 06 Jul 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc