Skip to content

Commit 3081134

Browse files
committedJan 29, 2024
refac(utils): Refactoring objectHasOwnProperty
1 parent 4abee1e commit 3081134

9 files changed

+18
-16
lines changed
 

‎dist/purify.cjs.js

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const stringMatch = unapply(String.prototype.match);
4545
const stringReplace = unapply(String.prototype.replace);
4646
const stringIndexOf = unapply(String.prototype.indexOf);
4747
const stringTrim = unapply(String.prototype.trim);
48+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
4849
const regExpTest = unapply(RegExp.prototype.test);
4950
const typeErrorCreate = unconstruct(TypeError);
5051

@@ -120,7 +121,7 @@ function addToSet(set, array) {
120121
*/
121122
function cleanArray(array) {
122123
for (let index = 0; index < array.length; index++) {
123-
const isPropertyExist = Object.prototype.hasOwnProperty.call(array, index);
124+
const isPropertyExist = objectHasOwnProperty(array, index);
124125
if (!isPropertyExist) {
125126
array[index] = null;
126127
}
@@ -137,7 +138,7 @@ function cleanArray(array) {
137138
function clone(object) {
138139
const newObject = create(null);
139140
for (const [property, value] of entries(object)) {
140-
const isPropertyExist = Object.prototype.hasOwnProperty.call(object, property);
141+
const isPropertyExist = objectHasOwnProperty(object, property);
141142
if (isPropertyExist) {
142143
if (Array.isArray(value)) {
143144
newObject[property] = cleanArray(value);

‎dist/purify.es.mjs.map

+1-1
Large diffs are not rendered by default.

‎dist/purify.js

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/utils.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const stringReplace = unapply(String.prototype.replace);
4646
const stringIndexOf = unapply(String.prototype.indexOf);
4747
const stringTrim = unapply(String.prototype.trim);
4848

49+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
50+
4951
const regExpTest = unapply(RegExp.prototype.test);
5052

5153
const typeErrorCreate = unconstruct(TypeError);
@@ -115,7 +117,7 @@ function addToSet(set, array, transformCaseFunc = stringToLowerCase) {
115117
*/
116118
function cleanArray(array) {
117119
for (let index = 0; index < array.length; index++) {
118-
const isPropertyExist = Object.prototype.hasOwnProperty.call(array, index);
120+
const isPropertyExist = objectHasOwnProperty(array, index);
119121

120122
if (!isPropertyExist) {
121123
array[index] = null;
@@ -135,10 +137,7 @@ function clone(object) {
135137
const newObject = create(null);
136138

137139
for (const [property, value] of entries(object)) {
138-
const isPropertyExist = Object.prototype.hasOwnProperty.call(
139-
object,
140-
property
141-
);
140+
const isPropertyExist = objectHasOwnProperty(object, property);
142141

143142
if (isPropertyExist) {
144143
if (Array.isArray(value)) {

0 commit comments

Comments
 (0)
Please sign in to comment.