es-toolkit 1.18.0-dev.584 → 1.18.0-dev.585
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +15 -0
- package/dist/compat/index.mjs +1 -0
- package/dist/compat/string/toString.d.mts +19 -0
- package/dist/compat/string/toString.d.ts +19 -0
- package/dist/compat/string/toString.mjs +15 -0
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -161,6 +161,7 @@ export { endsWith } from './string/endsWith.mjs';
|
|
|
161
161
|
export { padStart } from './string/padStart.mjs';
|
|
162
162
|
export { padEnd } from './string/padEnd.mjs';
|
|
163
163
|
export { repeat } from './string/repeat.mjs';
|
|
164
|
+
export { toString } from './string/toString.mjs';
|
|
164
165
|
export { trim } from './string/trim.mjs';
|
|
165
166
|
export { trimStart } from './string/trimStart.mjs';
|
|
166
167
|
export { trimEnd } from './string/trimEnd.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -161,6 +161,7 @@ export { endsWith } from './string/endsWith.js';
|
|
|
161
161
|
export { padStart } from './string/padStart.js';
|
|
162
162
|
export { padEnd } from './string/padEnd.js';
|
|
163
163
|
export { repeat } from './string/repeat.js';
|
|
164
|
+
export { toString } from './string/toString.js';
|
|
164
165
|
export { trim } from './string/trim.js';
|
|
165
166
|
export { trimStart } from './string/trimStart.js';
|
|
166
167
|
export { trimEnd } from './string/trimEnd.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -1076,6 +1076,20 @@ function repeat(str, n) {
|
|
|
1076
1076
|
return str.repeat(n);
|
|
1077
1077
|
}
|
|
1078
1078
|
|
|
1079
|
+
function toString(value) {
|
|
1080
|
+
if (value == null) {
|
|
1081
|
+
return '';
|
|
1082
|
+
}
|
|
1083
|
+
if (Array.isArray(value)) {
|
|
1084
|
+
return value.map(toString).join(',');
|
|
1085
|
+
}
|
|
1086
|
+
const result = String(value);
|
|
1087
|
+
if (result === '0' && Object.is(Number(value), -0)) {
|
|
1088
|
+
return '-0';
|
|
1089
|
+
}
|
|
1090
|
+
return result;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1079
1093
|
function trim(str, chars, guard) {
|
|
1080
1094
|
if (str == null) {
|
|
1081
1095
|
return '';
|
|
@@ -1372,6 +1386,7 @@ exports.sortBy = sortBy;
|
|
|
1372
1386
|
exports.spread = spread;
|
|
1373
1387
|
exports.startCase = startCase;
|
|
1374
1388
|
exports.startsWith = startsWith;
|
|
1389
|
+
exports.toString = toString;
|
|
1375
1390
|
exports.trim = trim;
|
|
1376
1391
|
exports.trimEnd = trimEnd;
|
|
1377
1392
|
exports.trimStart = trimStart;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -161,6 +161,7 @@ export { endsWith } from './string/endsWith.mjs';
|
|
|
161
161
|
export { padStart } from './string/padStart.mjs';
|
|
162
162
|
export { padEnd } from './string/padEnd.mjs';
|
|
163
163
|
export { repeat } from './string/repeat.mjs';
|
|
164
|
+
export { toString } from './string/toString.mjs';
|
|
164
165
|
export { trim } from './string/trim.mjs';
|
|
165
166
|
export { trimStart } from './string/trimStart.mjs';
|
|
166
167
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts `value` to a string.
|
|
3
|
+
*
|
|
4
|
+
* An empty string is returned for `null` and `undefined` values.
|
|
5
|
+
* The sign of `-0` is preserved.
|
|
6
|
+
*
|
|
7
|
+
* @param {unknown} value - The value to convert.
|
|
8
|
+
* @returns {string} Returns the converted string.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* toString(null) // returns ''
|
|
12
|
+
* toString(undefined) // returns ''
|
|
13
|
+
* toString(-0) // returns '-0'
|
|
14
|
+
* toString([1, 2, -0]) // returns '1,2,-0'
|
|
15
|
+
* toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)'
|
|
16
|
+
*/
|
|
17
|
+
declare function toString(value?: unknown): string;
|
|
18
|
+
|
|
19
|
+
export { toString };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts `value` to a string.
|
|
3
|
+
*
|
|
4
|
+
* An empty string is returned for `null` and `undefined` values.
|
|
5
|
+
* The sign of `-0` is preserved.
|
|
6
|
+
*
|
|
7
|
+
* @param {unknown} value - The value to convert.
|
|
8
|
+
* @returns {string} Returns the converted string.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* toString(null) // returns ''
|
|
12
|
+
* toString(undefined) // returns ''
|
|
13
|
+
* toString(-0) // returns '-0'
|
|
14
|
+
* toString([1, 2, -0]) // returns '1,2,-0'
|
|
15
|
+
* toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)'
|
|
16
|
+
*/
|
|
17
|
+
declare function toString(value?: unknown): string;
|
|
18
|
+
|
|
19
|
+
export { toString };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function toString(value) {
|
|
2
|
+
if (value == null) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
return value.map(toString).join(',');
|
|
7
|
+
}
|
|
8
|
+
const result = String(value);
|
|
9
|
+
if (result === '0' && Object.is(Number(value), -0)) {
|
|
10
|
+
return '-0';
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { toString };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.18.0-dev.
|
|
4
|
+
"version": "1.18.0-dev.585+993b77f9",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|