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

pull-fs-meta

v0.1.0

Published

File system functions with a separated metadata system.

Downloads

11

Readme

pull-fs-meta NPM version Build Status experimental

File system functions with a separated metadata system.

var pull = require('pull-stream')
var pug = require('pull-pug') // An example module
var fs = require('pull-fs-meta')() // Init pull-fs-meta

pull(
  // Reading pulls the file's contents as a string
  // and stashes the file's metadata on the `fs` object
  fs.read('app/**/*.pug'),

  // Use String -> String compiler
  pug(),

  // Change the file extensions before writing
  fs.files({ ext: 'html' }),

  // Write to an output folder.
  fs.write('output')
)

Modules like pull-vinyl or vinyl-fs (used in gulp) are based on top of the Vinyl object, which centralizes the metadata and contents in one location in the stream. This isn't really appealing to things like compilers who only deal with data... So you end up needing to create wrapper libraries like gulp-pug, gulp-sass, etc.

This module separates file structure from contents:

  1. Contents are streamed as strings so you can compile them easily with String -> String tools.
  2. Metadata is changed with fs.files({ ...options }), like extnames, clearing, etc.

Installation

$ npm install --save pull-fs-meta

API

fsm(options) -> fs

Initialize the pull-fs-meta module. This is the main export

  • options (Object): Options to initialize with
  • meta (Array): Optional meta to load beforehand

Easily done like this:

var fs = require('pull-fs-meta')({ meta: [] })
// Or
var fs = require('pull-fs-meta')()

fs.read(pattern, [options])

Read files' contents from the file system as a String. It works as a source pull stream.

  • pattern: A glob pattern resolved by pull-glob
  • options get passed to fs.files (with clear: true by default).
pull(
  fs.read('foo/**/*.js'),
  // ... transform contents
)

fs.write(directory)

Write contents to the file system under a base directory, to their metadata paths.

  • directory (String): A path where you want to output the files.
pull(
  fs.read('foo/**/*.js'),
  // ... transform contents
  // then write to `out` directory:
  fs.write('out')
)

fs.files(options)

Change your files' metadata.

  • options (Object): Options to apply on your metadata.
  • clear (Boolean): Clear the metadata.
  • ext (String): Change the file's extnames.
pull(
  fs.read('app/**/*.coffee'),
  // ... transform contents
  // update metadata:
  fs.files({ ext: '.js' })
  // write:
  fs.write('out')
)

"Meta" and "Metadata"

"Meta" is private array created from fms(), it contains "metadata".

The "metedata" are also arrays. They contain info much like Vinyl has; although, minus the content as that gets streamed.

License

MIT © Jamen Marz