## Usage ```js var Config = require('./'); var config = new Config(); console.log(config.expand(require('./package'))); ``` ## Schema Values are parsed using a [schema](lib/schema.js) that is passed to [map-schema][] (builds on the schema from [normalize-pkg][] as a starting point): - only properties that have a corresponding field on the schema will be parsed. - any properties that do not have a corresponding field are returned unmodified. See the [.field docs](#field) to learn how to add or overwrite a field on the schema. ## Defaults A `default` value may optionally be defined when a `.field` is registered. When `.expand` is run and a property that is required or recommended by npm is missing, `expand-pkg` attempts to create the field if valid data can be found in the repository. The following fields are the only built-in fields with default values: - `version`: `'0.1.0'` - `license`: `'MIT'` - `engines`: `{node: '>= 0.10.0'}` ## API {%= apidocs("index.js") %} ## Options ### options.knownOnly **Type**: `boolean` **Default**: `undefined` Omit properties from package.json that do not have a field registered on the schema. ```js var Config = require('{%= name %}'); var config = new Config({knownOnly: true}); console.log(config.expand({author: 'Brian Woodward', foo: 'bar'})); //=> {author: {name: 'Brian Woodward'}} ``` ### options.pick **Type**: `array` **Default**: `undefined` Filter the resulting object to contain only the specified keys. ### options.omit **Type**: `array` **Default**: `undefined` Remove the specified keys from the resulting object. ### options.fields Pass a `fields` object on the options to customize any fields on the schema (also see [options.extend](#options-extend)): ```js var pkg = config.expand(require('./package'), { extend: true, fields: { name: { normalize: function() { return 'bar' } } } }); console.log(pkg.name); //=> 'bar' ``` ### options.extend **Type**: `boolean` **Default**: `undefined` Used with [options.field](#options-field), pass ` true` if you want to extend a field that is already defined on the schema. ```js var pkg = config.expand(require('./package'), { extend: true, fields: { name: { normalize: function() { return 'bar' } } } }); console.log(pkg.name); //=> 'bar' ```