ut2 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,41 +2,27 @@ import isSymbol from '../isSymbol.js';
2
2
  import toString from '../toString.js';
3
3
 
4
4
  function compareAsc(value, other) {
5
- if (isSymbol(value) && isSymbol(other)) {
6
- return 0;
7
- }
8
- if (isSymbol(value)) {
9
- return 1;
10
- }
11
- if (isSymbol(other)) {
12
- return -1;
13
- }
14
- var valStr = toString(value);
15
- var othStr = toString(other);
16
- if (valStr > othStr) {
5
+ var valueIsSymbol = isSymbol(value);
6
+ var otherIsSymbol = isSymbol(other);
7
+ var valueStr = toString(value);
8
+ var otherStr = toString(other);
9
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
17
10
  return 1;
18
11
  }
19
- if (valStr < othStr) {
12
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
20
13
  return -1;
21
14
  }
22
15
  return 0;
23
16
  }
24
17
  function compareDesc(value, other) {
25
- if (isSymbol(value) && isSymbol(other)) {
26
- return 0;
27
- }
28
- if (isSymbol(value)) {
29
- return -1;
30
- }
31
- if (isSymbol(other)) {
32
- return 1;
33
- }
34
- var valStr = toString(value);
35
- var othStr = toString(other);
36
- if (valStr > othStr) {
18
+ var valueIsSymbol = isSymbol(value);
19
+ var otherIsSymbol = isSymbol(other);
20
+ var valueStr = toString(value);
21
+ var otherStr = toString(other);
22
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
37
23
  return -1;
38
24
  }
39
- if (valStr < othStr) {
25
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
40
26
  return 1;
41
27
  }
42
28
  return 0;
@@ -9,6 +9,6 @@ var numberIsInteger = Number.isInteger;
9
9
  var numberIsSafeInteger = Number.isSafeInteger;
10
10
  var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
11
11
  var arrayAt = arrayProto.at;
12
- var VERSION = "1.3.0";
12
+ var VERSION = "1.3.2";
13
13
 
14
14
  export { FUNC_ERROR_TEXT, VERSION, argType, arrayAt, numberIsFinite, numberIsInteger, numberIsSafeInteger, objectGetOwnPropertySymbols, supportedArgumentsType };
package/es/isEqual.js CHANGED
@@ -14,7 +14,7 @@ function mapToArray(map) {
14
14
  map.forEach(function (value, key) {
15
15
  result.push([key, value]);
16
16
  });
17
- return orderBy(result, function (item) { return item[0]; });
17
+ return orderBy(result, [0, 1]);
18
18
  }
19
19
  function setToArray(set) {
20
20
  var result = [];
@@ -122,13 +122,14 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
122
122
  if (hasCustomizer) {
123
123
  var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
124
124
  if (compared !== undefined) {
125
- result = !!compared;
126
- break;
125
+ if (!compared) {
126
+ return false;
127
+ }
128
+ continue;
127
129
  }
128
130
  }
129
131
  if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
130
- result = false;
131
- break;
132
+ return false;
132
133
  }
133
134
  }
134
135
  }
@@ -144,23 +145,24 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
144
145
  if (hasCustomizer) {
145
146
  var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
146
147
  if (compared !== undefined) {
147
- result = !!compared;
148
- break;
148
+ if (!compared) {
149
+ return false;
150
+ }
151
+ continue;
149
152
  }
150
153
  }
151
154
  if (!(hasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
152
- result = false;
153
- break;
155
+ return false;
154
156
  }
155
157
  if (!skipCtor && key === 'constructor') {
156
158
  skipCtor = true;
157
159
  }
158
160
  }
159
- if (result && !skipCtor) {
161
+ if (!skipCtor) {
160
162
  var valCtor = value.constructor;
161
163
  var othCtor = other.constructor;
162
164
  if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
163
- result = false;
165
+ return false;
164
166
  }
165
167
  }
166
168
  }
@@ -4,41 +4,27 @@ var isSymbol = require('../isSymbol.js');
4
4
  var toString = require('../toString.js');
5
5
 
6
6
  function compareAsc(value, other) {
7
- if (isSymbol(value) && isSymbol(other)) {
8
- return 0;
9
- }
10
- if (isSymbol(value)) {
11
- return 1;
12
- }
13
- if (isSymbol(other)) {
14
- return -1;
15
- }
16
- var valStr = toString(value);
17
- var othStr = toString(other);
18
- if (valStr > othStr) {
7
+ var valueIsSymbol = isSymbol(value);
8
+ var otherIsSymbol = isSymbol(other);
9
+ var valueStr = toString(value);
10
+ var otherStr = toString(other);
11
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
19
12
  return 1;
20
13
  }
21
- if (valStr < othStr) {
14
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
22
15
  return -1;
23
16
  }
24
17
  return 0;
25
18
  }
26
19
  function compareDesc(value, other) {
27
- if (isSymbol(value) && isSymbol(other)) {
28
- return 0;
29
- }
30
- if (isSymbol(value)) {
31
- return -1;
32
- }
33
- if (isSymbol(other)) {
34
- return 1;
35
- }
36
- var valStr = toString(value);
37
- var othStr = toString(other);
38
- if (valStr > othStr) {
20
+ var valueIsSymbol = isSymbol(value);
21
+ var otherIsSymbol = isSymbol(other);
22
+ var valueStr = toString(value);
23
+ var otherStr = toString(other);
24
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
39
25
  return -1;
40
26
  }
41
- if (valStr < othStr) {
27
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
42
28
  return 1;
43
29
  }
44
30
  return 0;
@@ -11,4 +11,4 @@ exports.numberIsInteger = Number.isInteger;
11
11
  exports.numberIsSafeInteger = Number.isSafeInteger;
12
12
  exports.objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
13
13
  exports.arrayAt = native.arrayProto.at;
14
- exports.VERSION = "1.3.0";
14
+ exports.VERSION = "1.3.2";
package/lib/isEqual.js CHANGED
@@ -16,7 +16,7 @@ function mapToArray(map) {
16
16
  map.forEach(function (value, key) {
17
17
  result.push([key, value]);
18
18
  });
19
- return orderBy(result, function (item) { return item[0]; });
19
+ return orderBy(result, [0, 1]);
20
20
  }
21
21
  function setToArray(set) {
22
22
  var result = [];
@@ -124,13 +124,14 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
124
124
  if (hasCustomizer) {
125
125
  var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
126
126
  if (compared !== undefined) {
127
- result = !!compared;
128
- break;
127
+ if (!compared) {
128
+ return false;
129
+ }
130
+ continue;
129
131
  }
130
132
  }
131
133
  if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
132
- result = false;
133
- break;
134
+ return false;
134
135
  }
135
136
  }
136
137
  }
@@ -146,23 +147,24 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
146
147
  if (hasCustomizer) {
147
148
  var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
148
149
  if (compared !== undefined) {
149
- result = !!compared;
150
- break;
150
+ if (!compared) {
151
+ return false;
152
+ }
153
+ continue;
151
154
  }
152
155
  }
153
156
  if (!(native.hasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
154
- result = false;
155
- break;
157
+ return false;
156
158
  }
157
159
  if (!skipCtor && key === 'constructor') {
158
160
  skipCtor = true;
159
161
  }
160
162
  }
161
- if (result && !skipCtor) {
163
+ if (!skipCtor) {
162
164
  var valCtor = value.constructor;
163
165
  var othCtor = other.constructor;
164
166
  if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
165
- result = false;
167
+ return false;
166
168
  }
167
169
  }
168
170
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -11,7 +11,7 @@
11
11
  * @returns {boolean} 如果值为 `buffer` ,返回 `true` ,否则返回 `false` 。
12
12
  * @example
13
13
  *
14
- * isBuffer(new Buffer(2)); // true
14
+ * isBuffer(Buffer.alloc(2)); // true
15
15
  *
16
16
  * isBuffer({}); // false
17
17
  *