@@ -204,6 +204,7 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi
204
204
setNonEnumerableProperty ( tuple , 'sort' , sort ) ;
205
205
setNonEnumerableProperty ( tuple , 'subtuple' , subtuple ) ;
206
206
setNonEnumerableProperty ( tuple , 'toJSON' , toJSON ) ;
207
+ setNonEnumerableProperty ( tuple , 'toLocaleString' , toLocaleString ) ;
207
208
setNonEnumerableProperty ( tuple , 'toString' , toString ) ;
208
209
209
210
return tuple ;
@@ -1198,7 +1199,33 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi
1198
1199
return out ;
1199
1200
}
1200
1201
1201
- // TODO: consider adding `toLocaleString()` in a manner similar to `toString()` below
1202
+ /**
1203
+ * Serializes a tuple as a locale-aware string.
1204
+ *
1205
+ * @private
1206
+ * @memberof tuple
1207
+ * @param {(string|string[]) } [locales] - locale(s)
1208
+ * @param {Object } [options] - formatting options
1209
+ * @throws {TypeError } `this` must be the host tuple
1210
+ * @returns {string } tuple locale string representation
1211
+ */
1212
+ function toLocaleString ( locales , options ) {
1213
+ var out = [ ] ;
1214
+ var val ;
1215
+ var i ;
1216
+ if ( this !== tuple ) { // eslint-disable-line no-invalid-this
1217
+ throw new TypeError ( 'invalid invocation. `this` is not host tuple.' ) ;
1218
+ }
1219
+ for ( i = 0 ; i < nfields ; i ++ ) {
1220
+ val = tuple [ indices [ i ] ] ;
1221
+ if ( val && typeof val . toLocaleString === 'function' ) {
1222
+ out . push ( val . toLocaleString ( locales , options ) ) ;
1223
+ } else {
1224
+ out . push ( String ( val ) ) ;
1225
+ }
1226
+ }
1227
+ return out . join ( ',' ) ;
1228
+ }
1202
1229
1203
1230
/**
1204
1231
* Serializes a tuple as a string.
0 commit comments