Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Functions that assist in working with strings. Node.js

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 History.md
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Makefile
Octocat-spinner-32 Readme.md
Octocat-spinner-32 hydro.conf.js
Octocat-spinner-32 package.json
Readme.md

Build Status

word

screenshot

Description

Word contains functions that assist in working with strings.

Features

  • strip slashes
  • strip quotes
  • quotes to entities
  • random strings
  • repeat string
  • censor words in text
  • strip links
  • auto links
  • excerpts
  • word limit
  • pluralize
  • join
  • capitalize
  • camel-case
  • slug
word = require 'word'

result = null

result = word.stripSlashes "O\\'reilly" # strips slashes.

result = word.stripQuotes "foo ' bar" # strips quotes

result = word.quotesEntities "foo ' bar" # quotes to entities

result = word.random 5 # returns random string with length of 5

result = word.repeat 'foo', 3 # repeats n times a string

result = word.censor 'foo', 'foo', '***' # censors bad words.

result = word.censor 'foo bar baz', ['foo', 'bar'], '***'

result = word.stripLinks 'baz <a href="http://example.com" class="foobar">Foo</a>' # strips links

result = word.autoLink "http://example.com/" # links -> a + href

result = word.excerpt 'foobar', 3 # extracts an excerpt from string

result = word.limit 'foo bar baz bar foo.', 3 # limits text to n words.

result = word.wrap 'foooo bar baz', 3 # wraps text to given length.

result = word.pluralize 2, 'dog' # pluralize or not, depends on supplied count.

Want to use it as helper in your express app? Sure.

Install

$ npm install word

Tests

$ npm install
$ make test

License

MIT License

Something went wrong with that request. Please try again.