0.0.3 • Published 9 years ago

superscore.string v0.0.3

Weekly downloads
2
License
WTFPL
Repository
github
Last release
9 years ago

superscore.string

Underscore.String mixins

Usage

Node environment

npm install superscore.string

Then in your scripts:

var s = require('superscore.string');

Browser environment

bower install superscore.string

Then include these files into your documents

<script src="bower_components/superscore.string/dist/lowerdash.js"></script>
<script src="bower_components/underscore.string/lib/underscore.string.js"></script>

API

Superscore.String provides the following methods :

  • String truncate(String str, Number max, [Object options]) Truncate a string before atChar str string to truncate max string max length options options.trail leading string, default to * options.atChar if provided, cut string before it

    	```javascript
    	s.truncate('The quick brown fox jumps over the lazy dog', 20, {
    		atChar: ' '
    	});
    	// "The quick brown fox…"
    
    	s.truncate('The quick brown fox jumps over the lazy dog', 17);
    	// "The quick brown f…"
    	```
  • Boolean anymatch(String str, Array matchers) Test provided string against anymatch expression(s) (Node only)

    	```javascript
    	console.info(s.anymatch('The quick brown fox jumps over the lazy dog', ['over', /^the/]))
    	//false
    
    	console.info(s.anymatch('The quick brown fox jumps over the lazy dog', ['over', /^The/]))
    	// true
    	```
  • String random(Number length) Generates a random string of length length
0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago