minor cleanup
This commit is contained in:
parent
11377c99b9
commit
e88f622449
1 changed files with 21 additions and 20 deletions
|
@ -7,16 +7,16 @@ Ox.char = String.fromCharCode;
|
|||
|
||||
/*@
|
||||
Ox.clean <f> Remove leading, trailing and double whitespace from a string
|
||||
> Ox.clean("foo bar")
|
||||
"foo bar"
|
||||
> Ox.clean(" foo bar ")
|
||||
"foo bar"
|
||||
> Ox.clean(" foo \n bar ")
|
||||
"foo\nbar"
|
||||
> Ox.clean(" \nfoo\n\nbar\n ")
|
||||
"foo\nbar"
|
||||
> Ox.clean(" foo\tbar ")
|
||||
"foo bar"
|
||||
> Ox.clean('foo bar')
|
||||
'foo bar'
|
||||
> Ox.clean(' foo bar ')
|
||||
'foo bar'
|
||||
> Ox.clean(' foo \n bar ')
|
||||
'foo\nbar'
|
||||
> Ox.clean(' \nfoo\n\nbar\n ')
|
||||
'foo\nbar'
|
||||
> Ox.clean(' foo\tbar ')
|
||||
'foo bar'
|
||||
@*/
|
||||
Ox.clean = function(string) {
|
||||
return Ox.filter(Ox.map(string.split('\n'), function(string) {
|
||||
|
@ -43,13 +43,13 @@ Ox.endsWith = function(string, substring) {
|
|||
Ox.isValidEmail <f> Tests if a string is a valid e-mail address
|
||||
(str) -> <b> True if the string is a valid e-mail address
|
||||
str <s> Any string
|
||||
> Ox.isValidEmail("foo@bar.com")
|
||||
> Ox.isValidEmail('foo@bar.com')
|
||||
true
|
||||
> Ox.isValidEmail("foo.bar@foobar.co.uk")
|
||||
> Ox.isValidEmail('foo.bar@foobar.co.uk')
|
||||
true
|
||||
> Ox.isValidEmail("foo@bar")
|
||||
> Ox.isValidEmail('foo@bar')
|
||||
false
|
||||
> Ox.isValidEmail("foo@bar..com")
|
||||
> Ox.isValidEmail('foo@bar..com')
|
||||
false
|
||||
@*/
|
||||
Ox.isValidEmail = function(string) {
|
||||
|
@ -227,6 +227,7 @@ Ox.parseURL = (function() {
|
|||
};
|
||||
}());
|
||||
|
||||
// FIXME: can we get rid of this?
|
||||
Ox.parseUserAgent = function(userAgent) {
|
||||
var aliases = {
|
||||
browser: {
|
||||
|
@ -368,13 +369,13 @@ Ox.parseUserAgent = function(userAgent) {
|
|||
Ox.repeat <f> Repeat a value multiple times
|
||||
Works for arrays, numbers and strings
|
||||
> Ox.repeat(1, 3)
|
||||
"111"
|
||||
> Ox.repeat("foo", 3)
|
||||
"foofoofoo"
|
||||
'111'
|
||||
> Ox.repeat('foo', 3)
|
||||
'foofoofoo'
|
||||
> Ox.repeat([1, 2], 3)
|
||||
[1, 2, 1, 2, 1, 2]
|
||||
> Ox.repeat([{k: "v"}], 3)
|
||||
[{k: "v"}, {k: "v"}, {k: "v"}]
|
||||
> Ox.repeat([{k: 'v'}], 3)
|
||||
[{k: 'v'}, {k: 'v'}, {k: 'v'}]
|
||||
@*/
|
||||
Ox.repeat = function(value, times) {
|
||||
var ret;
|
||||
|
@ -522,7 +523,7 @@ Ox.words <f> Splits a string into words, removing punctuation
|
|||
(string) -> <[s]> Array of words
|
||||
string <s> Any string
|
||||
> Ox.words('Let\'s "split" array-likes into key/value pairs--okay?')
|
||||
["let's", "split", "array-likes", "into", "key", "value", "pairs", "okay"]
|
||||
['let's', 'split', 'array-likes', 'into', 'key', 'value', 'pairs', 'okay']
|
||||
@*/
|
||||
Ox.words = function(string) {
|
||||
var array = string.toLowerCase().split(/\b/),
|
||||
|
|
Loading…
Reference in a new issue