Skip to content

Commit 11bdb13

Browse files
Merge pull request #7987 from getkirby/refact/ts-object-helper
refact: Migrate `$helper.object` to TypeScript
2 parents e5f1b15 + 59e162b commit 11bdb13

File tree

21 files changed

+181
-155
lines changed

21 files changed

+181
-155
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
return [
4-
'source' => 'panel/src/helpers/object.js'
4+
'source' => 'panel/src/helpers/object.ts'
55
];

panel/src/api/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { responder, safeFetch } from "@/panel/request.js";
2-
import { toLowerKeys } from "@/helpers/object.js";
2+
import { toLowerKeys } from "@/helpers/object";
33
import { ltrim, rtrim } from "@/helpers/string";
44

55
export default (api) => {

panel/src/components/Dialogs/Elements/Buttons.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
</template>
77

88
<script>
9-
import { isObject } from "@/helpers/object.js";
10-
119
export const props = {
1210
props: {
1311
/**
@@ -94,7 +92,7 @@ export default {
9492
return false;
9593
}
9694
97-
if (isObject(button) === false) {
95+
if (this.$helper.object.isObject(button) === false) {
9896
return defaults;
9997
}
10098

panel/src/helpers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import isComponent from "./isComponent";
1010
import isUploadEvent from "./isUploadEvent";
1111
import keyboard from "./keyboard";
1212
import link from "./link.js";
13-
import object from "./object.js";
13+
import object from "./object";
1414
import page from "./page.js";
1515
import ratio from "./ratio.js";
1616
import sort from "./sort.js";

panel/src/helpers/link.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { length } from "./object.js";
2+
import { length } from "./object";
33
import link from "./link.js";
44

55
// mock $t() function
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { clone } from "./object.js";
2+
import { clone } from "./object";
33

44
describe.concurrent("$helper.object.clone()", () => {
55
it("should clone an object", () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { isEmpty } from "./object.js";
2+
import { isEmpty } from "./object";
33

44
describe.concurrent("$helper.object.isEmpty()", () => {
55
it("should detect empty values as true", () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, it } from "vitest";
22
import { isObject } from "./object";
33

4-
describe.concurrent("isObject", () => {
4+
describe.concurrent("$helper.object.isObject()", () => {
55
it("returns true for an object", () => {
66
expect(isObject({})).toBe(true);
77
expect(isObject({ a: 1, b: 2 })).toBe(true);

panel/src/helpers/object.js

Lines changed: 0 additions & 126 deletions
This file was deleted.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { describe, expect, it } from "vitest";
2-
import object from "./object.js";
2+
import { length } from "./object";
33

4-
describe("$helper.object.merge", () => {
4+
describe("$helper.object.length()", () => {
55
it("should count object props", () => {
6-
const result = object.length({
6+
const result = length({
77
a: "a",
88
b: "b",
99
c: "c"
@@ -13,17 +13,17 @@ describe("$helper.object.merge", () => {
1313
});
1414

1515
it("should work with empty objects", () => {
16-
const result = object.length({});
16+
const result = length({});
1717
expect(result).toStrictEqual(0);
1818
});
1919

2020
it("should work with undefined objects", () => {
21-
const result = object.length();
21+
const result = length();
2222
expect(result).toStrictEqual(0);
2323
});
2424

2525
it("should also work with arrays", () => {
26-
const result = object.length(["a", "b", "c"]);
26+
const result = length(["a", "b", "c"]);
2727

2828
expect(result).toStrictEqual(3);
2929
});

0 commit comments

Comments
 (0)