Skip to content

Commit

Permalink
Use "has" utility instead of hasOwnProperty
Browse files Browse the repository at this point in the history
commit_hash:e8a84da4c5255037894ff3446008b08108408346
  • Loading branch information
sabio committed Oct 22, 2024
1 parent b875659 commit 2358e59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/storage/global/global.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { yaNamespace } from 'src/const';
import { isUndefined } from 'src/utils/object/assertions';
import { hasOwnProperty } from 'src/utils/object/has';
import { has } from 'src/utils/object/has';

export type GlobalStorage = {
setSafe<T>(name: string, value: T): GlobalStorage;
Expand All @@ -25,7 +25,7 @@ export const globalStorage = (ctx: Window): GlobalStorage => {

return {
setSafe<T>(name: string, value: T): GlobalStorage {
if (!hasOwnProperty.call(storage, name)) {
if (!has(storage, name)) {
storage[name] = value;
}
return this;
Expand All @@ -36,7 +36,7 @@ export const globalStorage = (ctx: Window): GlobalStorage => {
},
getVal<T>(name: string, defVal?: T): T {
const val = storage[name] as T;
if (!hasOwnProperty.call(storage, name) && !isUndefined(defVal)) {
if (!has(storage, name) && !isUndefined(defVal)) {
return defVal;
}
return val;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/object/has.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isNil } from './assertions';

export const { hasOwnProperty } = Object.prototype;
const { hasOwnProperty } = Object.prototype;

export const has = (
object: any,
Expand Down

0 comments on commit 2358e59

Please sign in to comment.