JavaScript Code to Flowchart

No credit card required

JavaScript Code to Flowchart

JavaScript Code to Flowchart

drobnikj/js-code-2-flowchart

No credit card required

Use this to convert JavaScript code to a flowchart. The actor uses https://www.npmjs.com/package/js2flowchart npm package to convert the code to a flowchart. The output is an SVG file.

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn mode

import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with API token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "code": // The function accepts a single argument: the "context" object.
    // For a complete list of its properties and functions,
    // see https://apify.com/apify/web-scraper#page-function 
    async function pageFunction(context) {
        // This statement works as a breakpoint when you're trying to debug your code. Works only with Run mode: DEVELOPMENT!
        // debugger; 
    
        // jQuery is handy for finding DOM elements and extracting data from them.
        // To use it, make sure to enable the "Inject jQuery" option.
        const $ = context.jQuery;
        const pageTitle = $('title').first().text();
    
        // Print some information to actor log
        context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);
    
        // Manually add a new page to the queue for scraping.
        context.enqueueRequest({ url: 'http://www.example.com' });
    
        // Return an object with the data extracted from the page.
        // It will be stored to the resulting dataset.
        return {
            url: context.request.url,
            pageTitle
        };
    }
};

(async () => {
    // Run the Actor and wait for it to finish
    const run = await client.actor("drobnikj/js-code-2-flowchart").call(input);

    // Fetch and print Actor results from the run's dataset (if any)
    console.log('Results from dataset');
    const { items } = await client.dataset(run.defaultDatasetId).listItems();
    items.forEach((item) => {
        console.dir(item);
    });
})();
Developer
Maintained by Community
Actor stats
  • 316 users
  • 1.3k runs
  • Modified 2 months ago
Categories

You might also like these Actors