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

@jdfed/leo-utils

v1.0.0

Published

为 leo 及其生态提供的工具库

Downloads

2

Readme

leo-utils

为 leo 及其生态提供的工具库

loadPkg

动态加载

基础使用

import { loadPkg } from '@leo/leo-utils';

(async () => {
  const puppeteer = await loadPkg('puppeteer', '10.0.0');
})();

高级使用

import { loadPkg, log } from '@leo/leo-utils';

(async () => {
  const puppeteer = await loadPkg('puppeteer', {
    version: '10.0.0',
    private: true,
    beforeInstall: () => {
      log.info('Log info when beforeInstall');
    },
    installSuccess: () => {
      log.success('Log info when installSuccess');
    },
    installFail: () => {
      log.error('Log info when installFail');
    },
  });
})();

API

loadPkg

| 属性名 | 描述 | 类型 | 默认值 | | ------------------------------ | ------------------------ | ------------------------------------------ | ------- | | name | 安装路径 | string | -- | | versionOrOptions | 版本号或相关配置 | string / object | -- | | versionOrOptions.version | 版本号 | string | false | | versionOrOptions.dev | 本次安装是否为开发模式 | boolean | false | | versionOrOptions.private | 是否将安装的包单独隔离 | boolean | false | | versionOrOptions.beforeInstall | 本次安装后执行的声明周期 | (name: string, version?: string) => void | -- | | versionOrOptions.afterInstall | 本次安装前执行的声明周期 | (name: string, version?: string) => void | `-- |

log

基于 signale 封装的 log 工具

基础使用

import { log } from '@leo/leo-utils';

log.error('');
log.fatal('');
log.fav('');
log.info('');
log.star('');
log.success('');
log.wait('');
log.warn('');
log.complete('');
log.pending('');
log.note('');
log.start('');
log.pause('');
log.debug('');
log.await('');
log.watch('');
log.log('');

高级使用

import { log } from '@leo/leo-utils';

// 在输出时标识你的作用域,用于区分输出
const myLog = log.scope('plugin scope');

myLog.info('info');

// [plugin scope] › ℹ  info      Info will has scope remark

注意

  • log.debug 是否输出由 leoConfig.isDebug 来控制,你可以通过使用 log.debug 来定位线上问题