@@ -581,15 +581,21 @@ lib.objectFromPath = function(path, value) {
581581 * // returns '2016'
582582 *
583583 * @example
584+ * lib.numSeparate(3000, '.,', true);
585+ * // returns '3,000'
586+ *
587+ * @example
584588 * lib.numSeparate(1234.56, '|,')
585589 * // returns '1,234|56'
586590 *
587591 * @param {string|number } value the value to be converted
588592 * @param {string } separators string of decimal, then thousands separators
593+ * @param {boolean } separatethousands boolean, 4-digit integers are separated if true
589594 *
590595 * @return {string } the value that has been separated
591596 */
592- lib . numSeparate = function ( value , separators ) {
597+ lib . numSeparate = function ( value , separators , separatethousands ) {
598+ if ( ! separatethousands ) separatethousands = false ;
593599
594600 if ( typeof separators !== 'string' || separators . length === 0 ) {
595601 throw new Error ( 'Separator string required for formatting!' ) ;
@@ -608,7 +614,7 @@ lib.numSeparate = function(value, separators) {
608614 x2 = x . length > 1 ? decimalSep + x [ 1 ] : '' ;
609615
610616 // Years are ignored for thousands separators
611- if ( thouSep && ( x . length > 1 || x1 . length > 4 ) ) {
617+ if ( thouSep && ( x . length > 1 || x1 . length > 4 || separatethousands ) ) {
612618 while ( thousandsRe . test ( x1 ) ) {
613619 x1 = x1 . replace ( thousandsRe , '$1' + thouSep + '$2' ) ;
614620 }
0 commit comments