🌐 AI搜索 & 代理 主页
Skip to content

Commit 228ad2a

Browse files
committed
feat: extend falsey values to include negative zero and BigInt zeros
feat: update falsey values to include BigInt zeros and negative zero
1 parent edadd45 commit 228ad2a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lodash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6961,7 +6961,7 @@
69616961

69626962
/**
69636963
* Creates an array with all falsey values removed. The values `false`, `null`,
6964-
* `0`, `""`, `undefined`, and `NaN` are falsey.
6964+
* `0`, `-0', '0n`, `""`, `undefined`, and `NaN` are falsey.
69656965
*
69666966
* @static
69676967
* @memberOf _

test/test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@
163163
/** Used to provide falsey values to methods. */
164164
var falsey = [, null, undefined, false, 0, NaN, ''];
165165

166+
/** Used to provide extended falsey values including negative zero and BigInt zeros. */
167+
var falseyWithBigInt = falsey.concat(-0, BigInt(0));
168+
166169
/** Used to specify the emoji style glyph variant of characters. */
167170
var emojiVar = '\ufe0f';
168171

@@ -3171,17 +3174,17 @@
31713174
assert.expect(1);
31723175

31733176
var array = ['0', '1', '2'];
3174-
assert.deepEqual(_.compact(falsey.concat(array)), array);
3177+
assert.deepEqual(_.compact(falseyWithBigInt.concat(array)), array);
31753178
});
31763179

31773180
QUnit.test('should work when in-between lazy operators', function(assert) {
31783181
assert.expect(2);
31793182

31803183
if (!isNpm) {
3181-
var actual = _(falsey).thru(_.slice).compact().thru(_.slice).value();
3184+
var actual = _(falseyWithBigInt).thru(_.slice).compact().thru(_.slice).value();
31823185
assert.deepEqual(actual, []);
31833186

3184-
actual = _(falsey).thru(_.slice).push(true, 1).compact().push('a').value();
3187+
actual = _(falseyWithBigInt).thru(_.slice).push(true, 1).compact().push('a').value();
31853188
assert.deepEqual(actual, [true, 1, 'a']);
31863189
}
31873190
else {

0 commit comments

Comments
 (0)