-
Notifications
You must be signed in to change notification settings - Fork 28
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
docs(isEmpty): differences between Radashi and Lodash #146
Conversation
- Keep the tests in one file. Use `vi.resetModules` to check for correct behavior when globalThis.AggregateError is undefined and when it‘s not. - Inline the polyfill so it‘s not instantiated unless necessary. - Rename the local const to `AggregateErrorOrPolyfill` then use `export { … as … }` to export it as `AggregateError`. This prevents ESBuild from renaming the polyfill to `AggregateError2`, which it does to prevent variable shadowing.
This looks great. Thanks for starting this one! |
I ended up discovering a false positive in the it('should work with an object that has a `length` property', () => {
expect(_.isEmpty({ name: 'asfd', length: 0 })).toBe(false)
expect(_.isEmpty({ length: 0 })).toBe(false)
}) Currently, both expects fail because of this line of code: const length = (value as any).length
if (isNumber(length)) {
return length === 0
} In my view, this is incorrect, and this length check should only happen with arrays. So, I would change it to something like: if (isArray(value)) {
return value.length === 0
} Even though the JSDOC mentions "object with |
In the end, the only valid point to document is the constructor property in the prototype of a function. function Foo() {}
Foo.prototype = { constructor: Foo } |
Was this intentionally closed? |
Now that I see it, it wasn't 😅. My fork has some git problems. I'd rather delete the fork and create another one, but it looks like they closed the PR. |
I'll have to open the PR for the new fork now |
Tip
The owner of this PR can publish a preview release by commenting
/publish
in this PR. Afterwards, anyone can try it out by runningpnpm add radashi@pr<PR_NUMBER>
.Summary
Document differences between
Radashi
andLodash
in the functionisEmpty
Initially, I attempted to incorporate all the test cases from
Lodash
intoRadash
, and the following are my initial findings:false
for non-empty valuesarguments
objectslodash
that doesn't make sense herelodash
that doesn't make sense hereMAX_SAFE_INTEGER
as array-likeI will put the failed tests here to make analysis easier.
Related issue, if any:
#85
For any code change,
Does this PR introduce a breaking change?
No
Bundle impact
src/typed/isEmpty.ts
Footnotes
Function size includes the
import
dependencies of the function. ↩