1515 * @public
1616 */
1717
18- const format = function ( ...replacements ) {
18+ Object . defineProperty ( String . prototype , 'format' , {
19+ 'enumerable' : false ,
20+ value ( ) {
1921
20- let value = this ;
22+ 'use strict' ;
2123
22- ( value . match ( / ( % [ s i d f ] ) / g) || [ ] ) . forEach ( ( match , key ) => {
24+ let value = this ;
25+ const replacements = Array . prototype . slice . call ( arguments ) ;
2326
24- if ( typeof replacements [ key ] !== 'undefined' ) {
27+ ( value . match ( / ( % [ s i d f ] ) / g ) || [ ] ) . forEach ( ( match , key ) => {
2528
26- if ( match === '%i' || match === '%d ') {
29+ if ( typeof replacements [ key ] !== 'undefined ') {
2730
28- replacements [ key ] = parseInt ( replacements [ key ] , 10 ) ;
31+ if ( match === '%i' || match === '%d' ) {
2932
30- } else if ( match === '%f' ) {
33+ replacements [ key ] = parseInt ( replacements [ key ] , 10 ) ;
3134
32- replacements [ key ] = parseFloat ( replacements [ key ] ) ;
35+ } else if ( match === '%f' ) {
3336
34- }
37+ replacements [ key ] = parseFloat ( replacements [ key ] ) ;
3538
36- value = value . replace ( match , replacements [ key ] ) ;
39+ }
3740
38- }
41+ value = value . replace ( match , replacements [ key ] ) ;
3942
40- } ) ;
43+ }
4144
42- return value ;
45+ } ) ;
4346
44- } ;
47+ return value ;
4548
46- Object . defineProperty ( String . prototype , 'format' , {
47- 'enumerable' : false ,
48- 'value' : format
49+ }
4950} ) ;
5051
5152/**
@@ -57,21 +58,21 @@ Object.defineProperty(String.prototype, 'format', {
5758 * @public
5859 */
5960
60- const chunk = function ( num ) {
61+ Object . defineProperty ( Array . prototype , 'chunk' , {
62+ 'enumerable' : false ,
63+ value ( num ) {
6164
62- const array = [ ] ;
65+ 'use strict' ;
6366
64- while ( this . length ) {
67+ const array = [ ] ;
6568
66- array . push ( this . splice ( 0 , num ) ) ;
69+ while ( this . length ) {
6770
68- }
71+ array . push ( this . splice ( 0 , num ) ) ;
6972
70- return array ;
73+ }
7174
72- } ;
75+ return array ;
7376
74- Object . defineProperty ( Array . prototype , 'chunk' , {
75- 'enumerable' : false ,
76- 'value' : chunk
77+ }
7778} ) ;
0 commit comments