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

nikki.js

v0.0.30

Published

nikki.build javascript client library.

Downloads

3

Readme

HOW TO USE NIKKI.BUILD JAVASCRIPT CLIENT (BROWSER) LIBRARY: WITH 3 SIMPLE STEPS.

  1. Refer example "embeddingInHtml" to directly include javascript library into your html.

    Steps to initialize javascript client.

    1. LOADING FILES:

        1. TO load the nikkijs.min.js client library from your server. =========OR========
        2. Use CDN link to load the client library like.check for latest version. https://www.jsdelivr.com/package/npm/nikki.js?path=dist
      1. Make sure you place serviceDef.json in the root path. So that it is accessible at this path /serviceDef.json You can find serviceDef.json file in CDN link or in our exmaples. Don't modify the content of serviceDef.json file.

      2. Create instance of nikkibuild's js client by creating instance of serviceBase class , you could find in nikki namespace.

        example: var jsHandler = new nikki.serviceBase()

    2. INITIALIZING THE CLIENT.

      You need to load the nikki.build's playground session credentials to complete the initialization. This information is stored in serviceToken.json (you can download it from nikki.build's playground => token => download token).

      You have 2 ways to initialize your client library. You can choose any of them.

      1. Loading session credentials from file serviceToken.json: Pass the file handler to loadTokenFromFileHanlder ( fileHandler ) function. example: html code : open serviceToken.json file from file input.

                        =========OR========
      2. Loading from server : Place your serviceToken.json file next to your serviceDef.json file. accessible at this path /serviceToken.json example: jsHandler.loadTokenFromServer()

    3. START THE CONNECTION. Call start() function of the client library once initialization is complete. This will establish the communication channel with the server. refer to the client API section for more information.

      example: jsHandler.start()

For more information: https://docs.nikki.build/clientApi

!!! important !!!.

MAKE SURE YOU UPDATE YOUR serviceToken.json FILE EVERY TIME YOU START A NEW SESSION.

JAVASCRIPT CLIENT API:

= loadTokenFromFileHanlder( fileHanlder ) : Map "onchange" event for file input element of you html. open serviceToken.json file to load the session's credentials. example html code.:

        js code:
              function loadTokenFromFileHanlder(event){
                    jsHandler.loadTokenFromFileHanlder(event)
              }

= loadTokenFromServer() : Place your serviceToken.json file in the root path of your server and call this function to load it from the /serviceToken.json path // it returns promise, either await for it or use then().catch()

  example: 

        async function yourStartingFun(){
              await jsHandler.loadTokenFromServer()
        }
                
                =========OR======== 

        jsHandler.loadTokenFromServer().
              then(()=>{
                    console.info("connected to server")
              }).
              cathc((err)=>{
                    console.info("failed to load tokens", err)
              })

= addEventListener(eventName, callbackFunction) :

   Register your event listeners on specific events.
   events:
        connected      : emitted when client connects to playground.
        disConnected   : emitted when connection with server breaks or closed.
        data           : emitted whenever you receive input from the playground.

  returns the ID of the listener. pass this ID to  removeEventListener() to remove the event listener.
  
  example: 
        
        function onData(data){
              console.log("got data", data)
        }

        let listnerID = jsHandler.addEventListener("data", onData)

= removeEventListener(ID) : ID : While registering the callback you will get an listener ID , pass that to remove the specific callback.

   example: 
        jsHandler.removeEventListener(listnerID)

= start() : To establish the connection. example: jsHandler.start()

= stop() : To stop the connection. example: jsHandler.stop()

= sendData(jsonData) : To send data to the playground. jsonData need to be valid and stringify() able.
example: let data = {count : 0} jsHandler.sendData(data);