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

slimz

v1.1.8

Published

A util for node.js

Downloads

13

Readme

Description

Utils for node.js

Normal API

  • getTimeString(type)
  • getDay(number) eg:-1,0,1,2,3...
  • getFileExtension(file): Return the extension of the file. The file here can be any string that contains the file name.

type options

  • getTimeString(): 2019年03月17日 11:31:18
  • getTimeString('yyyymmdd'): 20190317
  • getTimeString('yyyy年mm月dd日'): 2019年03月17日
  • getTimeString('yyyy-mm-dd'): 2019-03-17
  • getTimeString('yyyy/mm/dd'): 2019/03/17
  • getTimeString('mmdd'): 0317
  • getTimeString('mm月dd日'): 03月17日
  • getTimeString('mm-dd'): 03-17
  • getTimeString('mm/dd'): 03/17
  • getTimeString('hh:mm:ss'): 11:31:18
  • getTimeString('hh时:mm分:ss秒'): 11时31分18秒

Promise API

  • rename(old_file, new_file)
  • copy(from,to)
  • mkdir_p(folder)
  • rm_rf(folder)
  • readFile(file)
  • readJson(jsonFile)
  • createFile(file)
  • writeFile(file,data)
  • writeJson(file,json_data)
  • exists(Path): The Path here is belong to file-system, which is a bit difference from js
  • exec_cmd(linux_cmd,cb): cb will exec after linux_cmd, note the result of the linux_cmd will not show in screen, so you should make it into a output stream, like echo hello > a.txt, ofcourse you can excute bash here
  • getFileList(options):Recive options, data structure liike {folder:"",skip:[],ext:[]}, return a obj like {files:[...],dirs:[...]}

example

getTimeString(type)

const { getTimeString } = require('slimz');
getTimeString(type)

mkdir(dir)

const { mkdir } = require('slimz');

mkdir('./a').then(()=>{
	return mkdir('a/b')
}).then(()=>{

}).catch(err=>{
	console.log(err)
})

exists(filePath)

exists('package.json').then(data=>{
	console.log(data)
})

exec_cmd(linx_cmd)

exec_cmd(`ls -al > a.txt`,()=>{
   console.log("finish")
}).then((data)=>{
    console.log(data)
})

getFileList(options)

options<Object>

  • folder: The path of the folder
  • skip: The folder you want to skip, it must be an Array
  • ext: Filter the extension, it must be an Array

example:

const options={
  folder: path.resolve(__dirname),
  skip:['node_modules/slimz','node_modules/fs-extra'],
  ext:['md']
}

getFileList(options).then(data=>{
  console.log(data)
}).catch(err=>{
  console.log(err);
})
//also you can do like this:
const { getFileList } = require('slimz')
async function run(){
  const options = {
    folder:"/Volumes/datavolumn_bmkserver_Pub/新做稿",
    skip:['摄影'],
    ext:['xls','xlsx']
  }
  let files = await getFileList(options)
  console.log(files)
}
run()