@gvray/eskit
Version:
A rich and colorful toolkit about typescript and javascript.
37 lines • 1.18 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var isNil_1 = __importDefault(require("./isNil"));
/**
* Converts a value to a string representation.
* 将值转换为字符串表示。
*
* @param value - The value to convert / 要转换的值
* @returns The string representation, or empty string for null/undefined / 字符串表示,null/undefined返回空字符串
*
* @example
* ```typescript
* toString(123) // '123'
* toString('hello') // 'hello'
* toString(true) // 'true'
* toString(false) // 'false'
* toString([1, 2, 3]) // '1,2,3'
* toString({ a: 1 }) // '[object Object]'
* toString(new Date('2023-01-01')) // 'Sun Jan 01 2023...'
* toString(null) // ''
* toString(undefined) // ''
* toString(Symbol('test')) // 'Symbol(test)'
* toString(BigInt(123)) // '123'
* ```
*
* @since 1.0.0
*/
var toString = function (value) {
if ((0, isNil_1.default)(value))
return '';
return value.toString();
};
exports.default = toString;
//# sourceMappingURL=toString.js.map