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

@shilong521/fnc-method

v0.1.3

Published

js/ts方法库

Readme

@shilong521/fnc-method

介绍

js/ts 通用方法库。

安装

yarn add @shilong521/fnc-method
# 或者
npm install @shilong521/fnc-method --save

使用

import { getUrlSearchValueByKey } from '@shilong521/fnc-method';

API 目录

String

  • stringIsNumberAll - 判断字符串是否都是数字
  • stringTrimBlank - 过滤字符串中所有空格
  • stringEncodeChineseOnly - 仅对汉字进行编码

Number

  • numInRange - 判断数字是否在指定范围内

Array

  • arrayOmitFake - 过滤数组中的假值

Object

  • objOmitFake - 过滤对象中的假值
  • objForArray - 对象转数组

Window

  • getUrlSearchValueByKey - 通过 key 获取 URL 参数值
  • urlSearchToObject - URL 参数转对象
  • addUrlSearchData - 添加/更新 URL 参数
  • delUrlSearchKey - 删除指定 URL 参数
  • delUrlAllSearch - 清除所有 URL 参数
  • replaceSearchValueByKey - 替换 URL 参数值
  • historyReplace - 无感更新 URL

Tree

  • treeFind - 查找树形节点
  • treeFilter - 筛选树形结构
  • treeFindValues - 获取树形节点所有指定 key 的值
  • treeFindPaths - 查找树形节点路径

Is

  • isString / isNumber / isNull / isUndefined
  • isObject / isArray
  • isDev - 判断是否为开发环境
  • isFake - 判断是否为假值

Event

  • stopPropagation - 阻止事件冒泡

示例

urlSearchToObject

import { urlSearchToObject } from '@shilong521/fnc-method';

// URL: ?id=144&chinese=%E5%93%88%E5%93%88&chinese=%E4%BD%A0%E5%A5%BD

urlSearchToObject(window);
// { id: '144', chinese: ['哈哈', '你好'] }

urlSearchToObject(window, { valueNumberKeys: ['id'] });
// { id: 144, chinese: ['哈哈', '你好'] }

treeFindPaths

import { treeFindPaths } from '@shilong521/fnc-method';

const treeData = [
  {
    id: '1',
    name: '1-c',
    children: [
      {
        id: '1-1',
        name: '1-1-c',
        children: [{ id: '1-1-1', name: '1-1-1-c' }],
      },
      { id: '1-2', name: '1-2-c' },
    ],
  },
];

treeFindPaths(treeData, (data) => data.id === '1-1-1', 'id');
// ['1', '1-1', '1-1-1']