JavaScript Code to Flowchart avatar
JavaScript Code to Flowchart
Try for free

No credit card required

View all Actors
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.

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

Node.js

Python

curl

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5    token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10    "code": // The function accepts a single argument: the "context" object.
11    // For a complete list of its properties and functions,
12    // see https://apify.com/apify/web-scraper#page-function 
13    async function pageFunction(context) {
14        // This statement works as a breakpoint when you're trying to debug your code. Works only with Run mode: DEVELOPMENT!
15        // debugger; 
16    
17        // jQuery is handy for finding DOM elements and extracting data from them.
18        // To use it, make sure to enable the "Inject jQuery" option.
19        const $ = context.jQuery;
20        const pageTitle = $('title').first().text();
21    
22        // Print some information to actor log
23        context.log.info(`URL: ${context.request.url}, TITLE: ${pageTitle}`);
24    
25        // Manually add a new page to the queue for scraping.
26        context.enqueueRequest({ url: 'http://www.example.com' });
27    
28        // Return an object with the data extracted from the page.
29        // It will be stored to the resulting dataset.
30        return {
31            url: context.request.url,
32            pageTitle
33        };
34    }
35};
36
37(async () => {
38    // Run the Actor and wait for it to finish
39    const 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)
42    console.log('Results from dataset');
43    const { items } = await client.dataset(run.defaultDatasetId).listItems();
44    items.forEach((item) => {
45        console.dir(item);
46    });
47})();
Developer
Maintained by Community
Actor metrics
  • 17 monthly users
  • 82.1% runs succeeded
  • 0.0 days response time
  • Created in Nov 2017
  • Modified 7 months ago
Categories