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

agnostic-wipe

v0.1.0

Published

A utility function that safely removes all child nodes of a given DOM element, avoiding the use of innerHTML.

Downloads

9

Readme

AgnosticWipe

AgnosticWipe is a utility function that safely removes all child nodes of a given DOM element, avoiding the use of innerHTML to clear content. It includes configurable debugging capabilities (log and warn), similar to other Agnostic modules, to assist with troubleshooting during development.

Features

  • Safely wipes the content of a DOM element without using innerHTML.
  • Configurable debugging for logging and warnings.
  • Simple, clean, and secure DOM manipulation.

Installation

You can install AgnosticWipe via npm:

npm install agnostic-wipe

Usage

Importing and Declaring Debugging

To use agnosticWipe, first import it and configure the debugging options globally. You can then wipe the content of elements without needing to reconfigure debugging for every call.

import { agnosticWipe } from 'agnostic-wipe';

// Configure AgnosticWipe with debug options globally
window.agnosticWipe = agnosticWipe({ debugLog: true, debugWarn: true });

Basic Usage

Once agnosticWipe is configured globally, you can call it directly to wipe the content of any element by providing the target selector:

// Wipe content of an element with the ID '#myElement'
window.agnosticWipe('#myElement');

This will safely remove all the child nodes of the selected element.

Direct Usage Without Debugging

If you don't need to configure debugging, you can use agnosticWipe without setting the options:

// Wipe content of an element without configuring debugging
agnosticWipe()('#myElement');

Debugging

The agnosticWipe function can be configured to show logs and warnings:

  • debugLog: Controls the appearance of informational messages (console.log). It can be set to true or false.
  • debugWarn: Controls the appearance of warning messages (console.warn). It can be set to true or false.

By default, both flags are set to false.

Example:

Show only warnings in the console:

window.agnosticWipe = agnosticWipe({ debugLog: false, debugWarn: true });

Show both logs and warnings:

window.agnosticWipe = agnosticWipe({ debugLog: true, debugWarn: true });

Show nothing:

window.agnosticWipe = agnosticWipe;

-or-

window.agnosticWipe = agnosticWipe({ debugLog: false, debugWarn: false });

License

AgnosticHTML is licensed under the MIT License. See the LICENSE file for details.

Issues

If you encounter any issues, feel free to report them here.