Skip to content

Commit

Permalink
refac(utils): Refactoring objectHasOwnProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi02014 committed Jan 29, 2024
1 parent 4abee1e commit 3081134
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
5 changes: 3 additions & 2 deletions dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const stringMatch = unapply(String.prototype.match);
const stringReplace = unapply(String.prototype.replace);
const stringIndexOf = unapply(String.prototype.indexOf);
const stringTrim = unapply(String.prototype.trim);
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
const regExpTest = unapply(RegExp.prototype.test);
const typeErrorCreate = unconstruct(TypeError);

Expand Down Expand Up @@ -120,7 +121,7 @@ function addToSet(set, array) {
*/
function cleanArray(array) {
for (let index = 0; index < array.length; index++) {
const isPropertyExist = Object.prototype.hasOwnProperty.call(array, index);
const isPropertyExist = objectHasOwnProperty(array, index);
if (!isPropertyExist) {
array[index] = null;
}
Expand All @@ -137,7 +138,7 @@ function cleanArray(array) {
function clone(object) {
const newObject = create(null);
for (const [property, value] of entries(object)) {
const isPropertyExist = Object.prototype.hasOwnProperty.call(object, property);
const isPropertyExist = objectHasOwnProperty(object, property);
if (isPropertyExist) {
if (Array.isArray(value)) {
newObject[property] = cleanArray(value);
Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const stringReplace = unapply(String.prototype.replace);
const stringIndexOf = unapply(String.prototype.indexOf);
const stringTrim = unapply(String.prototype.trim);

const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);

const regExpTest = unapply(RegExp.prototype.test);

const typeErrorCreate = unconstruct(TypeError);
Expand Down Expand Up @@ -115,7 +117,7 @@ function addToSet(set, array, transformCaseFunc = stringToLowerCase) {
*/
function cleanArray(array) {
for (let index = 0; index < array.length; index++) {
const isPropertyExist = Object.prototype.hasOwnProperty.call(array, index);
const isPropertyExist = objectHasOwnProperty(array, index);

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

for (const [property, value] of entries(object)) {
const isPropertyExist = Object.prototype.hasOwnProperty.call(
object,
property
);
const isPropertyExist = objectHasOwnProperty(object, property);

if (isPropertyExist) {
if (Array.isArray(value)) {
Expand Down

0 comments on commit 3081134

Please sign in to comment.