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

dndesm

v0.0.4

Published

classbase drag and drop esmodule

Readme

DnD.js

DnD.js provides the event-handling part of drag and drop, not the actual implementation of copying and moving.

quick start

load

no-module

<script src="./node_modules/dndesm/dnd.js"></script>

module

<script type="module">
	import DnD from "./node_modules/dndesm/index.mjs";
</script>
const namespace = 'dd';
const allowed = 'move';
DnD.setup(namespace).then(() => {
	DnD.Drop[namespace][allowed].set((e, ns) => {
		DnD.shiftDrop(e);
		DnD.uniqueEL(e, ns).then(el => {
			switch(e.dataTransfer.effectAllowed) {
				case 'move':
					e.target.append(el);
					break;
				case 'copy':
				default:
					const clone = el.cloneNode();
					clone.innerHTML = el.innerHTML;
					e.target.append(clone);
					DnD.reNumber(ns);
			}
		});
	});
});

set drag target & drop zone

<div class="dd-drag-move">drag able move</div>
<div class="dd-drag-copy">drag able copy</div>

<div class="dd-drop-move">drop zone allow move</div>
<div class="dd-drop-copy">drop zone allow copy</div>
<div class="dd-drop-all">drop zone allow all</div>

functions

DnD.setup(ns = 'dd')

async function. set event-handling

DnD.setup();

// OR

const namespaces = ['dd', 'xx', 'yy', 'zz'];
Promise.all(namespaces.map(DnD.setup)).then(() => {
	// complete all set up.
});

DnD.(Dragstart|Drag|Dragend)[namespace][effectAllowed].set(event, namespace)

// effectAllowed
// ['', 'none', 'copy', 'move', 'link', 'copyMove', 'copyLink', 'linkMove', 'all'];
DnD.Dragstart.dd.move.set((e, ns) => {
	console.log('drag target unique id', e.dataTransfer.getData(DnD.unique));
	e.dataTransfer.setData('test', 'a');
})

DnD.(Dragenter|Dragover|Dragleave|Drop)[namespace][dropEffects].set(event, namespace)

// dropEffects
// ['', 'move', 'copy', 'link', 'none']
DnD.Drop.dd.move.set((e, ns) => {
	console.log('drag target unique id', e.dataTransfer.getData(DnD.unique));
	console.log(e.dataTransfer.getData('test'));

	// Describe the implementation of "Move on Drop".
});

DnD.uniqueEL(event, namespace)

get drag target element.

DnD.uniqueEL(e, ns).then(el => {})

DnD.shiftDrop(event)

move: Shift + Drop
copy: Ctrl + Drop

DnD.reNumber(namespace)

update unique number.

<div class="dd-drag-copy" data-dd-unique="1">copy</div>
<div class="dd-drop-all">
	<!-- copy.  -->
	<div class="dd-drag-copy" data-dd-unique="1">copy</div>
</div>
DnD.Drop.dd.copy.set((e, ns) => {
	DnD.uniqueEL(e, ns).then(el => {
		const clone = el.cloneNode();
		clone.innerHTML = el.innerHTML;
		e.ctarget.append(clone);

		// unique number update
		DnD.reNumber(ns);
	});
});
<div class="dd-drag-copy" data-dd-unique="1">copy</div>
<div class="dd-drop-all">
	<!-- copy.  -->
	<div class="dd-drag-copy" data-dd-unique="2">copy</div>
</div>