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

Add .isWeakRef() #165

Merged
merged 21 commits into from
Jun 13, 2022
Merged

Conversation

bigbigDreamer
Copy link
Contributor

@bigbigDreamer bigbigDreamer commented Mar 2, 2022

@sindresorhus done other PR to replace #164

@bigbigDreamer bigbigDreamer changed the title Add .isWeakRef Add .isWeakRef() Mar 2, 2022
@sindresorhus
Copy link
Owner

Tests are failing

tsconfig.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@bigbigDreamer
Copy link
Contributor Author

Tests are failing

Sorry, I haven't checked the problem yet. At present, it seems that only node version 14 is passed.

@bigbigDreamer
Copy link
Contributor Author

Tests are failing

image

I found the reason, because JSDOM WeakRef currently supports V14.6.0+ , can I Mock one manually? As a downgrade solution to handle Node versions?

@bigbigDreamer bigbigDreamer mentioned this pull request Mar 3, 2022
@bigbigDreamer
Copy link
Contributor Author

Unfortunately, I have not found a solution on how to simulate the behavior of WeakRef. At present, because JSOM simulation is limited to Node V14.6.0+, the test of the lower version fails, so I can only temporarily close this PR, thank you for your understanding

@bigbigDreamer
Copy link
Contributor Author

https://github.com/ungap/weakrefs/blob/master/cjs/index.js perhaps it can try mock in node env

@bigbigDreamer bigbigDreamer reopened this Mar 9, 2022
@bigbigDreamer
Copy link
Contributor Author

Although the use case must be run on a low version node environment, the minimum requirement for WeakRef is Node V14.6.0, so I don't think it is necessary to create a mock use case for it on a low version Node.

@bigbigDreamer
Copy link
Contributor Author

Record: JSDOM@latest will reported error in ci with Node V10.
image

@bigbigDreamer
Copy link
Contributor Author

Tests all pass, @sindresorhus 🥳

@sindresorhus
Copy link
Owner

Can you fix the merge conflict?

@bigbigDreamer
Copy link
Contributor Author

bigbigDreamer commented Jun 12, 2022

Can you fix the merge conflict?

Ok. Had fixed!But I encountered a very strange problem. Line 343 is a blank line, but lint reported an error. I repeatedly checked the code and found no problems. Can I ask for your help.

image

source/index.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

I suggest we just embed the WeakRef type so we don't have to require a higher target.

interface WeakRef<T extends object> {
    readonly [Symbol.toStringTag]: "WeakRef";

    /**
     * Returns the WeakRef instance's target object, or undefined if the target object has been
     * reclaimed.
     */
    deref(): T | undefined;
}

@bigbigDreamer
Copy link
Contributor Author

I suggest we just embed the WeakRef type so we don't have to require a higher target.

interface WeakRef<T extends object> {
    readonly [Symbol.toStringTag]: "WeakRef";

    /**
     * Returns the WeakRef instance's target object, or undefined if the target object has been
     * reclaimed.
     */
    deref(): T | undefined;
}

done

@bigbigDreamer
Copy link
Contributor Author

Can you fix the merge conflict?

Ok. Had fixed!But I encountered a very strange problem. Line 343 is a blank line, but lint reported an error. I repeatedly checked the code and found no problems. Can I ask for your help.

image

Thank you so much, I just noticed that I read the wrong file, it is a lint problem in another file, sorry, sorry for the trouble, I will be more careful next time

@sindresorhus sindresorhus merged commit e503a9e into sindresorhus:main Jun 13, 2022
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.

None yet

2 participants