Skip to content

Commit 5b69af0

Browse files
committed
use null instead of undefined as an empty placeholder in some cases
1 parent 9cc1d63 commit 5b69af0

8 files changed

+21
-21
lines changed

packages/core-js/internals/collection-strong.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ module.exports = {
2323
setInternalState(that, {
2424
type: CONSTRUCTOR_NAME,
2525
index: create(null),
26-
first: undefined,
27-
last: undefined,
26+
first: null,
27+
last: null,
2828
size: 0
2929
});
3030
if (!DESCRIPTORS) that.size = 0;
@@ -49,7 +49,7 @@ module.exports = {
4949
key: key,
5050
value: value,
5151
previous: previous = state.last,
52-
next: undefined,
52+
next: null,
5353
removed: false
5454
};
5555
if (!state.first) state.first = entry;
@@ -83,10 +83,10 @@ module.exports = {
8383
var entry = state.first;
8484
while (entry) {
8585
entry.removed = true;
86-
if (entry.previous) entry.previous = entry.previous.next = undefined;
86+
if (entry.previous) entry.previous = entry.previous.next = null;
8787
entry = entry.next;
8888
}
89-
state.first = state.last = undefined;
89+
state.first = state.last = null;
9090
state.index = create(null);
9191
if (DESCRIPTORS) state.size = 0;
9292
else that.size = 0;
@@ -178,7 +178,7 @@ module.exports = {
178178
target: iterated,
179179
state: getInternalCollectionState(iterated),
180180
kind: kind,
181-
last: undefined
181+
last: null
182182
});
183183
}, function () {
184184
var state = getInternalIteratorState(this);
@@ -189,7 +189,7 @@ module.exports = {
189189
// get next entry
190190
if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
191191
// or finish the iteration
192-
state.target = undefined;
192+
state.target = null;
193193
return createIterResultObject(undefined, true);
194194
}
195195
// return step by kind

packages/core-js/internals/collection-weak.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
setInternalState(that, {
6363
type: CONSTRUCTOR_NAME,
6464
id: id++,
65-
frozen: undefined
65+
frozen: null
6666
});
6767
if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
6868
});
@@ -110,7 +110,7 @@ module.exports = {
110110
if (isObject(key)) {
111111
var data = getWeakData(key);
112112
if (data === true) return uncaughtFrozenStore(state).get(key);
113-
return data ? data[state.id] : undefined;
113+
if (data) return data[state.id];
114114
}
115115
},
116116
// `WeakMap.prototype.set(key, value)` method

packages/core-js/modules/es.array.iterator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
3737
var target = state.target;
3838
var index = state.index++;
3939
if (!target || index >= target.length) {
40-
state.target = undefined;
40+
state.target = null;
4141
return createIterResultObject(undefined, true);
4242
}
4343
switch (state.kind) {

packages/core-js/modules/es.promise.constructor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ if (FORCED_PROMISE_CONSTRUCTOR) {
220220
reactions: new Queue(),
221221
rejection: false,
222222
state: PENDING,
223-
value: undefined
223+
value: null
224224
});
225225
};
226226

packages/core-js/modules/esnext.async-disposable-stack.constructor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ defineBuiltIns(AsyncDisposableStackPrototype, {
7272
var loop = function () {
7373
if (i) {
7474
var disposeMethod = stack[--i];
75-
stack[i] = undefined;
75+
stack[i] = null;
7676
try {
7777
Promise.resolve(disposeMethod()).then(loop, handleError);
7878
} catch (error) {
7979
handleError(error);
8080
}
8181
} else {
82-
internalState.stack = undefined;
82+
internalState.stack = null;
8383
thrown ? reject(suppressed) : resolve(undefined);
8484
}
8585
};

packages/core-js/modules/esnext.disposable-stack.constructor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ defineBuiltIns(DisposableStackPrototype, {
5656
var suppressed;
5757
while (i) {
5858
var disposeMethod = stack[--i];
59-
stack[i] = undefined;
59+
stack[i] = null;
6060
try {
6161
disposeMethod();
6262
} catch (errorResult) {
@@ -68,7 +68,7 @@ defineBuiltIns(DisposableStackPrototype, {
6868
}
6969
}
7070
}
71-
internalState.stack = undefined;
71+
internalState.stack = null;
7272
if (thrown) throw suppressed;
7373
},
7474
use: function use(value) {

packages/core-js/modules/esnext.observable.constructor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ var getSubscriptionObserverInternalState = getterFor(SUBSCRIPTION_OBSERVER);
3030

3131
var SubscriptionState = function (observer) {
3232
this.observer = anObject(observer);
33-
this.cleanup = undefined;
34-
this.subscriptionObserver = undefined;
33+
this.cleanup = null;
34+
this.subscriptionObserver = null;
3535
};
3636

3737
SubscriptionState.prototype = {
3838
type: SUBSCRIPTION,
3939
clean: function () {
4040
var cleanup = this.cleanup;
4141
if (cleanup) {
42-
this.cleanup = undefined;
42+
this.cleanup = null;
4343
try {
4444
cleanup();
4545
} catch (error) {
@@ -53,10 +53,10 @@ SubscriptionState.prototype = {
5353
var subscriptionObserver = this.subscriptionObserver;
5454
subscription.closed = true;
5555
if (subscriptionObserver) subscriptionObserver.closed = true;
56-
} this.observer = undefined;
56+
} this.observer = null;
5757
},
5858
isClosed: function () {
59-
return this.observer === undefined;
59+
return this.observer === null;
6060
}
6161
};
6262

packages/core-js/modules/web.url-search-params.constructor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params
115115
var target = state.target;
116116
var index = state.index++;
117117
if (!target || index >= target.length) {
118-
state.target = undefined;
118+
state.target = null;
119119
return createIterResultObject(undefined, true);
120120
}
121121
var entry = target[index];

0 commit comments

Comments
 (0)