source: node_modules/ramda/es/identical.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import _objectIs from "./internal/_objectIs.js";
2/**
3 * Returns true if its arguments are identical, false otherwise. Values are
4 * identical if they reference the same memory. `NaN` is identical to `NaN`;
5 * `0` and `-0` are not identical.
6 *
7 * Note this is merely a curried version of ES6 `Object.is`.
8 *
9 * `identical` does not support the `__` placeholder.
10 *
11 * @func
12 * @memberOf R
13 * @since v0.15.0
14 * @category Relation
15 * @sig a -> a -> Boolean
16 * @param {*} a
17 * @param {*} b
18 * @return {Boolean}
19 * @example
20 *
21 * const o = {};
22 * R.identical(o, o); //=> true
23 * R.identical(1, 1); //=> true
24 * R.identical(1, '1'); //=> false
25 * R.identical([], []); //=> false
26 * R.identical(0, -0); //=> false
27 * R.identical(NaN, NaN); //=> true
28 */
29
30var identical = function (a, b) {
31 switch (arguments.length) {
32 case 0:
33 return identical;
34
35 case 1:
36 return function () {
37 return function unaryIdentical(_b) {
38 switch (arguments.length) {
39 case 0:
40 return unaryIdentical;
41
42 default:
43 return _objectIs(a, _b);
44 }
45 };
46 }();
47
48 default:
49 return _objectIs(a, b);
50 }
51}; // In order to support Cross-origin Window objects as arguments to identical,
52// it cannot be implemented as _curry2(_objectIs).
53// The reason is that _curry2 checks if a function argument is the placeholder __
54// by accessing a paritcular property. However, across URL origins access
55// to most properties of Window is forbidden.
56
57
58export default identical;
Note: See TracBrowser for help on using the repository browser.