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

resource-file

v0.4.6

Published

The Abstract Resource File Class. Each resource could have many custom attributes. These attributes could be a front-matter block in the same file, or as a separate configuration file exists.

Downloads

48

Readme

resource-file npm

Build Status Code Climate Test Coverage downloads license

Add a configuration data to a resource file object.

The resource could be a folder or a file. Each resource could have many custom attributes. These attributes may come from a front-matter block in the same text file, or as a separate configuration file exists with the same basename.

The priority is the front-matter > configuration file if they are both exist.

The Resource uses the Front-matter to read the file attributes.

The separate configuration file name should be the same basename of the resource.

You can add the following configuration format(extname):

  • YAML: .yml
  • CSON: .cson
  • TOML: .toml, .ini
  • JSON: .json

You should register these formats by youself.

It's only exists the separate configuration file if the resource if a folder. The folder's configuration file name could be:

  • _config.(yml|cson|ini|json)
  • (index|readme).md

The folder's configuration file names need to be registered too.

Usage

loadCfgFile     = require 'load-config-file'
loadCfgFolder   = require 'load-config-folder'
yaml            = require 'js-yaml'

loadCfgFile.register 'yml', yaml.safeLoad
loadCfgFolder.register 'yml', yaml.safeLoad
loadCfgFolder.addConfig '_config'

res = Resource './test/fixture'
res.loadSync(read:true)
res.should.have.property 'config', '_config'
res.contents.should.have.length 5
expect(res.date).to.be.an.instanceOf Date
expect(res.title).to.be.equal 'Fixture'

API

The Resource File Class inherited from AdvanceFile

Note: the load option default to true when creating resource file object.

Changes

v0.4

  • set the load option default to true when creating resource file object(v0.4.6).
  • add the summary attribute to the Resource (v0.4.4).
  • the filter should run after loading config.
  • can work on windows
  • add the title, date attributes to the Resource (v0.4.2)
    • title String: remove extension name of the file name, and convert it to a title strirng.
    • date(modifiedDate, updatedDate) Date : the latest modified date of the file/folder.
    • Note: you can set these value before loading stat.

v0.3

  • inherits the parent's configuration: the '<' key means inherits from parent.
    • number: add the parent's number

    • string: a the parent's string + this stirng.

    • list: concat the parent's list

    • object: extent the parent's object

    • eg,

      ---
      superLst:
        <: #inherits from parent
          - add1
          - add2
      superObj:
        <: #inherits from parent
          key1: HI
          key3: append
      ---

TODO

  • Stream supports.

License

MIT