<commit_before>/*
 * PersianInputMask v0.1.0
 * https://github.com/jalalazimi/persianMask.js
 * MIT licensed
 *
 * Copyright (C) 2015 <NAME>
 */

(function ($) {

    var VERSION = "0.1.0",
        //Check for nodeJS
        hasModule = (typeof module !== 'undefined' && module.exports);

    //used for prototype.
    function PersianMask(str) {
        this._str = str;
    }
    
    /**
     * Used for set comma
     *
     * @param {Number} value
     * @return {String} Returns Converted string
     * @api private
     */
    function _setComma(value) {
        if (!value) {
            return;
        }
        value = "" + value;
            value = _persianInt(value);
        if (value)
            while (/(\d+)(\d{3})/.test(value))
                value = value.replace(/(\d+)(\d{3})/, "$1,$2");
        return value
    }

    /**
     * Used for convert persian number to English number
     *
     * @param {String} value
     * @return {String} Returns Converted string
     * @api private
     */
    function _persianInt(value) {
        var numberDictionary = {
                "۱": "1",
                "۲": "2",
                "۳": "3",
                "۴": "4",
                "۵": "5",
                "۶": "6",
                "۷": "7",
                "۸": "8",
                "۹": "9",
                "۰": "0",
                "/": "."
            }
            , result = "";
        if (value != null && value != undefined) {
            var numberString = value.toString();
            for (var i = 0; i < numberString.length; i++) {
                var setNumber = numberDictionary[numberString.charAt(i)];
                setNumber ? result += setNumber : result += numberString.charAt(i)
            }
        }
        return result
    }





    var persianMask = function (inputValue) {
        if (inputValue == "" || inputValue == null)
        	return null;
        return new PersianMask(inputValue);
    }

    //persianMask Version
    persianMask.version = VERSION;

    persianMask.fn = PersianMask.prototype = {
        clone: function () {
            return persianMask(this);
        },
        value: function () {
            return this._str;
        },
        toString: function () {
            return this._str.toString();
        },
        set : function (value) {
            this._str = String(value);
            return this;
        },
        setComma: function () {
            return _setComma(this);
        }
    };

    //CommonJS module
    if (hasModule) {
        module.exports = persianMask;
    }
    //global ender:false
    if (typeof ender === 'undefined') {
        this['persianMask'] = persianMask;
    }
    //global define:false
    if (typeof define === 'function' && define.amd) {
        define('persianMask', [], function () {
            return persianMask;
        });
    }


})();<commit_msg>set value condition on persianInt function<commit_after>/*
 * PersianInputMask v0.1.0
 * https://github.com/jalalazimi/persianMask.js
 * MIT licensed
 *
 * Copyright (C) 2015 <NAME>
 */

(function($) {

    var VERSION = "0.1.0",
        //Check for nodeJS
        hasModule = (typeof module !== 'undefined' && module.exports);


    var arabicNumbers = ["١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩", "٠"],
        persianNumbers = ["۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "۰"],
        englishNumbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
        persianChar = ["ض", "ص", "ث", "ق", "ف", "غ", "ع", "ه", "خ", "ح", "ج", "چ", "ش", "س", "ی", "ب", "ل", "ا", "ت", "ن", "م", "ک", "گ", "ظ", "ط", "ز", "ر", "ذ", "د", "پ", "و", "؟"],
        englishChar = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "z", "x", "c", "v", "b", "n", "m", ",", "?"],
        arabicChars = ["ي", "ك", "‍", "دِ", "بِ", "زِ", "ذِ", "ِشِ", "ِسِ", "‌", "ى"],
        persianChars = ["ی", "ک", "", "د", "ب", "ز", "ذ", "ش", "س", "", "ی"];


    //used for prototype.
    function PersianMask(str) {
        this._str = str;
    }

    /**
     * Used for set comma
     *
     * @param {Number} value
     * @return {String} Returns Converted string
     * @api private
     */
    function _setComma(value) {
        if (!value) return;
        value = _persianNumber(value);
        while (/(\d+)(\d{3})/.test(value))
            value = value.replace(/(\d+)(\d{3})/, "$1,$2");
        return value
    }

    /**
     * Used for convert persian number to English number
     *
     * @param {String} value
     * @return {String} Returns Converted string
     * @api private
     */
    function _persianNumber(value) {
        if (!value) return;
        var numberDictionary = {
                "۱": "1",
                "۲": "2",
                "۳": "3",
                "۴": "4",
                "۵": "5",
                "۶": "6",
                "۷": "7",
                "۸": "8",
                "۹": "9",
                "۰": "0",
                "/": "."
            },
            result = "";
        var numberString = value.toString();
        for (var i = 0; i < numberString.length; i++) {
            var setNumber = numberDictionary[numberString.charAt(i)];
            setNumber ? result += setNumber : result += numberString.charAt(i)
        }
        return result
    }





    var persianMask = function(inputValue) {
        if (inputValue == "" || inputValue == null)
            return null;
        return new PersianMask(inputValue);
    }

    //persianMask Version
    persianMask.version = VERSION;

    persianMask.fn = PersianMask.prototype = {
        clone: function() {
            return persianMask(this);
        },
        value: function() {
            return this._str;
        },
        toString: function() {
            return this._str.toString();
        },
        set: function(value) {
            this._str = String(value);
            return this;
        },
        setComma: function() {
            return _setComma(this);
        }
    };

    //CommonJS module
    if (hasModule) {
        module.exports = persianMask;
    }
    //global ender:false
    if (typeof ender === 'undefined') {
        this['persianMask'] = persianMask;
    }
    //global define:false
    if (typeof define === 'function' && define.amd) {
        define('persianMask', [], function() {
            return persianMask;
        });
    }


})();
{'fraction_non_alphanumeric': 0.18641169154228857, 'fraction_numerical': 0.01554726368159204, 'mean_word_length': 1.6267864434463046, 'pattern_counts': {'":': 22, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4842660', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2070, 'n_words': 505}