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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@html_first/js_lib_template

v2.0.17

Published

an opionated js library single file exporter

Downloads

2

Readme

HOW TO INSTALL

npm i @html_first/js_lib_template --save-dev

or

bun i @html_first/js_lib_template -D

or any npm dependency management cli

singleton_instantiate_to_run

  • class prefixed with "__", are:
  • singleton, can only be instantiated once;
  • call run method of the instance, to starts the watcher to autogenerate the documentation;

exported-api-and-type-list

  • extended from core
  • singleton_instantiate_to_run;
  • fileName contains .type. detects @+typedef + ... + fileName;
  • supports nested folders;
  • targets ['*.mjs', '*.ts', '*.mts'] files;
  • instantiate class API to watch for file changes;
  • the exported API should contains match literally:
/**
 * @param {string} exportName
 * @returns {string[]}
 */
exportPatterns = (exportName) => [
	`export class ${exportName}`,
	`export const ${exportName}`,
	`export function ${exportName}`,
];
  • doesn't support var or let, for semantics;
  • supports for ["*.mjs", "*.ts", "*.mts"];
  • fileName contains .type. detects @+typedef + ... + fileName;
  • additional base setup for js developement:
  • generate types;
// tsconfig.js
{
"compilerOptions": {
	"allowJs": true,
	"declaration": true,
	"emitDeclarationOnly": true,
	"outDir": "./types",
	"module": "ESNext",
	"target": "ES2020",
	"moduleResolution": "node",
	"esModuleInterop": true,
	"skipLibCheck": true,
	"baseUrl": "."
},
"include": [filePathOptionValue]
}
  • generation script
// package.json
{
...
"main": "index.mjs",
"types": "./types/index.d.mts",
"module": "index.mjs",
"type": "module",
...
"scripts": {
	"dev": "concurrently \"bun --watch ./dev/index.mjs\" \"bun tsc --watch\""
},
...
}
  • with type definition it can also check for:
  • if there are any name colision, as we don't support aliases exports;
  • allow your library user to set skiplibChecks: false on their typescript configuration;

*) go to exported list

  • extended from core
  • singleton_instantiate_to_run;
  • fileName contains .type. detects @+see + ... + fileName;
  • using class instantiation, generate single markdown documentation for PHP;
  • on comment after @see throught the end of comment will be added;
  • supports nesting;
  • additional base setup;
  • example file setting:
// ./dev/index.mjs
// @ts-check
import { __PHPDev } from '@html_first/js_lib_template';
new __PHPDev({
 folderPath: './src',
 readMePath: './README.md',
  description: ['## HOW TO INSTALL','```shell','composer require author/package-name','```'].
}).run();
  • saving script for convenience:
// package.json
{
...
"scripts": {
...
	"dev": "bun --watch ./dev/index.mjs"
...
},
}
...
  • starts watching:
bun dev
// or
npm run dev

*) go to exported list

  • class template for auto document/export generator;
  • extended class must call super on it's constructor
export class MyClass extends {
	constructor(){
 		super({ ...coreOptions });
		// ...
	}
	// ...
	// also you need to override any method and property prefixed with "_"
}
  • constructor argument:
/**
 * @typedef {Object} coreOptions
 * @property {string} [coreOptions.filePath]
 * - realtive path from wroking directory
 * @property {string} [coreOptions.folderPath]
 * - realtive path from wroking directory
 * @property {string} [coreOptions.readMePath]
 * - realtive path from wroking directory
 * @property {string} [coreOptions.tableOfContentTitle]
 * @property {string[]} [coreOptions.copyright]
 * @property {string[]} [coreOptions.description]
 * @property {import('chokidar').WatchOptions} [coreOptions.option]
 */
  • we use chokidar for watching changes:
  • in essence this class is a collection of method to help to do the above points, incase of you want to create your own documentation/export generator calling this.createHandler;
  • file content detection uses string.includes, as I cannot get arround regex to allow me to use $ as export name;
  • README.md auto export rules:
  • has description;
  • in case you want to render empty string use [blank];
  • detectes the first commentBlock with description;
  • automatically turns string after last description of that commentBlock until end of the commentBlock;
  • upperCase OR symbol;
  • fileName match with exportedName;
  • special export:
  • fileName contains .type.:

only works on language that have type supports, where declaring and assigning types can be done on different file:

  • will detect depends on the handler @+coreInstance._typedefIdentifier ... + filename;
  • fileName contains .export.:
  • use to bypass upperCase rule:
  • links:
  • auto named h2 tag id, it match the fileName in lowerCase;
  • in this autoExported case __JSDev can be refered as #__jsdev;
  • use namedExport extracted files from this.getListFilesNestedDetails method;
  • run thisInstance.run(); to start the watcher; !!!WARNING
  • copy out:
  • filePath: default ./index.mjs,
  • readMePath: default ./README.md,
  • folderPath: default ./src/*,
  • typescript outDir or package.json types: default ./types/*,
  • of any file you might need to be unmodified, before fully knowing what this library will modify...

*) go to exported list