mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
refactor(util) addNewLine, rmNewLine
This commit is contained in:
parent
ea50210887
commit
6653feb6f4
1 changed files with 10 additions and 10 deletions
20
lib/util.js
20
lib/util.js
|
|
@ -74,25 +74,25 @@
|
|||
* ad new line (if it's not)
|
||||
* @param {string} pText
|
||||
*/
|
||||
this.addNewLine = function(pText) {
|
||||
var lNewLine = '',
|
||||
n = pText && pText.length;
|
||||
this.addNewLine = function(text) {
|
||||
var newLine = '',
|
||||
n = text && text.length;
|
||||
|
||||
if(n && pText[n-1] !== '\n')
|
||||
lNewLine = '\n';
|
||||
if(n && text[n-1] !== '\n')
|
||||
newLine = '\n';
|
||||
|
||||
return pText + lNewLine;
|
||||
return text + newLine;
|
||||
};
|
||||
|
||||
/**
|
||||
* rm new line (if it's)
|
||||
* @param {string} pText
|
||||
*/
|
||||
this.rmNewLine = function(pText) {
|
||||
var strs = ['\n', '\r'],
|
||||
text = Util.removeStr(pText, strs);
|
||||
this.rmNewLine = function(text) {
|
||||
var strs = ['\n', '\r'],
|
||||
str = Util.removeStr(text, strs);
|
||||
|
||||
return text;
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue