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

bind-tree-to-property

v1.0.0

Published

Create APIs from directories and files.

Downloads

1

Readme

bind-tree-to-property

Create APIs from directories and files.

Installation

$ npm i -s bind-tree-to-property

Usage

Given this filesystem tree:

/index.js
/src/auth/login.js
/src/auth/logout.js
/src/data/select.js
/src/data/insert.js
/src/data/update.js
/src/data/delete.js

We can do:

const bindTreeToProperty = require("bind-tree-to-property");
const myFramework = {};
bindTreeToProperty("./src", myFramework, "api");

So we can get things done like:

myFramework.api.auth.login();
myFramework.api.auth.logout();
myFramework.api.data.select();
myFramework.api.data.insert();
myFramework.api.data.update();
myFramework.api.data.delete();

API

The whole library is based on 1 function: bindTreeToProperty.

This function accepts as parameters:

  • directory: String. Directory root of the future property value.
  • object: Object. Object that owns the property we want to set.
  • property: String. Property that we want to set.
  • root: Object. Object used as scope of the functional modules. Optional. By default, it is the object.

This function returns a: Promise. This promise returns the initial object extended.

Caution! this function does NOT create a copy of the object, it instead extends the provided object itself.

Why.

To create Node.js APIs fastly and schematically.

  • Using 0 dependencies
  • In 50 lines of code
  • In less than 2.5kB of code
  • Supports the following module types:
    • static
    • function
    • class
    • factory
    • promise
    • promiser or async factory

Really, why.

It is like... having an iluminated tree.

The skeleton of that tree is provided by the filesystem, the files and folders draw that skeleton.

The light of that tree is provided by Node.js and the runtime.

Given this... you can do 2 things:

  • You can turn off a branch, simply deleting a property. When you load it again, the branch will become illuminated again.

  • You can cut a branch, by deleting a property and the cache of node that provided the value of that property. This time, when you load it again, the branch will be regenerated, and then, illuminated again.

Basically, this is the ide behind this library. An illuminated tree.

License

No license, do what you want.