JavaScript Code to Flowchart avatar

JavaScript Code to Flowchart

Try for free

No credit card required

Go to Store
JavaScript Code to Flowchart

JavaScript Code to Flowchart

drobnikj/js-code-2-flowchart
Try for free

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.

You can access the JavaScript Code to Flowchart programmatically from your own JavaScript applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6    token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11    "code": // The function accepts a single argument: the "context" object.
12    // For a complete list of its properties and functions,
13    // see https://apify.com/apify/web-scraper#page-function 
14    async function pageFunction(context) {
15        // This statement works as a breakpoint when you're trying to debug your code. Works only with Run mode: DEVELOPMENT!
16        // debugger; 
17    
18        // jQuery is handy for finding DOM elements and extracting data from them.
19        // To use it, make sure to enable the "Inject jQuery" option.
20        const $ = context.jQuery;
21        const pageTitle = $('title').first().text();
22    
23        // Print some information to actor log
24        context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);
25    
26        // Manually add a new page to the queue for scraping.
27        context.enqueueRequest({ url: 'http://www.example.com' });
28    
29        // Return an object with the data extracted from the page.
30        // It will be stored to the resulting dataset.
31        return {
32            url: context.request.url,
33            pageTitle
34        };
35    }
36};
37
38// Run the Actor and wait for it to finish
39const run = await client.actor("drobnikj/js-code-2-flowchart").call(input);
40
41// Fetch and print Actor results from the run's dataset (if any)
42console.log('Results from dataset');
43console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
44const { items } = await client.dataset(run.defaultDatasetId).listItems();
45items.forEach((item) => {
46    console.dir(item);
47});
48
49// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

JavaScript Code to Flowchart API in JavaScript

The Apify API client for JavaScript is the official library that allows you to use JavaScript Code to Flowchart API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.

Install the apify-client

npm install apify-client

Other API clients include:

Developer
Maintained by Community

Actor Metrics

  • 13 monthly users

  • 4 stars

  • 83% runs succeeded

  • Created in Nov 2017

  • Modified a year ago

Categories