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

@const-an/helper-core

v0.0.12

Published

@const-an/helper-core

Readme

@const-an/helper-core

项目中常用的帮助函数

安装:


npm install @const-an/helper-core
yarn add @const-an/helper-core

使用:

import { isNull } from '@const-an/helper-core'
isNull(null)

// commomjs
const helperCore = require('@const-an/helper-core')
helperCore.isNull(null)

promise

createPromise

创建一个流式执行的 promise

import { createPromise } from '@const-an/helper-core'

function load() {
  const { promise, resolve, reject } = createPromise()

  setTimeout(() => {
    resolve(true)
    // reject(new Error(''))
  }, 1000)

  return promise
}

load().then((res) => {
  console.log(res)
})

type

校验数据类型

isNull

import { isNull } from '@const-an/helper-core'

console.log(isNull(null)) // true

isArray

import { isArray } from '@const-an/helper-core'

console.log(isArray([])) // true

isString

import { isString } from '@const-an/helper-core'

console.log(isString('string')) // true

isNumber

import { isNumber } from '@const-an/helper-core'

console.log(isNumber(123)) // true

isObject

import { isObject } from '@const-an/helper-core'

console.log(isObject({})) // true

isBoolean

import { isBoolean } from '@const-an/helper-core'

console.log(isBoolean(false)) // true

isUndefined

import { isUndefined } from '@const-an/helper-core'

console.log(isUndefined(undefined)) // true

isEmpty

import { isEmpty } from '@const-an/helper-core'

// 判断是否为 空字符串、空数组、空对象、"Null"、"null"、"Undefined"、"undefined"、null、undefined

console.log(isEmpty(null)) // true
console.log(isEmpty(undefined)) // true
console.log(isEmpty('Null')) // true
console.log(isEmpty('null')) // true
console.log(isEmpty('Undefined')) // true
console.log(isEmpty('undefined')) // true
console.log(isEmpty('')) // true
console.log(isEmpty([])) // true
console.log(isEmpty({})) // true

param

获取 window.location.href 中携带的参数

getURLParam

获取 window.location.href 中的某“个”参数

import { getURLParam } from '@const-an/helper-core'

// url https://www.test.com/index.html?a=a#/test?b=b

console.log(getURLParam('a')) // a
console.log(getURLParam('b')) // b

getURLParamByMulti

获取 window.location.href 中的某“些”参数

import { getURLParamByMulti } from '@const-an/helper-core'

// url https://www.test.com/index.html?a=a&b=b#/test?c=c

console.log(getURLParamByMulti(['a', 'b', 'c'])) // {a : a, b : b, c : c}

getURLParamByAll

获取 window.location.href 中的所有参数

import { getURLParamByAll } from '@const-an/helper-core'

// url https://www.test.com/index.html?a=a&b=b#/test?c=c

console.log(getURLParamByAll()) // {a : a, b : b, c : c}

context

获取相关运行环境

checkBrowser

获取运行环境类型,类型有: WXWORK(企业微信) | WECHAT(微信) | ALIPAY(支付宝) | UNKNOWN (未知)

import { checkBrowser } from '@const-an/helper-core'

console.log(checkBrowser()) // WXWORK | WECHAT | ALIPAY | UNKNOWN

checkSystem

获取运行系统,类型有: android(安卓) | ios(ios) | unknown(未知)

import { checkSystem } from '@const-an/helper-core'

console.log(checkSystem()) // android | ios | unknown