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

Docs should include info how to promisify jar #143

Closed
thamerla opened this issue Jan 30, 2019 · 8 comments
Closed

Docs should include info how to promisify jar #143

thamerla opened this issue Jan 30, 2019 · 8 comments

Comments

@thamerla
Copy link

I would like to use promises but I have no clue how to promisify methods using built-in util.promisify. Docs should support this if it's not currently possible to implement promises on their own.

@stash stash self-assigned this Feb 4, 2019
@stash
Copy link
Collaborator

stash commented Feb 4, 2019

I suspect that util.promisfy should Just Work (tm) but I'll write up some test cases and update README.md to reflect the preferred method.

Since we support minimum node.js v6, and util.promisify was added in v8, tough-cookie unfortunately can't (yet!) switch to supporting this automatically. So, I'd like to explore a wrapper package that offers a promisify-ed API.

@stash
Copy link
Collaborator

stash commented Feb 4, 2019

See also: #66

@thamerla
Copy link
Author

thamerla commented Feb 5, 2019

@stash I saw that one and it prompted me to write this issue.

@bshevlin
Copy link

bshevlin commented Feb 14, 2019

@stash Bluebird has a good backwards-compatible promisification function and would probably help. They also have util functions that could help with backwards compatibility.

An example from Bluebird's docs that simultaneously supports promises and callbacks:

function getDataFor(input, callback) {
    return dataFromDataBase(input).asCallback(callback);
}

@awaterma awaterma added this to To do in 4.x Release Jul 1, 2019
@shivam-tripathi
Copy link

This should be useful:

const cookieJar = new tough.CookieJar();
const setCookie = util.promisify(cookieJar.setCookie.bind(cookieJar));
await setCookie('billi=0', 'https://www.catcat.com/', {
    ignoreError: false
});

@awaterma awaterma added major We expect this work to be a major semver change and removed major We expect this work to be a major semver change labels Dec 9, 2019
@awaterma awaterma added this to the 4.x Release milestone Dec 9, 2019
@awaterma awaterma removed this from To do in 4.x Release Feb 19, 2020
@awaterma awaterma assigned awaterma and unassigned stash Apr 20, 2020
@awaterma
Copy link
Member

We now support promises in the 4.x release. I think this issue is asking for better documentation, and some examples? Or should we close this out?

@awaterma awaterma moved this from To do to In progress in 4.01/4.1 Release Plan Mar 24, 2021
@colincasey
Copy link
Contributor

this should be addressed in #234

@colincasey colincasey moved this from In progress to Review in progress in 4.01/4.1 Release Plan May 23, 2022
@wjhsf
Copy link
Contributor

wjhsf commented May 24, 2022

#234 has been merged with updates to the README.

@wjhsf wjhsf closed this as completed May 24, 2022
4.01/4.1 Release Plan automation moved this from Review in progress to Done May 24, 2022
wjhsf pushed a commit that referenced this issue Feb 8, 2024
* chore: prepare for summer20 release (#143)

* 0.8.0

* chore: update jest to v25.5.4 (#152)

* chore: upgrade jest to 25.5.4

* 0.9.0 (#154)

* Update stubs for Summer 20 (#150)

* update stubs for Summer 20

* APPLICATION_SCOPE as symbol

* 0.9.1

* chore: update yarn lock file

Co-authored-by: Aliaksandr Papko <apapko@salesforce.com>
Co-authored-by: Trevor <tbliss@salesforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

7 participants