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

selfexjs

v7.0.0

Published

Creates self extracting JavaSscript.

Downloads

20

Readme

SelfExJS

npm install selfexjs

This is an experimental module. It contains one exported function pack(String). It takes a string of HTML or unevaluated JavaScript, and can include inline CSS. The resulting output, when included in a browser page, is a script which performs a document.write() of the original contents of the input string, or a self extracting JavaScript.

It uses the LZW packer method from Rosetta Code (replacing one from www.whak.ca which had been hacked to attempt to generate data in a pseudo document textarea mess). As a research project on the possibilities of using this with node, there is no copyright issue. For commercial server use, this may not be the case. But then again, you might just use the compression middleware module off github. Which is why I went for a medium LZW with UTF-8 output (plenty left to compress), making a casual code crypt.

Added in a file cache server, which is simplistic. It does not handle file permissions. Thus can be used to generate cache files from code which generates them. It allows concatenation of many files, and the first parameter if a string makes a blank file. If it is a function, it does nothing. If it is an array of functions and strings mixed, it uses the function to make all following string filenames until the next function is encountered. A file must be flushed before it can be recalculated by a function.

A pack cache server is now included, which prefixes "editable/" on to a requested file, and packs it down to be the file requested, and returns the content as a string to serve. It works on a double layer of total page and page section caching.

I have made it easy to get an Express app with inbuilt less, form data and JSON parsing, have added logging automatically, along with favicon.ico serving. Also a downloads function sets up an app server which static serves dowloads with and auto save dialog.

There is also a packServe callback which can be used with app.use to pack and serve with a cache the contents of the "editable/" directory. This also places the final pack page in the "cache/" directory (the first serve). The intermediates placed in the base directory are only ever used if the "cache/" copy does not exist. This makes it possible to edit a site without destroying service. For example various notifications can be edited in, and the site can activate them all at once when they "look good".

Exports

DEBUG: A debug flag which clears cache before generation when true
compress: LZW compression with Unicode optimization
decompress: An inverse of the above
ucompress: Compression with the compressor compressed too
pcompress: Compression with a general agreed prefix
pdecompress: Decompression with the same prefix (but the prefix must be compressed)
serve: A general static web server
downloads: A download server
app: An express app with many useful handlers
pack: A packed expression producer
minify: Minify JavaScript code
no: A utility to check defined
yes: A utility to fill undefined
getExtension: A file extension getter
blank: A no action callback filler
read: Sychronous file read
cache: Creates a cache of a function and file array
packServe: A simple packed file server (exports client (((p)(de))|(u))compress)
flush: A file cache flusher