UNPKG

1.44 kBJavaScriptView Raw
1import _curry1 from "./internal/_curry1.js";
2import _toString from "./internal/_toString.js";
3/**
4 * Returns the string representation of the given value. `eval`'ing the output
5 * should result in a value equivalent to the input value. Many of the built-in
6 * `toString` methods do not satisfy this requirement.
7 *
8 * If the given value is an `[object Object]` with a `toString` method other
9 * than `Object.prototype.toString`, this method is invoked with no arguments
10 * to produce the return value. This means user-defined constructor functions
11 * can provide a suitable `toString` method. For example:
12 *
13 * function Point(x, y) {
14 * this.x = x;
15 * this.y = y;
16 * }
17 *
18 * Point.prototype.toString = function() {
19 * return 'new Point(' + this.x + ', ' + this.y + ')';
20 * };
21 *
22 * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)'
23 *
24 * @func
25 * @memberOf R
26 * @since v0.14.0
27 * @category String
28 * @sig * -> String
29 * @param {*} val
30 * @return {String}
31 * @example
32 *
33 * R.toString(42); //=> '42'
34 * R.toString('abc'); //=> '"abc"'
35 * R.toString([1, 2, 3]); //=> '[1, 2, 3]'
36 * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}'
37 * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")'
38 */
39
40var toString =
41/*#__PURE__*/
42_curry1(function toString(val) {
43 return _toString(val, []);
44});
45
46export default toString;
\No newline at end of file