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 🙏

© 2026 – Pkg Stats / Ryan Hefner

root-api

v0.0.5

Published

Organize your API with flexible customization in a breeze. No dependencies.

Readme

root-api

Organize your API with flexible customization in a breeze. No dependencies.

Dependencies Coverage Downloads

Installation

$ npm i -s root-api

Usage

There are 2 steps:

  1. Define the tree. When you define the tree, you specify the structure, so you, mainly, nest objects.
  2. Define the leaves. When you define the leaves, you specify the contents, so you use direct values, references to files and factories (through functions or files). Here is where the root-api helps.

Test

This is a test that demonstrates almost all the parameters in action separatedly:

const $api = RootAPI.create({
	directory: __dirname + "/lib",
	separator: ".",
	root: {
		classicMessage: "Hi all!",
		data: {
			strings: {
				hello: "hello",
				world: "world"
			},
			externalSource: undefined,
			code: undefined,
			code800: undefined,
			message: undefined,
			prop: "code800"
		},
		getMessage: undefined,
		setMessage: undefined,
		aboutData: undefined,
		stack: [],
		methods: {
			talk: undefined,
			run: undefined,
			jump: undefined,
			breath: undefined,
			swim: undefined,
			meditate: undefined,
		},
		doEverything: undefined,
		classExample: undefined,
	}
});
$api.set({
	property: "data.code",
	value: 200
})
$api.set({
	property: "data.code800",
	file: "data.example.js"
});
$api.set({
	property: "data.message",
	factory: "data.message.factory.js"
});
$api.set({
	property: "getMessage",
	file: "function.getMessage.js"
});
$api.set({
	property: "setMessage",
	factory: "function.setMessage.factory.js"
});
await $api.set({
	property: "data.externalSource",
	factory: "data.externalSource.factory.js",
	with: ["data.strings.hello", "data.strings.world"],
	promised: true
});
$api.set({
	property: "aboutData",
	factory: "function.aboutData.factory.js",
	scope: "data"
});
$api.set({
	property: "aboutDataBound",
	factory: "function.aboutData.factory.js",
	scope: "data",
	with: ["data.prop"]
});
$api.set({
	property: "sum",
	factory: function() {
		return 800 + this.code800
	},
	scope: "data",
	with: ["data.prop"]
});
$api.set({
	property: "methods.talk",
	value: function(arg) {
		this.stack.push("Talking: " + (arg ? arg : ""))
	}
});
$api.set({
	property: "methods.run",
	value: function(arg) {
		this.stack.push("Running: " + (arg ? arg : ""))
	}
});
$api.set({
	property: "methods.jump",
	value: function(arg) {
		this.stack.push("Jumping: " + (arg ? arg : ""))
	}
});
$api.set({
	property: "methods.breath",
	value: function(arg) {
		this.stack.push("Breathing: " + (arg ? arg : ""))
	}
});
$api.set({
	property: "methods.swim",
	value: function(arg) {
		this.stack.push("Swiming: " + (arg ? arg : ""))
	}
});
$api.set({
	property: "methods.meditate",
	value: function(arg) {
		this.stack.push("Meditating: " + (arg ? arg : ""))
	}
});
$api.set({
	property: "doEverything",
	value: function() {
		this.methods.talk("something");
		this.methods.run("something");
		this.methods.jump("something");
		this.methods.breath("something");
		this.methods.swim("something");
		this.methods.meditate("something");
	}
});
$api.set({
	property: "classExample",
	with: [{
		msg: "My fixed message"
	}],
	value: function(data = undefined) {
		this.a = "a";
		this.b = "b";
		this.c = "c";
		this.message = data.msg;
	},
});

To see the complete example, you will have to go to the test folder.

Property options

This logical expression represents the combinations of parameters that makes sense to the internal algorythm:

property & ( factory | file | value ) & ( with )? & ( scope )?

  • property (string) indicates, using the separator option, which defaults to ., the property which is going to be modified.
  • ( factory | file | value ) indicates the source, and implicitly its type, by which the property is going to be set.
    • factory can receive function or string. On strings, it is understood as the path of a file which is a function module.
    • file can receive string as the path of a file which is a function module.
    • value can receive any as the direct value.
  • with (array) is optional. Used with functions, it indicates the parameters attached to the main function. In the case of the factory, the factory's main function is attached only.
  • scope is optional. Used with functions, it indicates the scope bound to the main function. In the case of the the factory, the factory's main function is attached only.
  • promised indicates that the result should be obtained by an await expression. In factories, the referred result is the generated value, not the generator function.

License

This project is licensed under WTFPL or do What The Fuck you want to Public License.

Issues

You can leave an issue on the repository.

URL

https://github.com/allnulled/root-api