From ec1a75fed1cbcb8be212388d706086cce3f0b6ef Mon Sep 17 00:00:00 2001 From: Contra Date: Wed, 25 Jan 2017 13:06:15 -0500 Subject: [PATCH] change overrides usage --- README.md | 10 +--------- dist/index.js | 11 +++++++---- package.json | 2 +- src/index.js | 8 +++++--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3a20f60..c0cc7eb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/dist/index.js b/dist/index.js index 5b3168b..34a7828 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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); @@ -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)); diff --git a/package.json b/package.json index c4f2d97..d8e2867 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 863676b..8450a75 100644 --- a/src/index.js +++ b/src/index.js @@ -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}`)}`)