Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADITO_Update_Upgrade
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
ADITO_Update_Upgrade
Commits
4e76d261
Commit
4e76d261
authored
4 years ago
by
Sebastian Listl
Browse files
Options
Downloads
Patches
Plain Diff
Added function Utils.parseBoolean
parent
0a2e509e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Util_lib/process.js
+31
-15
31 additions, 15 deletions
process/Util_lib/process.js
with
31 additions
and
15 deletions
process/Util_lib/process.js
+
31
−
15
View file @
4e76d261
...
...
@@ -134,56 +134,72 @@ Utils.isEqual = function (pFirstObject, pSecondObject)
/**
* Checks if the given value is a function.
*
* @param {Object} p
Object
the value to check
* @param {Object} p
Value
the value to check
* @return {Boolean} true if the value is a function
*/
Utils
.
isFunction
=
function
(
p
Object
)
Utils
.
isFunction
=
function
(
p
Value
)
{
return
typeof
p
Object
===
"
function
"
;
return
typeof
p
Value
===
"
function
"
;
}
/**
* Checks if the given value is a string.
*
* @param {Object} p
Object
the value to check
* @param {Object} p
Value
the value to check
* @return {Boolean} true if the value is a string
*/
Utils
.
isString
=
function
(
p
Object
)
Utils
.
isString
=
function
(
p
Value
)
{
return
typeof
p
Object
===
"
string
"
;
return
typeof
p
Value
===
"
string
"
;
}
/**
* Checks if the given value is a number.
*
* @param {Object} p
Object
the value to check
* @param {Object} p
Value
the value to check
* @return {Boolean} true if the value is a number
*/
Utils
.
isNumber
=
function
(
p
Object
)
Utils
.
isNumber
=
function
(
p
Value
)
{
return
typeof
p
Object
===
"
number
"
;
return
typeof
p
Value
===
"
number
"
;
}
/**
* Checks if the given value is an object. Be careful, null is also considered "object".
*
* @param {Object} p
Object
the value to check
* @param {Object} p
Value
the value to check
* @return {Boolean} true if the value is an object
*/
Utils
.
isObject
=
function
(
p
Object
)
Utils
.
isObject
=
function
(
p
Value
)
{
return
typeof
p
Object
===
"
object
"
;
return
typeof
p
Value
===
"
object
"
;
}
/**
* Checks if the given value is a boolean.
*
* @param {Object} p
Object
the value to check
* @param {Object} p
Value
the value to check
* @return {Boolean} true if the value is a boolean
*/
Utils
.
isBoolean
=
function
(
p
Object
)
Utils
.
isBoolean
=
function
(
p
Value
)
{
return
typeof
pObject
===
"
boolean
"
;
return
typeof
pValue
===
"
boolean
"
;
}
/**
* Parses the given value to Boolean, this can be used to check for stringified Booleans. These rules apply:
* <ul>
* <li>If the value is either falsy, the string "false" or the string "0", false is returned</li>
* <li>If the valueOf method of the value returns a falsy value, false is returned
* (this is to make sure the function returns false for weird stuff like 'new Boolean(false)')</li>
* <li>Every other value results in true</li>
*
* @param {String|Object} pValue the value to parse
* @return {Boolean} a real boolean
*/
Utils
.
parseBoolean
=
function
(
pValue
)
{
return
!
(
!
pValue
||
pValue
===
"
0
"
||
pValue
===
"
false
"
||
!
(
pValue
.
valueOf
()));
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment