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

stc-helper

v1.0.7

Published

Helper for stc

Downloads

61

Readme

stc-helper

NPM version Build Status Coverage Status Dependency Status

helper for stc.

Install

npm install stc-helper

How to use

import {isFile} from 'stc-helper';
if(isFile('xxx')){
  
}

API

isStream(stream)

check is stream.

import {isStream} from 'stc-helper';
if(isStream(stream){
  
}

isBuffer(buffer)

check is buffer.

import {isBuffer} from 'stc-helper';
if(isBuffer(buf){
  
}

isArray(arr)

check is array.

isFunction(fn)

check is function.

isObject(obj)

isString(str)

isRegExp(regexp)

check is RegExp.

isExist(filePath)

check file/dir is exist.

isFile(filepath)

isDirectory(dir)

extend(target, source)

deep copy

let obj = extend({}, {name: 'stc'})

getFiles(dir, prefix = '')

get files from dir.

import {getFiles} from 'stc-helper';

let files = getFiles('/path/to'); // return is array

promisify(fn, receiver)

make callback function to promise.

import {promisify} from 'stc-helper';
import fs from 'fs'

let fn = promisify(fs.readFile, fs);
fn('/path/to/file', 'utf8').then(content => {
  
})

defer()

get Deferred object.

import {defer} from 'stc-helper';

let fn => {
  let deferred = defer();
  if(xxx){
    deferred.resolve('xxx');
  }else{
    deferred.reject(new Error());
  }
  return deferred.promise;
}

md5(str)

get content md5 value.

asyncReplace(content, replace, callback)

async content replace

import {asyncReplace} from 'stc-helper';

let fn = async content => {
  return asyncReplace(content, /\d+/, (a, b) => {
    return Promise.resolve(a);
  });
}

isRemoteUrl(url)

check is remote url

isRemoteUrl('http://www.stcjs.org/'); //true
isRemoteUrl('https://www.stcjs.org/'); //true
isRemoteUrl('//www.stcjs.org/'); //true

chmod(dir)

mkdir(dir)