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

base-env

v0.3.1

Published

Base plugin, creates a normalized environment object from a function, filepath or instance of base.

Downloads

90,765

Readme

base-env NPM version NPM monthly downloads NPM total downloads Linux Build Status

Base plugin, creates a normalized environment object from a function, filepath or instance of base.

Install

Install with npm:

$ npm install --save base-env

Usage

var Base = require('base');
var env = require('base-env');
var base = new Base();
base.use(env());

API

createEnv

Create an env object with the given name, function, filepath or app instance, and options. See the Env API docs below.

Params

  • name {String}
  • val {Object|Function|String}
  • options {Object}
  • returns {Object}

Example

var base = require('base');
var env = require('base-env');
var app = new Base();
app.use(env());

var env = app.createEnv('foo', function() {});

Env

Create an instance of Env with the given name, fn, app instance, and options. The Env class is used by base-generators to handle some of the heavy lifting for resolving generators.

Params

  • name {String}
  • fn {Function|Object|String}: Function to be lazily invoked, instance, or filepath that resolves to one of the other types when required.
  • app {Object}: Base instance to use for invocation context.
  • options {Object}

Example

var env = new Env('foo', function(app) {
  // do stuff to app
});

.isMatch

Returns true if the given str matches any of the following properties, in order:

  • env.key
  • env.name
  • env.alias
  • env.dirname
  • env.path
  • env.basename

Params

  • str {String}: The string to match
  • returns {Boolean}: Retuns true if a match is made.

Example

var env = new Env('foo', fucntion(){});
console.log(env.isMatch('bar')) //=> false
console.log(env.isMatch('foo')) //=> true

.invoke

Invoke env.fn with the given context and options.

Params

  • context {Object}: The application instance to use for invoking env.fn
  • opptions {Object}
  • returns {Object}

Example

var app = new Base();
env.fn(app, {doStuff: true});

.isDefault

Getter that is set to true when the env being loaded is in the user's working directory.

  • returns {Boolean}

Example

var env = new Env('generator.js', generatorFn, {cwd: process.cwd()});
console.log(env.isDefault);
//=> true

.namespace

Getter for resolving the namespace of an env. A namespace is created by joining the namespace from a parent instance (if exists) to env.alias (e.g. parent.namespace + '.' + env.alias).

var env = new Env('foo', function() {});

* `returns` **{String}**  

## About
### Related projects
- [base-generators](https://www.npmjs.com/package/base-generators): Adds project-generator support to your `base` application. | [homepage](https://github.com/node-base/base-generators "Adds project-generator support to your `base` application.")
- [base-runner](https://www.npmjs.com/package/base-runner): Orchestrate multiple instances of base at once. | [homepage](https://github.com/node-base/base-runner "Orchestrate multiple instances of base at once.")
- [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks")

### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Contributors
| **Commits** | **Contributor** |  
| --- | --- |  
| 37 | [jonschlinkert](https://github.com/jonschlinkert) |  
| 6  | [doowb](https://github.com/doowb) |  

### Release history

### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.7.0, on July 19, 2018.