UNPKG

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