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

@suey/pkg-web

v0.0.3

Published

Compatible universal functions.

Downloads

7

Readme

设置 npm 源

npm config set registry https://registry.npmjs.org

安装

npm install @suey/pkg-web --save

pnpm install @suey/pkg-web --save

<script lang="ts" setup>
import { useRouter } from 'vue-router';
import { useMousetrap } from '@suey/pkg-web';

const router = useRouter();

// 监听键盘快捷键 Alt + 左右方向键, 只要当前组件存活(没有被销毁), 那么这个快捷键事件就存在
useMousetrap([
  ['alt+left', () => router.back(), 'keyup'],
  ['alt+right', () => router.forward(), 'keyup']
]);

// 你也可以写成单个的形式
useMousetrap('alt+left', () => router.back(), 'keyup');
useMousetrap('alt+right', () => router.forward(), 'keyup');

// 也可以多个快捷键触发同一个事件, 那么你的 key 应该更换为数组的形式
useMousetrap(['alt+left', 'left'], () => router.back(), 'keyup');
</script>
// pkg-web

// cookie
export declare const ckGet: (key: string) => string;
export declare const ckSet: (key: string, data: string, timer?: number) => string;
export declare const ckRemove: (key: string) => void;

// localstorage
export declare const loGet: <T>(key: string) => T;
export declare const loSet: <T>(key: string, value: T) => void;
export declare const loRemove: (key: string) => void;
export declare const loClear: () => void;

// sessionstorage
export declare const seGet: <T>(key: string) => T;
export declare const seSet: <T>(key: string, value: T) => void;
export declare const seRemove: (key: string) => void;
export declare const seClear: () => void;

// 监听键盘快捷键
export declare function useMousetrap(el: HTMLElement | Ref<HTMLElement>, keys: string | string[], callback: MousetrapBindFn, action?: MousetrapAction): Ref<MousetrapInstance>;
export declare function useMousetrap(el: HTMLElement | Ref<HTMLElement>, binds?: MousetrapBinds): Ref<MousetrapInstance>;
export declare function useMousetrap(keys: string | string[], callback: MousetrapBindFn, action?: MousetrapAction): Ref<MousetrapInstance>;
export declare function useMousetrap(binds: MousetrapBinds): Ref<MousetrapInstance>;

// 监听 DOM 事件
export declare function useEventListenerForElement<K extends keyof HTMLElementEventMap>(dom: HTMLElement, evtKey: K, listener: (ev: HTMLElementEventMap[K]) => any): void;
export declare function useEventListenerForElement<K extends keyof HTMLElementEventMap>(dom: HTMLElement, props: Record<K, (ev: HTMLElementEventMap[K]) => any>): void;
export declare function useEventListener<K extends keyof HTMLElementEventMap>(dom: Ref<HTMLElement>, evtKey: K, listener: (ev: HTMLElementEventMap[K]) => any): void;
export declare function useEventListener<K extends keyof HTMLElementEventMap>(dom: Ref<HTMLElement>, props: Record<K, (ev: HTMLElementEventMap[K]) => any>): void;

// 设置 DOM 样式
export declare const cssRoot: HTMLElement;
export declare const setCssVar: <T extends string>(node: HTMLElement, cssVar: T, value: string, isImportant?: boolean) => void;
export declare const getCssVar: (node: HTMLElement, cssVar: string) => string;
export declare const setCssVars: (node: HTMLElement, properties: Record<string, string>, isImportant?: boolean) => void;
export declare const setCssVarForRoot: <T extends string>(cssVar: T, value: string) => void;
export declare const getCssVarForRoot: (cssVar: string) => string;
export declare const setCssVarsForRoot: (properties: Record<string, string>) => void;
export declare const setStyleProperty: <T extends keyof CSSStyleDeclaration>(node: HTMLElement, key: T, value: CSSStyleDeclaration[T]) => CSSStyleDeclaration[T];
export declare const setStyleProperties: (node: HTMLElement, styleProperties: Partial<CSSStyleDeclaration>) => void;