Skip to content

Commit

Permalink
fix: minor changes to pub release
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Jun 29, 2023
1 parent ef8bd67 commit 0984287
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/utils/object-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export function setObjectPathProperty(
key: string,
value: unknown,
) {
const dotIndex = key.indexOf('.');
const currentKey = dotIndex === -1 ?
const index = key.indexOf('.');
const currentKey = index === -1 ?
key :
key.substring(0, dotIndex);
key.substring(0, index);

if (dotIndex === -1) {
if (index === -1) {
record[currentKey] = value;
return;
}
Expand All @@ -33,12 +33,12 @@ export function setObjectPathProperty(
}

export function hasObjectPathProperty(data: ObjectLiteral, key: string) : boolean {
const dotIndex = key.indexOf('.');
const currentKey = dotIndex === -1 ?
const index = key.indexOf('.');
const currentKey = index === -1 ?
key :
key.substring(0, dotIndex);
key.substring(0, index);

if (dotIndex === -1) {
if (index === -1) {
return !!hasOwnProperty(data, currentKey);
}

Expand All @@ -54,12 +54,12 @@ export function removeObjectPathProperty(
data: Record<string, any>,
key: string,
) {
const dotIndex = key.indexOf('.');
const currentKey = dotIndex === -1 ?
const index = key.indexOf('.');
const currentKey = index === -1 ?
key :
key.substring(0, dotIndex);
key.substring(0, index);

if (dotIndex === -1) {
if (index === -1) {
if (hasOwnProperty(data, currentKey)) {
delete data[currentKey];
}
Expand All @@ -76,12 +76,12 @@ export function removeObjectPathProperty(
}

export function getObjectPathProperty(data: Record<string, any>, key: string) : any {
const dotIndex = key.indexOf('.');
const currentKey = dotIndex === -1 ?
const index = key.indexOf('.');
const currentKey = index === -1 ?
key :
key.substring(0, dotIndex);
key.substring(0, index);

if (dotIndex === -1) {
if (index === -1) {
return data[currentKey];
}

Expand Down

0 comments on commit 0984287

Please sign in to comment.