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