Skip to content

Commit

Permalink
change overrides usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Jan 25, 2017
1 parent 107a140 commit ec1a75f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ npm install census-boundaries
```js
import census from 'census-boundaries'

// specify your own options if you want
const overrides = {
objects: [
'STATE',
'PLACE'
]
}

census(overriders, {
census({
// this function is called every time a record is parsed
onBoundary: (objectType, doc, cb) => {
cb() // make sure to call the cb
Expand Down
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _plural = require('plural');

var _plural2 = _interopRequireDefault(_plural);

var _lodash = require('lodash.defaultsdeep');
var _lodash = require('lodash.clone');

var _lodash2 = _interopRequireDefault(_lodash);

Expand All @@ -64,14 +64,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

var debug = (0, _debug3.default)('census');

exports.default = function (overrides, _ref) {
var onBoundary = _ref.onBoundary,
exports.default = function (_ref) {
var objects = _ref.objects,
onBoundary = _ref.onBoundary,
onFinish = _ref.onFinish;

if (!onBoundary) throw new Error('Missing onBoundary!');
if (!onFinish) throw new Error('Missing onFinish!');
onFinish = (0, _once2.default)(onFinish);
var options = (0, _lodash2.default)({}, overrides, _defaultConfig2.default);

var options = (0, _lodash2.default)(_defaultConfig2.default);
if (objects) options.objects = objects;

debug(_chalk2.default.bold('Establishing connection:'));
debug(' -- ' + _chalk2.default.cyan('US Census Bureau @ ' + options.ftp.host));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"chalk": "^1.1.3",
"debug": "^2.2.0",
"ftp": "^0.3.10",
"lodash.defaultsdeep": "^4.4.0",
"lodash.clone": "^4.5.0",
"meow": "^3.7.0",
"once": "^1.3.3",
"plural": "^0.2.0",
Expand Down
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ import request from 'superagent'
import JSONStream from 'JSONStream'
import map from 'through2-asyncmap'
import plural from 'plural'
import defaultsDeep from 'lodash.defaultsdeep'
import clone from 'lodash.clone'
import once from 'once'
import config from './defaultConfig'
import getFTP from './getFTP'
import _debug from 'debug'
const debug = _debug('census')

export default (overrides, { onBoundary, onFinish }) => {
export default ({ objects, onBoundary, onFinish }) => {
if (!onBoundary) throw new Error('Missing onBoundary!')
if (!onFinish) throw new Error('Missing onFinish!')
onFinish = once(onFinish)
const options = defaultsDeep({}, overrides, config)

const options = clone(config)
if (objects) options.objects = objects

debug(chalk.bold('Establishing connection:'))
debug(` -- ${chalk.cyan(`US Census Bureau @ ${options.ftp.host}`)}`)
Expand Down

0 comments on commit ec1a75f

Please sign in to comment.