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

dat-transform

v2.0.0

Published

row-based, lazily-evaluated transformation on Dat archives.

Downloads

21

Readme

dat-transform

Lazily-evaluated transformation on Dat archives. Inspired by Resilient Distributed Dataset(RDD)

Standard - JavaScript Style Guide npm

npm i dat-transform

Synopsis

word count example:

const {RDD, kv} = require('dat-transform')

const Hyperdrive = require('hyperdrive')
const memdb = require('random-access-memory')
const archive = new Hyperdrive(ram, '<DAT-ARCHIVE-KEY>', {sparse: true})

// define transforms
var wc = RDD(archive)
  .splitBy(/[\n\s]/)
  .filter(x => x !== '')
  .map(word => kv(word, 1))

// actual run(action)
wc
  .reduceByKey((x, y) => x + y)
  .toArray(res => {
    console.log(res) // [{bar: 2, baz: 1, foo: 1}]
  })

Transform & Action

Transforms are lazily-evaluated function on a dat archive. Defining a transform on a RDD will not trigger computation immediately. Instead, transformations will be pipelined and computed when we actually need the result, therefore provides opportunities of optimization.

Transforms are applied to each file separately.

Following transforms are included:

map(f)
filter(f)
splitBy(f)
sortBy(f) // check test/index.js for gotcha

Actions are operations that returns a value to the application.

Examples of actions:

collect()
take(n)
reduceByKey(f)
count()
sum()
takeSortedBy()

Select

dat-transform provides indexing via hyperdrive's list of entry. You can specify the entries you want to computed with, which can greatly reduce bandwidth usage.

get(entryName)
select(f)

Partition

Partitions lets you re-index and cache the computed result to another archive.

partition(outArchive) // return promise

Marshal/Unmarshal

Transforms can be marshalled as JSON. which allows execution on remote machine.

RDD.marshal
unmarshal

How it works

dat-transform use streams from highland.js, which provides lazy-evaluation and back-pressure.

License

The MIT License