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

mitos

v1.0.3

Published

Makes JavaScript bundles that can be appended to

Downloads

7

Readme

Mitos

Commands

@import <path>@

imports a .dna file from the path specified

@retrieve <data property>@

splices data into the JavaScript file as inserted in the config.

@params <arguments>@

adds arguments into the function wrapper

Setup

Server: Configuration

require("mitos").config({
    "data": {
        key1: "word"
    },
    "import paths": [
        require("paths")["assets"] + "/dna/",
        require("paths")["assets"] + "/other-dna/"
    ]
});

Server: Make (& Send) First Bundle

require("mitos")["get package 1"]({
    "query": "import entry_point/first_page", //* required, just like the query, but w/o at symbols
    "launch params": ["start"] //* optional, these are passed in as arguments to the function that initiates the application
}, function(bundle) {
    var script = "&lt;script&gt;" + bundle + "&lt;script&gt;";

    // e.g. add script to html doc and send that to client
});

Client: Request additional JavaScript

Essentially this makes a POST request that includes the manifest of files that the client currently has, so that subsequent bundles can utilize these files

function mitos_request_subsequent_bundle(options) {
    var url = options.url;
    var data = options.data || null;

    var request = new XMLHttpRequest();
    var manifest = window["manifest"];

    request.onreadystatechange = function() {
        if (request.readyState == 4 && request.status == 200) {
            var response = request.responseText;

            var scriptStart;
            var launch;
            (function() {
                var number = "";

                if (response.substring(0,1) === "*") {
                    for (var i = 1; i < response.length; i++) {
                        var char = response.substring(i,i+1);

                        if (char === "*") {
                            if (number !== -1) {
                                launch = parseInt(number);
                                scriptStart = i + 1;
                                return;
                            }
                            else {
                                console.error("launch number not provided");
                            }
                        }
                        else {
                            number = number + char;
                        }
                    }
                }
                else {
                    console.error("launch not found");
                }
            })();

            var js = response.substring(scriptStart);

            if (js.length > 0) {
                var script = document.createElement("script");
                script.text = js;
                document.getElementById("sequences").appendChild(script);
            }

            window.bundle[launch](data);
        }
    };

    request.open("POST", url, true);
    request.send(JSON.stringify(manifest));
};

Server: Response to mitos_request_subsequent_bundle()

require("mitos")["get package 2+"]({
    "query": "import entry_point/second_page",
    "manifest": manifest,

    "launch params": ["asdfasdfasdf", "asdfasdfasdf"]
}, function(bundle) {
    response.write(bundle);
    response.end();
});