Skip to content

feat: add objectorarray to replacements - #1049

Open
gameroman wants to merge 1 commit into
e18e:mainfrom
gameroman:objectorarray
Open

feat: add objectorarray to replacements#1049
gameroman wants to merge 1 commit into
e18e:mainfrom
gameroman:objectorarray

Conversation

@gameroman

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Closes #1021

📚 Description

add objectorarray to replacements

@43081j

43081j commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

the package checks if something is an object or an array, but this checks if its an object and not a RegExp.

shouldn't this be typeof and Array.isArray?

@gameroman

Copy link
Copy Markdown
Contributor Author

the package checks if something is an object or an array, but this checks if its an object and not a RegExp.

The package does that https://main.npmx.dev/package-code/objectorarray/v/1.0.5/index.js

@43081j

43081j commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

img

i think maybe the package is just old/terrible? and we should suggest something more sane?

though then it just dumbs down to typeof val === 'object' && val != null. no clue why it special cases RegExp but no other class (e.g. Date, Map, etc).

@gameroman

Copy link
Copy Markdown
Contributor Author

Yeah, I guess it's just because it's old. Array.isArray makes more sense now

@gameroman

Copy link
Copy Markdown
Contributor Author

I think like this

const isPlainObjectOrArray = (val) => {
  if (val === null || typeof val !== 'object') return false
  return Array.isArray(val) || Object.getPrototypeOf(val) === Object.prototype
}

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.

[Replacement]: objectorarray

2 participants