Refactor Object.{groupBy,hasOwn}() transform (#19218)
This commit is contained in:
1 parent
6ec71b6463
commit
c018e68c5e
7 files changed
+90
-79
No files matched your search
@@ -28,21 +28,23 @@ const transform = (code) =>
|
||||
) +
|
||||
"\n";
|
||||
|
||||
test("Object.hasOwn", () => {
|
||||
test("Object.hasOwn()", () => {
|
||||
expect(transform("Object.hasOwn(foo, bar)")).toMatchInlineSnapshot(`
|
||||
"
|
||||
Object.prototype.hasOwnProperty.call(foo, bar);
|
||||
import __Object_hasOwn from "<SHIMS>/function-object-has-own.js";
|
||||
|
||||
__Object_hasOwn(foo, bar);
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
test("Object.groupBy", () => {
|
||||
test("Object.groupBy()", () => {
|
||||
expect(transform("const {} = Object.groupBy(foo, bar)"))
|
||||
.toMatchInlineSnapshot(`
|
||||
"
|
||||
import __objectGroupBy from "<SHIMS>/object-group-by.js";
|
||||
import __Object_groupBy from "<SHIMS>/function-object-group-by.js";
|
||||
|
||||
const {} = __objectGroupBy(foo, bar);
|
||||
const {} = __Object_groupBy(foo, bar);
|
||||
"
|
||||
`);
|
||||
});
|
||||
@@ -272,6 +274,7 @@ test("All", () => {
|
||||
`),
|
||||
).toMatchInlineSnapshot(`
|
||||
"
|
||||
import __Object_hasOwn from "<SHIMS>/function-object-has-own.js";
|
||||
import __replaceAll from "<SHIMS>/method-replace-all.js";
|
||||
import __at from "<SHIMS>/method-at.js";
|
||||
import __findLast from "<SHIMS>/method-find-last.js";
|
||||
@@ -284,7 +287,7 @@ test("All", () => {
|
||||
align,
|
||||
line
|
||||
} = __doc_builders;
|
||||
if (Object.prototype.hasOwnProperty.call(foo, bar)) {
|
||||
if (__Object_hasOwn(foo, bar)) {
|
||||
const a = __replaceAll(/* OPTIONAL_OBJECT: true */1, __at(/* OPTIONAL_OBJECT: true */1, foo, -1), /bar/, ""),
|
||||
b = __findLast(/* OPTIONAL_OBJECT: true */1, bar, () => true),
|
||||
c = __findLastIndex(/* OPTIONAL_OBJECT: false */0, foo, callback);
|
||||
|
||||
Reference in new issue
Block a user