npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adashta

v1.0.15

Published

A nodejs based user-friendly bidirectional real-time communication tool, powered by native web sockets, providing simplicity and scalability.

Downloads

25

Readme

Adashta

License: MIT npm version

Adashta offers advanced SDKs for real-time communication, allowing developers to focus on their application's core business logic.

Features

  • Adashta Charts: Create real-time charts with minimal to no frontend coding required.

Installation and Initialization

Server

  1. Install the adashta using npm:
npm install adashta
  1. Initialize the adashta with your host and port:
const adashta = new Adashta({
  adashtaHost: 'localhost',
  adashtaPort: 3011
});

You need to pass the host and port of the adashta server to the constructor of the Adashta class. This will start the adashta server on the specified host and port.

  1. Boilerplate
const { Adashta } = require('adashta');

const adashta = new Adashta({
  adashtaHost: 'localhost',
  adashtaPort: '3011'
});

const loadAdashta = async () => {
  
  adashta.on('connection', async (clientId) => {
    console.log('Client connected', clientId);
  });

  adashta.on('disconnection', async (clientId) => {
    console.log('Client disconnected', clientId);
  });
};

loadAdashta();

In the above code, we are logging the clientId when a new client is connected and disconnected from the server.

connection event is triggered when a new client is connected to the server. clientId is passed as an argument to the callback function.

disconnection event is triggered when a client is disconnected from the server. clientId is passed as an argument to the callback function.

Client

  1. Include the Adashta SDK in your HTML file:
<script type="module">
    import { Adashta } from 'https://cdn.skypack.dev/adashta-js';
</script>

Adashta is available as an ES module. You can include it in your HTML file using the script tag with type module.

  1. Initialize the Adashta with your host and port:
const adashta = new Adashta({
  adashtaHost: 'localhost',
  adashtaPort: 3011
});

You need to pass the host and port of the Adashta server to the constructor of the Adashta class. This will connect the client to the Adashta server running on the specified host and port.

  1. Boilerplate
<script type="module">
        import { Adashta } from 'https://cdn.skypack.dev/adashta-js';
        
        const adashta = new Adashta({
          adashtaHost: 'localhost',
          adashtaPort: '3011'
        });
</script>

No additional frontend coding is required to render the chart. The chart will be automatically rendered in the specified query selector.

This provides a seamless integration of real-time charts into your application without the need for complex frontend coding.

SDKs

Adashta Charts

Adashta charts is used to create real-time charts with minimal to no frontend coding required. You can create different types of charts like line, bar, pie, etc., and update them in real-time.

It is internally using the Chart.js library to render the charts. You can pass the chart data and configurations to the Adashta, and it will render the chart on the client side.

Server

  1. Create a new chart:
const chart = {
  chartId: 'dummy-company-stock-chart',
  querySelector: '.chart',
  chartData: {
    type: 'line',
    data: {
      labels: ['Day 1'],
      datasets: [{
        label: 'Dummy Company Stock Price',
        data: [350],
        borderWidth: 2
      }]
    },
    options: {
      scales: {
        y: {
          title: {
            display: true,
            text: 'Share Price ($)'
          }
        },
        x: {
          title: {
            display: true,
            text: 'Days'
          },
          ticks: {
            autoSkip: true,
            maxTicksLimit: 10,
          }
        }
      }
    }
  }
};
  1. Produce the chart to the client:
await adashta.charts().produce(clientId, chart);

produce method takes two arguments, first is the clientId and second is the chart object. clientId is the unique id of the client to whom we want to send the chart. It will be generated by the Adashta. chart object is the object containing the chart data and other configurations, For more information refer to the Chart.js documentation{:target="_blank"}.

  1. Update the chart data:
chart.chartData.data.labels.push(`Day ${days}`);
chart.chartData.data.datasets[0].data.push(getRandomInt(300, 800));
await adashta.charts().produce(clientId, chart);

To update the chart use produce method again with the updated chart object. This will update the chart on the client side.

  1. Boilerplate
const { Adashta } = require('adashta');

const adashta = new Adashta({
  adashtaHost: 'localhost',
  adashtaPort: '3011'
});

const loadAdashta = async () => {
  const clientIdInterval = {};
  adashta.on('connection', async (clientId) => {
    const chart = {
      chartId: 'dummy-company-stock-chart',
      querySelector: '.chart',
      chartData: {
        type: 'line',
        data: {
          labels: ['Day 1'],
          datasets: [{
            label: 'Dummy Company Stock Price',
            data: [350],
            borderWidth: 2
          }]
        },
        options: {
          scales: {
            y: {
              title: {
                display: true,
                text: 'Share Price ($)'
              }
            },
            x: {
              title: {
                display: true,
                text: 'Days'
              },
              ticks: {
                autoSkip: true,
                maxTicksLimit: 10,
              }
            }
          }
        }
      }
    };

    await adashta.charts().produce(clientId, chart);
      let days = 2;
      clientIdInterval[clientId] = setInterval(async () => {
        chart.chartData.data.labels.push(`Day ${days}`);
        chart.chartData.data.datasets[0].data.push(getRandomInt(300, 800));
        await adashta.charts().produce(clientId, chart);
        days++;
      }, 2000);
  });

  adashta.on('disconnection', async (clientId) => {
    clearInterval(clientIdInterval[clientId]);
    delete clientIdInterval[clientId];
    console.log('Client disconnected', clientId);
  });
};

function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

loadAdashta();

Here we are creating a chart with dummy data and sending it to the client.

Generally, We will have a chart object containing the chart data and other configurations. We will pass this object to the produce method to send the chart to the client.

We are using setInterval and getRandomInt methods to update the chart data every 2 seconds with random data. You can replace it with your own function to get the data from the database or any other source.

  1. Run Your Adashta Server:

    node index.js
  2. Open Your HTML File in a Browser: HTTP server is required to serve the HTML file. You can use http-server or any other HTTP server of your choice.

Contributing

Adashta is an open-source project that aims to simplify real-time communication for developers. We welcome contributions and feedback from the community. If you have any questions or suggestions, please feel free to reach out to us at [email protected]

If you would like to contribute to the project, please visit our GitHub repository at https://github.com/adashta/adashta

Thank you for using Adashta!