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

lazy-kit-fs

v1.0.7

Published

> File system quick toolkit based on Nodejs

Downloads

7

Readme

lazy-kit-fs

File system quick toolkit based on Nodejs

Functions

/**
 * 文件夹是否存在, 如果不存在则创建, 并返回创建后的绝对路径
 * @param path
 * @returns 绝对地址
 */
function inspect(path: string): string;

/**
   * 将指定文件移动到指定的目标地址
   * @param src 原文件
   * @param dest 目标文件夹
   * @param filename 可选 目标文件名, 未设置时同原文件名
   * @returns boolean
   */
  function moveTo(
    src_file: string,
    dest_dir: string,
    filename?: string
  ): boolean;

/**
   * 读取指定的文件后, 将文件内容转换为JSON对象
   * @param file_or_data 文件绝对地址 或者 JSON字符串
   * @param options 可选 {
   * isPath?:boolean 原文件参数是一个地址还是JSON字符串
   * path2buf: string[] 需要将指定字段设置的文件地址替换为读取之后的buffer, 字段可以是a.b.c深度指定
   * }
   * @returns JSON
   */
  function toJSON(
    file_or_data: string,
    options?: { isPath?: boolean; path2buf?: string[] }
  ): any;

  /**
   * 将键值对形式的文本转换为一个JSON对象
   * @param text 文本字符串
   * @param segSplit 键值对 与 键值对 之间的间隔符号, 默认是正则表达式/\r?\n/
   * @param kvSplit 键值对的 键与值之间的间隔符号, 默认是等号“=”
   * @returns 
   */
  function kv2Json(text:string, segSplit?:any, kvSplit?:any): {[field:string]:string} ;

/**
   * 检查给定文件, 判断文件的读写状态, 及其是否已经读写完毕, 可设置上一次检查的时间
   * 文件不存在时抛异常
   * @param file 文件地址
   * @param dura 间隔多少时间没有更新就表示文件写入已完成, 单位秒, 默认30s
   * @returns boolean
   */
  function isEOF(file:string, dura?:number): boolean;

/**
   * 监听文件, 直到文件完成全部更新
   * @param file 监听的文件地址
   * @param intv 监听的间隔时间, 单位秒, 默认5s
   * @param dura 间隔多少时间没有更新就表示文件写入已完成, 单位秒, 默认30s
   * @returns Promise<Stats> 文件完全全部更新之后的统计信息
   */
  function watchEOF(file:string, intv?:number, dura?:number): Promise<any>;
  /**
   * 按指定数据块参数, 解析二进制文件, 并按顺序返回解析后的数据块缓存
   * @param bin 原始二进制文件数据混存
   * @param blocks 按顺序指定的数据块参数
    {
      position: "fix"|"flex";
      start?: number; 起始位置; fix的时候必须(第一块不需要设置), flex的时候不需要;
      end?: number;   结束位置; fix的时候必须(末尾块不需要设置), flex的时候不需要;
      encoding?: any; 数据块的编码格式, UTF8 | ASCII | HEX 等等
    }
  * @returns 按顺序返回每个数据块(指定编码时返回解码后数据)
  */
  function parseBinary(bin:Buffer, blocks:{
    position: "fix"|"flex";
    start?: number; // 起始位置; fix的时候必须, flex的时候不需要
    end?: number; // 结束位置; fix的时候必须, flex的时候不需要
    encoding?: any; // 数据块的编码格式, UTF8 | ASCII | HEX 等等
  }[]): (string|Buffer)[];
  /**
   * 根据分块长度, 分隔给定的缓存
   * @param bin 
   * @param blocks 
   */
  function splitBinary(bin:Buffer, blocks:("flex" | number)[]): Buffer[];