Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:54:07+00:00 2026-05-22T23:54:07+00:00

My input is javascript code that I can pre-process.. at some specific point in

  • 0

My input is javascript code that I can pre-process..

at some specific point in the middle of some function there is a token that I need to replace with some async request(e.g. async AJAX request).

On runtime: When the async request is back (the callback is being executed) I need to return to exactly the same place(with the same context) in the code where I were before executing the async call.

Is it even possible? any ideas?

note that (1) I can pre process and change the code however I had like..
(2) the token can be practically anywhere, in a loop or anywhere else.. (3) the token just represents the location of the the async call, I can parse the entire document

This code might run on a browser or via node.js

Sample code:

function input(num){
     num +=10;
     <token>
     return num;
}

Would translate to some thing like

function input(num){
     num +=10;
     wait(async-request(...,callback));
     return num;
}

Update: After I read your answer here is an additional question,
Javascript: sync to async converter libs

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:54:08+00:00Added an answer on May 22, 2026 at 11:54 pm

    There are several projects that attempt to rewrite code written in a synchronous pattern into async code using continuations. E.g. you might want to take a look at:

    https://github.com/Sage/streamlinejs

    Some patterns (loops, try/catches) likely present more challenges than simple linear flow, but I’m pretty sure it’s a solvable problem in the general case. I don’t think you’ll be able to do it with simple token replacement, though — you’ll need to parse the javascript and transform it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some javascript code that generates additional input fields. So, I can know
I'm writing a custom widget that requires some supporting javascript code that I need
I have a javascript code, that sets a maximum quantity that can be select,
My current code that i use is this: <script type=text/javascript> $(document).ready(function(){ $('#on_holiday').trigger('click'); }); </script>
A thought struck me as I was writing a piece of JavaScript code that
i have a input tag which is non editable, but some times i need
i need help with a little code that i have below. i'm a newbie
I have JavaScript code that adds and removes classes using the classList object. The
I have this javascript code that creates a slider: http://jsfiddle.net/samccone/ZMkkd/ Now, i want to
I have applied the following code in javascript to pop-up a input box for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.