function-park is an common functions package for Nodejs。
npm install --save function-park
var S = require('function-park').string;
Name | Description |
---|---|
trim | Used for trimming whitespace |
ltrim | Used for trimming whitespace at left |
rtrim | Used for trimming whitespace at right |
left | Return part of a string from left |
right | Return part of a string from right |
ucfirst | Uppercase the first character of a string |
lcfirst | Lowercase the first character of a string |
md5 | Calculate the md5 hash of a string |
sha1 | Calculate the sha1 hash of a string |
is_email | Is an email string or not |
is_ip | Is an ip string or not |
strip_tags | Strip HTML tags from a string |
var S = require('function-park').string;
var str = "My name is Nemo!";
console.log(S(str).lcfirst()); //print "my name is Nemo!"
Well, it's also can call these methods directly on native String. Just like this:
var S = require('function-park').string;
S.extendToString();
console.log("My name is Nemo!".lcfirst().ucfirst()); //print "My name is Nemo!"