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

Fix clone deep to not throw err for non obj #15

Conversation

ZIMkaRU
Copy link
Member

@ZIMkaRU ZIMkaRU commented Nov 17, 2023

Description:

This PR fixes cloneDeep util to not throw an error when cloning non-objects

Fixes:

PR status:

  • Version bumped
  • Change-log updated
  • Tests added or updated
  • PR keeps 100% test coverage
  • Type definition updated
  • Readme updated
  • Linter is applied
  • Const arrow functions are used instead of pure function definitions where applicable
  • Functions are listed in alphabetic order in index.js, index.d.ts and readme

@ZIMkaRU ZIMkaRU changed the title Bugfix/fix clone deep to not throw err for non obj Fix clone deep to not throw err for non obj Nov 17, 2023
Copy link

@ezewer ezewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small request, rest looks good!

const isObject = require('./isObject')

const cloneDeep = (obj) => {
if (!isObject(obj)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistency with lodash
we should add: if (obj instanceof Function) return {}

Copy link

@ezewer ezewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants