1 | var _curry1 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry1.js");
|
---|
4 |
|
---|
5 | var _isArguments =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_isArguments.js");
|
---|
8 |
|
---|
9 | var _isArray =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./internal/_isArray.js");
|
---|
12 |
|
---|
13 | var _isObject =
|
---|
14 | /*#__PURE__*/
|
---|
15 | require("./internal/_isObject.js");
|
---|
16 |
|
---|
17 | var _isString =
|
---|
18 | /*#__PURE__*/
|
---|
19 | require("./internal/_isString.js");
|
---|
20 |
|
---|
21 | var _isTypedArray =
|
---|
22 | /*#__PURE__*/
|
---|
23 | require("./internal/_isTypedArray.js");
|
---|
24 | /**
|
---|
25 | * Returns the empty value of its argument's type. Ramda defines the empty
|
---|
26 | * value of Array (`[]`), Object (`{}`), String (`''`),
|
---|
27 | * TypedArray (`Uint8Array []`, `Float32Array []`, etc), and Arguments. Other
|
---|
28 | * types are supported if they define `<Type>.empty`,
|
---|
29 | * `<Type>.prototype.empty` or implement the
|
---|
30 | * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
|
---|
31 | *
|
---|
32 | * Dispatches to the `empty` method of the first argument, if present.
|
---|
33 | *
|
---|
34 | * @func
|
---|
35 | * @memberOf R
|
---|
36 | * @since v0.3.0
|
---|
37 | * @category Function
|
---|
38 | * @sig a -> a
|
---|
39 | * @param {*} x
|
---|
40 | * @return {*}
|
---|
41 | * @example
|
---|
42 | *
|
---|
43 | * R.empty(Just(42)); //=> Nothing()
|
---|
44 | * R.empty([1, 2, 3]); //=> []
|
---|
45 | * R.empty('unicorns'); //=> ''
|
---|
46 | * R.empty({x: 1, y: 2}); //=> {}
|
---|
47 | * R.empty(Uint8Array.from('123')); //=> Uint8Array []
|
---|
48 | */
|
---|
49 |
|
---|
50 |
|
---|
51 | var empty =
|
---|
52 | /*#__PURE__*/
|
---|
53 | _curry1(function empty(x) {
|
---|
54 | return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments(x) ? function () {
|
---|
55 | return arguments;
|
---|
56 | }() : _isTypedArray(x) ? x.constructor.from('') : void 0 // else
|
---|
57 | ;
|
---|
58 | });
|
---|
59 |
|
---|
60 | module.exports = empty; |
---|