mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Removed isNormal() because 'null == undefined' so 'null != value' is sufficient
This commit is contained in:
parent
1b811428e7
commit
f6a55898c7
13 changed files with 50 additions and 68 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { pString, pInt, isNormal } from 'Common/Utils';
|
||||
import { pString, pInt } from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
const ROOT = './',
|
||||
|
|
@ -365,7 +365,7 @@ export function admin(screenName) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function mailBox(folder, page = 1, search = '', threadUid = '') {
|
||||
page = isNormal(page) ? pInt(page) : 1;
|
||||
page = pInt(page, 1);
|
||||
search = pString(search);
|
||||
|
||||
let result = HASH_PREFIX + 'mailbox/';
|
||||
|
|
|
|||
|
|
@ -17,35 +17,23 @@ const
|
|||
},
|
||||
htmlspecialchars = str => (''+str).replace(/[&<>"']/g, m => htmlmap[m]);
|
||||
|
||||
/**
|
||||
* @param {*} value
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isNormal(value) {
|
||||
return undefined !== value && null !== value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(string|number)} value
|
||||
* @param {boolean=} includeZero = true
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isPosNumeric(value, includeZero = true) {
|
||||
return !isNormal(value)
|
||||
? false
|
||||
: includeZero
|
||||
? /^[0-9]*$/.test(value.toString())
|
||||
: /^[1-9]+[0-9]*$/.test(value.toString());
|
||||
return null != value && (includeZero ? /^[0-9]*$/ : /^[1-9]+[0-9]*$/).test(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} value
|
||||
* @param {number=} defaultValur = 0
|
||||
* @param {number=} defaultValue = 0
|
||||
* @returns {number}
|
||||
*/
|
||||
export function pInt(value, defaultValur = 0) {
|
||||
const result = isNormal(value) && value ? parseInt(value, 10) : defaultValur;
|
||||
return isNaN(result) ? defaultValur : result;
|
||||
export function pInt(value, defaultValue = 0) {
|
||||
value = parseInt(value, 10);
|
||||
return isNaN(value) || !isFinite(value) ? defaultValue : value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -53,7 +41,7 @@ export function pInt(value, defaultValur = 0) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function pString(value) {
|
||||
return isNormal(value) ? '' + value : '';
|
||||
return null != value ? '' + value : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,7 +89,7 @@ export function fakeMd5(len = 32) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function encodeHtml(text) {
|
||||
return isNormal(text) ? htmlspecialchars(text.toString()) : '';
|
||||
return null != text ? htmlspecialchars(text.toString()) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -722,11 +710,11 @@ export function folderListOptionsBuilder(
|
|||
const sDeepPrefix = '\u00A0\u00A0\u00A0';
|
||||
|
||||
bBuildUnvisible = undefined === bBuildUnvisible ? false : !!bBuildUnvisible;
|
||||
bSystem = !isNormal(bSystem) ? 0 < aSystem.length : bSystem;
|
||||
iUnDeep = !isNormal(iUnDeep) ? 0 : iUnDeep;
|
||||
fDisableCallback = isNormal(fDisableCallback) ? fDisableCallback : null;
|
||||
fVisibleCallback = isNormal(fVisibleCallback) ? fVisibleCallback : null;
|
||||
fRenameCallback = isNormal(fRenameCallback) ? fRenameCallback : null;
|
||||
bSystem = null == bSystem ? 0 < aSystem.length : bSystem;
|
||||
iUnDeep = null == iUnDeep ? 0 : iUnDeep;
|
||||
fDisableCallback = null != fDisableCallback ? fDisableCallback : null;
|
||||
fVisibleCallback = null != fVisibleCallback ? fVisibleCallback : null;
|
||||
fRenameCallback = null != fRenameCallback ? fRenameCallback : null;
|
||||
|
||||
if (!isArray(aDisabled)) {
|
||||
aDisabled = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue