Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Enhance Consistency in Utility Functions: Naming #11339

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/__tests__/utils/set.test.ts
Expand Up @@ -25,31 +25,31 @@ describe('set', () => {
});

const test4 = { foo: { bar: 'baz' } };
expect(set(test4, 'foo.obj.key', 'test')).toEqual('test');
expect(set(test4, 'foo.object.key', 'test')).toEqual('test');
expect(test4).toEqual({
foo: {
bar: 'baz',
obj: { key: 'test' },
object: { key: 'test' },
},
});

const test5 = { foo: 1 };
expect(set(test5, 'foo.obj.key', 3)).toEqual(3);
expect(set(test5, 'foo.object.key', 3)).toEqual(3);
expect(test5).toEqual({
foo: {
obj: {
object: {
key: 3,
},
},
});

const test6 = {};
expect(set(test6, 'foo.arr[0].obj.key', 1)).toEqual(1);
expect(set(test6, 'foo.arr[0].object.key', 1)).toEqual(1);
expect(test6).toEqual({
foo: {
arr: [
{
obj: {
object: {
key: 1,
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/utils/unset.ts
Expand Up @@ -15,9 +15,9 @@ function baseGet(object: any, updatePath: (string | number)[]) {
return object;
}

function isEmptyArray(obj: unknown[]) {
for (const key in obj) {
if (obj.hasOwnProperty(key) && !isUndefined(obj[key])) {
function isEmptyArray(object: unknown[]) {
for (const key in object) {
if (object.hasOwnProperty(key) && !isUndefined(object[key])) {
return false;
}
}
Expand Down