Giter Site home page Giter Site logo

Add format property about prompts HOT 10 CLOSED

terkelg avatar terkelg commented on July 22, 2024 2
Add format property

from prompts.

Comments (10)

lukeed avatar lukeed commented on July 22, 2024 2

Agreed, but should be format IMO. Otherwise sounds like logic to specify which prompts to display, or something like that.

from prompts.

lukeed avatar lukeed commented on July 22, 2024 2

I would pass the formatted answer to onSubmit

answers[prompt.name] = answer = prompt.format ? prompt.format(answer, answers) : answer;

I also don't think there's a need for async formatters, but might as well since we're inside an async function.

from prompts.

lukeed avatar lukeed commented on July 22, 2024

That or merge this behavior into onSubmit

from prompts.

simonepri avatar simonepri commented on July 22, 2024

Yeah I agree with format instead of filter

from prompts.

terkelg avatar terkelg commented on July 22, 2024

Nice 💯. Let's implement this

from prompts.

terkelg avatar terkelg commented on July 22, 2024

Please checkout the implementation here.

Should the onSubmit function receive the raw value or the formatted value?

I also pass the current answers object as a second param in case you want to format based on previous values.

from prompts.

terkelg avatar terkelg commented on July 22, 2024

Cool! Thanks guys. Added in #7

from prompts.

simonepri avatar simonepri commented on July 22, 2024

@terkelg
It shouldn't be:

answers[prompt.name] = answer = prompt.format ? await prompt.format(answer, answers) : answer;

??

from prompts.

simonepri avatar simonepri commented on July 22, 2024

On our side is effortless to support async functions. It doesn't make to much sense to not support it.
@lukeed any reason about the choice of sync only format?

from prompts.

terkelg avatar terkelg commented on July 22, 2024

@simonepri yeah I guess you're right. Let's make it async.

from prompts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.