Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fd9a4f3
feat(named-typed-tuple): implement toLocaleString function
Gauravkaushik-1206 Sep 3, 2025
6591629
Discard changes to lib/node_modules/@stdlib/dstructs/named-typed-tupl…
kgryte Sep 3, 2025
2075abe
fix: update `fromIndex` handling in `blas/ext/base/ndarray/slast-inde…
headlessNode Sep 3, 2025
d86f3ef
fix: update `fromIndex` handling in `blas/ext/base/ndarray/glast-inde…
headlessNode Sep 3, 2025
65c9403
feat: add argument validation to toLocaleString
Gauravkaushik-1206 Sep 3, 2025
09c587f
feat: changed copyright year to 2025
Gauravkaushik-1206 Sep 5, 2025
e63aa17
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
c4eda5f
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
f97d9f8
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
0c57f34
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
71ef02d
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
5ab6214
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
27dfeaa
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/gla…
kgryte Sep 7, 2025
ba670f7
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
8951632
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
9f98254
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
30c2f33
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
f894a17
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
28ed5ca
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
fbcae92
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/sla…
kgryte Sep 7, 2025
5eb4b37
Merge remote-tracking branch 'upstream/develop' into fix-tolocale-string
stdlib-bot Sep 7, 2025
23b2e2b
Apply suggestions from code review
kgryte Sep 7, 2025
b38c3a9
fix: change to custom serialization instead of array-style serialization
Gauravkaushik-1206 Sep 7, 2025
8f2650c
docs: fix missing declaration
kgryte Sep 7, 2025
7fa7688
docs: fix missing declaration
kgryte Sep 7, 2025
15c46bf
refactor: rename variable
kgryte Sep 7, 2025
ee7116d
test: update description
kgryte Sep 8, 2025
0fde4ab
test: remove test
kgryte Sep 8, 2025
95fdf7f
test: remove tests
kgryte Sep 8, 2025
1d807f3
test: update description
kgryte Sep 8, 2025
dbce613
test: update test value
kgryte Sep 8, 2025
272428a
test: rename variable and update test messages
kgryte Sep 8, 2025
b4a0d74
test: reorder tests
kgryte Sep 8, 2025
17daba7
test: update message
kgryte Sep 8, 2025
885162e
Merge remote-tracking branch 'upstream/develop' into fix-tolocale-string
stdlib-bot Sep 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ console.log( p.orderedFields );
// Serialize the tuple as a string:
console.log( p.toString() );

// Serialize the tuple as a locale string
console.log( p.toLocaleString() );

// Serialize the tuple a JSON string:
console.log( JSON.stringify( p ) );
29 changes: 28 additions & 1 deletion lib/node_modules/@stdlib/dstructs/named-typed-tuple/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi
setNonEnumerableProperty( tuple, 'sort', sort );
setNonEnumerableProperty( tuple, 'subtuple', subtuple );
setNonEnumerableProperty( tuple, 'toJSON', toJSON );
setNonEnumerableProperty( tuple, 'toLocaleString', toLocaleString );
setNonEnumerableProperty( tuple, 'toString', toString );

return tuple;
Expand Down Expand Up @@ -1198,7 +1199,33 @@ function factory( names, options ) { // eslint-disable-line max-lines-per-functi
return out;
}

// TODO: consider adding `toLocaleString()` in a manner similar to `toString()` below
/**
* Serializes a tuple as a locale-aware string.
*
* @private
* @memberof tuple
* @param {(string|string[])} [locales] - locale(s)
* @param {Object} [options] - formatting options
* @throws {TypeError} `this` must be the host tuple
* @returns {string} tuple locale string representation
*/
function toLocaleString( locales, options ) {
var out = [];
var val;
var i;
if ( this !== tuple ) { // eslint-disable-line no-invalid-this
throw new TypeError( 'invalid invocation. `this` is not host tuple.' );
}
for ( i = 0; i < nfields; i++ ) {
val = tuple[ indices[ i ] ];
if ( val && typeof val.toLocaleString === 'function' ) {
out.push( val.toLocaleString( locales, options ) );
} else {
out.push( String( val ) );
}
}
return out.join(',');
}

/**
* Serializes a tuple as a string.
Expand Down
Loading