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

map-config

v0.5.0

Published

Map configuration objects to application methods.

Downloads

144,284

Readme

map-config NPM version Build Status

Map configuration objects to application methods.

Install

Install with npm:

$ npm i map-config --save

Usage

var MapConfig = require('map-config');

API

MapConfig

Create a new instance of MapConfig with a specified map and application.

Params

  • app {Object}: Object containing the methods that will be called based on the map specification.
  • map {Object}: Optional object specifying how to map a configuration to an application.

Example

var mapper = new MapConfig(app, map);

.map

Map properties to methods and/or functions.

Params

  • key {String}: property key to map.
  • val {Function|Object}: Optional function to call when a config has the given key. Functions will be passed (val, key, config) when called. Functions may also take a callback to indicate async usage. May also pass another instance of MapConfig to be processed.
  • returns {Object} this: to enable chaining

Example

mapper
  .map('baz')
  .map('bang', function(val, key, config) {
  });

.alias

Create an alias for property key.

Params

  • alias {String}: Alias to use for key.
  • key {String}: Actual property or method on app.
  • returns {Object}: Returns the instance for chaining.

Example

mapper.alias('foo', 'bar');

.process

Process a configuration object with the already configured map and app.

Params

  • config {Object}: Configuration object to map to application methods.
  • cb {Function}: Optional callback function that will be called when finished or if an error occurs during processing.

Example

mapper.process(config);

.addKey

Add a key to the .keys array. May also be used to add an array of namespaced keys to the .keys array. Useful for mapping "sub-configs" to a key in a parent config.

Params

  • key {String}: key to push onto .keys
  • arr {Array}: Array of sub keys to push onto .keys
  • returns {Object} this: for chaining

Example

mapper.addKey('foo');
console.log(mapper.keys);
//=> ['foo']

var one = new MapConfig();
var two = new MapConfig();
two.map('foo');
two.map('bar');
two.map('baz');

// map config `two` to config `one`
one.map('two', function(val, key, config, next) {
  two.process(val, next);
});

// map keys from config `two` to config `one`
one.addKey('two', two.keys);
console.log(one.keys);
//=> ['two.foo', 'two.bar', 'two.baz']

Related projects

  • assemble: Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… more | homepage
  • generate: Fast, composable, highly extendable project generator with a user-friendly and expressive API. | homepage
  • templates: System for creating and managing template collections, and rendering templates with any node.js template engine.… more | homepage
  • update: Easily keep anything in your project up-to-date by installing the updaters you want to use… more | homepage
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.


This file was generated by verb, v0.1.0, on February 23, 2016.