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

@omni-door/utils

v1.3.2

Published

The utils of omni-door's projects

Downloads

911

Readme

🐸 @omni-door/utils

The Utils for omni-door's projects.

NPM downloads npm version Build Status codecov install size license

Install

  • Clone the repo: git clone [email protected]:omni-door/utils.git

  • Install with Npm: npm install @omni-door/utils

  • Install with Yarn: yarn add @omni-door/utils

Methods

  • exec

    import { exec } from '@omni-door/utils';
    
    exec(
      ['npm test', 'ls && pwd', 'npm run build'],
      () => console.info('成功!'),
      () => console.error('失败!')
    );
  • logPrefix

    import { logPrefix } from '@omni-door/utils';
    
    logPrefix(); // 😊  [OMNI-DOOR]:
  • setLogo

    import { setLogo } from '@omni-door/utils';
    
    setLogo('❤️️️️  ');
  • setBrand

    import { setBrand } from '@omni-door/utils';
    
    setBrand('ODYSSEY');
  • getLogo

    import { getLogo } from '@omni-door/utils';
    
    getLogo(); // ❤️️  
  • getBrand

    import { getBrand } from '@omni-door/utils';
    
    getBrand(); // ODYSSEY
  • logDetail

    import { logDetail } from '@omni-door/utils';
    
    logDetail('this is a message!'); // ❤️️  [ODYSSEY]: this is a message! (gray)
  • logEmph

    import { logEmph } from '@omni-door/utils';
    
    logEmph('this is a message!'); // ❤️️  [ODYSSEY]: this is a message! (cyan)
  • logErr

    import { logErr } from '@omni-door/utils';
    
    logErr('this is a message!'); // ❤️️  [ODYSSEY]: this is a message! (red)
  • logInfo

    import { logInfo } from '@omni-door/utils';
    
    logInfo('this is a message!'); // ❤️️  [ODYSSEY]: this is a message! (white)
  • logSuc

    import { logSuc } from '@omni-door/utils';
    
    logSuc('this is a message!'); // ❤️️  [ODYSSEY]: this is a message! (green)
  • logWarn

    import { logWarn } from '@omni-door/utils';
    
    logWarn('this is a message!'); // ❤️️  [ODYSSEY]: this is a message! (yellow)
  • underline

    import { underline } from '@omni-door/utils';
    
    logWarn(underline('this is a message!')); // ❤️️  [ODYSSEY]: this is a message! (has underline)
  • italic

    import { italic } from '@omni-door/utils';
    
    logDetail(italic('this is a message!')); // ❤️️  [ODYSSEY]: this is a message! (italic font)
  • nodeVersionCheck

    node -v # v10.13.0
    import { nodeVersionCheck } from '@omni-door/utils';
    
    // pass
    (async function () {
      // require node version >= 10
      await nodeVersionCheck('10');
    })()
    
    // can't through the check and will be exit with warn log
    (async function () {
      // require node version >= 10.14
      await nodeVersionCheck('10.14');
    })()
    
    // can't through the check and will be exit with warn log
    (async function () {
      // require node version >= 10.13.1
      await nodeVersionCheck('10.13.1');
    })()
  • npmVersionCheck

    import { npmVersionCheck } from '@omni-door/utils';
    
    // the npm-package current version whether equal the latest version
    // if not, will print some info
    npmVersionCheck('@omni-door/cli', '2.2.10');
  • updateNotifier

    import { updateNotifier } from '@omni-door/utils';
    import pkg from '../package.json'
    
    // update pkg notifier
    updateNotifier(pkg);
  • getNpmVersion

    import { getNpmVersion } from '@omni-door/utils';
    
    // get the npm-package latest version
    getNpmVersion('@omni-door/cli'); // 2.2.14
  • getNpmVersions

    import { getNpmVersions } from '@omni-door/utils';
    
    // get the npm-package latest version
    getNpmVersions('@omni-door/cli'); // [..., 2.2.14, 2.2.15, ....]
  • pkgNameCheck

    import { pkgNameCheck } from '@omni-door/utils';
    
    // check the project name whether or not meet the npm-package-name rule
    pkgNameCheck('yourProjectName');
  • outputFile

    import path from 'path';
    import { outputFile } from '@omni-door/utils';
    
    outputFile({
      file_path: path.resolve(__dirname, 'src/test.txt'),
      file_content: 'I am a test content!'
    });
  • getDependency

    import { getDependency } from '@omni-door/utils';
    
    const dependency = getDependency('latest', {
      'core-js': '3.6.4',
      'react': '16.12.0',
      'react-dom': '16.12.0',
      'regenerator-runtime': '0.13.3'
    });
    
    const dependencyStable = getDependency('stable', {
      'core-js': '3.6.4',
      'react': '16.12.0',
      'react-dom': '16.12.0',
      'regenerator-runtime': '0.13.3'
    });
    
    dependency('react'); // 'react@latest'
    dependencyStable('react'); // '[email protected]'
  • arr2str

    import { arr2str } from '@omni-door/utils';
    
    arr2str([1, 2, 3]); // "1 2 3"
  • intersection

    import { intersection } from '@omni-door/utils';
    
    depArr = [ ...intersection(depArr, depArr.filter(v => v !== 1)) ]
  • requireCwd

    import { requireCwd } from '@omni-door/utils';
    
    const errSilent = true;
    const Koa = requireCwd('koa', errSilent);
    const app = new Koa();
    // ...
  • spinner

    import { spinner } from '@omni-door/utils';
    
    spinner.state('start', 'begin!');
    spinner.text('new text');
    spinner.color('red');
    spinner.prefix('dot8');
    spinner.state('succeed', 'succeed!');
  • tplEngineInit

    import { tplEngineInit } from '@omni-door/utils';
    
    const tpls = {
      tplA: '`hello, ${include("tplB")}`',
      tplB: '`world`'
    };
    const envs = {
      ts: false,
      project_name: 'myProject',
      project_type: 'toolkit',
      style: 'css',
      strategy: 'stable',
      test: true,
      eslint: true,
      prettier: true,
      commitlint: true,
      stylelint: true,
      configFileName: 'omni.config.js'
    };
    const outputTpl = tplEngineInit(tpls, 'tplA');
    const tpl = outputTpl(envs);
  • tplEngineNew

    import { tplEngineNew } from '@omni-door/utils';
    
    const tpls = {
      tplA: '`hello, ${include("tplB")}`',
      tplB: '`world`'
    };
    const envs = {
      ts: false,
      project_type: 'spa-react' as 'spa-react',
      componentName: 'omni-spa',
      style: 'scss' as 'scss',
      test: true,
      md: 'md' as 'md'
    };
    const outputTpl = tplEngineNew(tpls, 'tplA');
    const tpl = outputTpl(envs);
  • _typeof

    import { _typeof } from '@omni-door/utils';
    
    _typeof(null); // "null"
    _typeof(undefined); // "undefined"
    _typeof([]); // "array"
    _typeof({}); // "object"
    _typeof(Symbol('symbol')); // "symbol"
    _typeof(''); // "string"
    _typeof(0); // "number"
  • isInGitRepository

    import { isInGitRepository } from '@omni-door/utils';
    
    isInGitRepository(); // return boolean
  • tryGitInit

    import { tryGitInit } from '@omni-door/utils';
    
    tryGitInit(); // try to init git repo