UNPKG

namify

Version:

Convert a npm package name into a safe-to-use variable name. Use as a mixin in Yeoman generators.

45 lines (31 loc) 864 B
# {%= name %} {%= badge('fury') %} > {%= description %} ## Install {%= include("install") %} Install with [bower](https://github.com/bower/bower) ```bash npm i {%= name %} --save-dev ``` ## Usage ```js var {%= name %} = require('{%= name %}'); console.log({%= name %}('foo-bar-bar')); //=> fooBarBaz ``` If the resulting variable name matches an [ECMAscript reserved word](https://github.com/jonschlinkert/reserved), an underscore will be prepended to the variable name. ### Yeoman generators Use as a mixin in Yeoman generators: ```js // in the contructor this._.mixin({%= name %}); // in templates you can now do something like: var <%= _.{%= name %}(appName) %> = require('<%= appname %>'); //=> var fooBarBaz = require('foo-bar-baz'); ``` ## Author {%= contrib("jon") %} ## License {%= copyright() %} {%= license() %} *** {%= include("footer") %}