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

@lytjs/common-dom-helpers

v6.6.0

Published

Lightweight DOM manipulation helpers for LytJS

Readme

@lytjs/common-dom-helpers

轻量级 DOM 操作辅助工具,提供常用的 DOM 创建、修改和查询方法。

安装

pnpm add @lytjs/common-dom-helpers

API

createElement(tag, attrs?, children?): Element

创建 DOM 元素,支持设置属性和子元素。

import { createElement } from '@lytjs/common-dom-helpers';

const el = createElement('div', { id: 'app', class: 'container' }, [
  'Hello',
  createElement('span', {}, ['World']),
]);

insertBefore(parent, child, ref): void

在参考节点前插入子节点,ref 为 null 时等同于 appendChild。

import { insertBefore } from '@lytjs/common-dom-helpers';

insertBefore(parent, newChild, refChild);
insertBefore(parent, newChild, null); // appendChild

removeChild(parent, child): boolean

移除子节点,成功返回 true,失败返回 false。

import { removeChild } from '@lytjs/common-dom-helpers';

const success = removeChild(parent, child); // true or false

nextSibling(node, skipComments?): Node | null

获取下一个兄弟节点,可通过参数控制是否跳过注释节点。

import { nextSibling } from '@lytjs/common-dom-helpers';

const next = nextSibling(node); // includes comments
const next = nextSibling(node, true); // skips comments

createTextNode(text): Text

创建文本节点。

import { createTextNode } from '@lytjs/common-dom-helpers';

const text = createTextNode('Hello World');

createComment(text): Comment

创建注释节点。

import { createComment } from '@lytjs/common-dom-helpers';

const comment = createComment('this is a comment');

setStyle(el, styles): void

批量设置元素样式。

import { setStyle } from '@lytjs/common-dom-helpers';

setStyle(el, { color: 'red', fontSize: '16px', zIndex: 10 });

hasClass(el, cls): boolean

检查元素是否有指定 class。

import { hasClass } from '@lytjs/common-dom-helpers';

hasClass(el, 'active'); // true or false

addClass(el, ...cls): void

添加 class。

import { addClass } from '@lytjs/common-dom-helpers';

addClass(el, 'active', 'visible');

removeClass(el, ...cls): void

移除 class。

import { removeClass } from '@lytjs/common-dom-helpers';

removeClass(el, 'active', 'hidden');

特性

  • 零运行时依赖
  • 体积 < 3KB(min+gzip)
  • Node.js 环境安全(非浏览器环境不会崩溃)
  • TypeScript 类型完整

License

MIT