@lite-v3/common-helpers
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,1 +0,9 @@ | ||
export default function thousandSeparator(numb: string, sparator?: string): string; | ||
interface ThousandSeparatorOption { | ||
/** | ||
* @default '.' | ||
*/ | ||
separator?: string; | ||
isReturnEmptyStringOnEmptyNumb?: boolean; | ||
} | ||
export default function thousandSeparator(numb: string, options?: ThousandSeparatorOption | string): string; | ||
export {}; |
@@ -6,10 +6,17 @@ "use strict"; | ||
exports.default = thousandSeparator; | ||
function thousandSeparator(numb) { | ||
var sparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '.'; | ||
function thousandSeparator(numb, options) { | ||
var _options = options; | ||
if (typeof _options === 'undefined') _options = {}; | ||
if (typeof _options === 'string') { | ||
_options = { | ||
separator: _options | ||
}; | ||
} | ||
var _separator = _options.separator, separator = _separator === void 0 ? '.' : _separator, isReturnEmptyStringOnEmptyNumb = _options.isReturnEmptyStringOnEmptyNumb; | ||
if (!numb) { | ||
return '0'; | ||
return isReturnEmptyStringOnEmptyNumb ? '' : '0'; | ||
} | ||
var num = numb.toString().replace(/\D/g, ''); | ||
if (num === '') { | ||
return '0'; | ||
return isReturnEmptyStringOnEmptyNumb ? '' : '0'; | ||
} | ||
@@ -19,4 +26,4 @@ if (num.length <= 3) { | ||
} | ||
var result = num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1".concat(sparator)); | ||
var result = num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1".concat(separator)); | ||
return result; // Return format 3.000.000 || 4.500 | ||
} |
{ | ||
"name": "@lite-v3/common-helpers", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Public common helpers for Tokopedia Web", | ||
@@ -47,3 +47,3 @@ "repository": { | ||
"@lite-v3/tsconfig": "^0.0.2", | ||
"@tokopedia/lite-testing": "^1.2.0", | ||
"@tokopedia/lite-testing": "^1.3.0", | ||
"@types/node": "^16.11.1", | ||
@@ -50,0 +50,0 @@ "lolex": "^4.1.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79772
2285