Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const trim = util.trim; | ||
const randomId = util.randomId; | ||
const each = util.each; | ||
|
||
const tests = [ | ||
' ', | ||
randomId(1000), | ||
` ${randomId(1000)} `, | ||
` ${randomId(1000, ' \n\r\t\f\v')}` | ||
]; | ||
|
||
benchmark({ | ||
trim() { | ||
each(tests, test => trim(test) === ''); | ||
}, | ||
licia() { | ||
each(tests, test => isStrBlank(test)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,7 @@ | |
"isSet", | ||
"isSorted", | ||
"isStr", | ||
"isStrBlank", | ||
"isStream", | ||
"isSymbol", | ||
"isTypedArr", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## CN | ||
|
||
检查字符串是否为空。 | ||
|
||
|参数名|说明| | ||
|-----|---| | ||
|str|要检查的字符串| | ||
|返回值|如果字符串为空,返回真| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Check if string is blank. | ||
* | ||
* |Name |Desc | | ||
* |------|-----------------------| | ||
* |str |String to check | | ||
* |return|True if string is blank| | ||
*/ | ||
|
||
/* example | ||
* isStrBlank('licia'); // -> false | ||
* isStrBlank(''); // -> true | ||
* isStrBlank(' '); // -> true | ||
* isStrBlank('\r\n '); // -> true | ||
*/ | ||
|
||
/* module | ||
* env: all | ||
*/ | ||
|
||
/* typescript | ||
* export declare function isStrBlank(str: string): boolean; | ||
*/ | ||
|
||
exports = function(str) { | ||
for (let i = 0, len = str.length; i < len; i++) { | ||
const c = str[i]; | ||
if ( | ||
c !== ' ' && | ||
c !== '\n' && | ||
c !== '\r' && | ||
c !== '\t' && | ||
c !== '\f' && | ||
c !== '\v' | ||
) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
tests([ | ||
['licia', false], | ||
['', true], | ||
[' ', true], | ||
['\r\n ', true] | ||
]); |