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

zion-common-utils

v1.5.9

Published

> zion-common-utils is a util lib for nodejs > > it has many convenient method to help you in daily develop

Downloads

99

Readme

zion-common-utils

zion-common-utils is a util lib for nodejs

it has many convenient method to help you in daily develop

installation

npm install zion-common-utils

usage

retry-util

import { RetryUtil } from "zion-common-utils";

await RetryUtil.retry(fn, { timeout: 5e3 })
await RetryUtil.retry(fn, { timeout: 5e3, interval: 2e3 })
await RetryUtil.retry(fn, { max: 10, interval: 2e3 })

net-util

import { NetUtil } from "zion-common-utils";

let ip: string = await NetUtil.getLocalIp();

let isConnected: boolean = await NetUtil.isConnected(`https://www.baidu.com`);

json-util

import { JsonUtil } from "zion-common-utils";

let objFormat: string = JsonUtil.format(obj);

file-util

import { FileUtil } from "zion-common-utils";

await FileUtil.download(url, dir);
await FileUtil.deleteFilesBefore7Days(dir);
const isExist = await FileUtil.isExist(file);
const files = await FileUtil.readAndSortFiles(dir);
const isDir = await FileUtil.isDir(path);
const result: { file: string[], dir: string[] } = await FileUtil.walkDir(dir, depth);

flag-util

import { FlagUtil } from "zion-common-utils";

await FlagUtil.setFlag(`${fileName}`, `${key}`, `${value}`);
const value = await FlagUtil.getFlag(`${fileName}`, `${key}`);

gitlab-util

import { GitlabUtil } from "zion-common-utils";

const gitlabUtil = new GitlabUtil(repository, branch, token);
const data: string = await gitlabUtil.readFile(path);

path-util

import { PathUtil } from "zion-common-utils";

PathUtil.initRootPath(path);
PathUtil.getAbsolutePath(relativePath);
const path = PathUtil.parseToPath(`/$HOME/test`) // path = `/Users/admin/test`

promise-util

import { PromiseUtil } from "zion-common-utils";

await PromiseUtil.sleep(3e3);
await PromiseUtil.withTimeout(fn, 30e3);

string-util

import { StringUtil } from "zion-common-utils";

StringUtil.substringToLastChar(origin, char);
StringUtil.substringToFirstChar(origin, char);
StringUtil.substringFromLastChar(origin, char);
StringUtil.substringFromFirstChar(origin, char);

process-util

import { ProcessUtil } from "zion-common-utils";

const stdout = await ProcessUtil.exec(command, options)

system-util

import { SystemUtil } from "zion-common-utils";

const platformName = await SystemUtil.getPlatformName();
const arch = await SystemUtil.getArch();
const platformVersion = await SystemUtil.getPlatformVersion();
const currentUser = await SystemUtil.currentUser();

const cpuInfo = SystemUtil.getCpuInfo();
const diskInfo = await SystemUtil.getDiskInfo();

const chromeVersion = await SystemUtil.getChromeVersion();
const chromeBetaVersion = await SystemUtil.getChromeBetaVersion();
const edgeVersion = await SystemUtil.getEdgeVersion();
const electronVersion = await SystemUtil.getElectronVersion();
const firefoxVersion = await SystemUtil.getFirefoxVersion();
const safariVersion = await SystemUtil.getSafariVersion();

const cpuUsage = SystemUtil.getCpuUsage();
const availableMem = SystemUtil.getAvailableMem();

interval-util

import { IntervalUtil } from "zion-common-utils";

IntervalUtil.addInterval(() => console.log(`hello`));
IntervalUtil.clearIntervals();

array-util

import { ArrayUtil } from "zion-common-utils";

const new_arr = ArrayUtil.deDuplicateX(arr, [str, str])

func-util

import { FuncUtil } from "zion-common-utils";

await FuncUtil.ignoreError(async () => {});

singleton-factory

import { SingletonFactory } from "zion-common-utils";

const person = SingletonFactory.getInstance(Person);

barrier

import { Barrier } from "zion-common-utils";

// use GPT to get how to use barrier