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

rsyncjs

v0.0.12

Published

rsyncjs provides a similar API to rsync, but in pure js.

Downloads

1,613

Readme

Description

rsyncjs provides a similar API to rsync, but in pure js.

With some additional features, such as splitting large files and quota throttling support.

Todo: Convert to TS 4.5 and export ESM

Based on sync-directory by @gh:hoperyy

Releases

  • (CodeSandbox official sandbox)[https://codesandbox.io/s/rsyncjs-rwr9t]
  • (Git repo, issues and PR's)[https://gitlab.com/vblip/rsyncjs]
  • (NPM rsyncjs)[https://www.npmjs.com/package/rsyncjs]
  • (UnPKG)[https://unpkg.com/rsyncjs@latest/]

Examples

Node

import { async as rsync } from 'rsyncjs'

const sleep = (s) => new Promise((p) => setTimeout(p, s * 1000))

console.time('rsync')

const main = async () => {
  await rsync(srcDir, targetDir, {
    async afterEachSync({ type, relativePath }) {
      console.log(type, relativePath)
      await sleep(1.5) // delay 1.5s after one file was synced
    }
  })
  console.timeEnd('rsync')
}
main()

Shell

# yarn add global rsyncjs
# npx -y rsyncjs <from> <to> [options]
npm install -g rsyncjs
rsyncjs <from> <to> [options]

Synchronous use via deasync

var rsyncjsCJS = require('rsyncjs')
var deasync = require('deasync')
var rsync = deasync(rsyncjsCJS.async)

Browser use with FileSystem API

Not tested... but willing to support it.

API

| import | Returns | Syntax | Blocks thread? | | ------ | --------- | ------------------------- | -------------- | | async | Promise | async / await, promises | No |

Params

| name | description | type | values | default | | ----------------------- | ------------------------------------------------ | ------------------------------------------------- | ------------- | ----------------------------------- | | srcDir | src directory | String | absolute path | - | | targetDir | target directory | String | absolute path | - | | config.deleteOrphaned | Delete other files in targetDir | Boolean | - | true | | config.afterEachSync | callback function when every file synced | Function | - | blank function | | config.exclude | files that should not sync to target directory. | RegExp / String / Array (item is RegExp / String) | - | null | | config.forceSync | some files must be synced even though 'excluded' | Function | - | (file) => { return false } | | config.filter | function to filter. Syncs file when true | Function | - | filepath => true | | config.onError | callback function when something wrong | Function | - | (err) => { throw new Error(err) } |

  • afterEachSync

    await rsync(srcDir, targetDir, {
      async afterEachSync({ type, relativePath }) {
        // type: init:hardlink / init:copy / add / change / unlink / unlinkDir
        // - init type: "init:copy"
        // - watch type: "add" / "change" / "unlink" / "unlinkDir"
        // relativePath: relative file path
      }
    })
  • type

    • copy

      rsync(srcDir, targetDir, {
        type: 'copy'
      })
  • exclude

    exclude node_modules

    • String

      rsync(srcDir, targetDir, {
        exclude: 'node_modules'
      })
    • RegExp

      rsync(srcDir, targetDir, {
        exclude: /node\_modules/
      })
    • Array

      rsync(srcDir, targetDir, {
        exclude: [/node\_modules/]
      })
      rsync(srcDir, targetDir, {
        exclude: ['node_modules']
      })
  • forceSync

    rsync(srcDir, targetDir, {
      exclude: 'node_modules',
      forceSync(file) {
        // all files in "node_modules" will be synced event though "exclude" is configed
        return /node_modules/.test(file)
      }
    })

Cli

options:

  • --quiet

    Disable unnecessary logs.

  • -do, --deleteOrphaned

    Delete orphaned files/folders in target folder. false as default.

    Same as api deleteOrphaned.

Contributing

  • Keep dependencies to a minimum, devDependencies are less of an issue.
  • Make sure your tests pass on the latest official Node LTS image
    • This is what CodeSandbox runs