Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurits Rijk committed Jun 2, 2017
1 parent 39572da commit dc57665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ const {gen} = require('./gen');
const describe = require('./util/describe');

function question(spec) {
const predicate = getSpec(spec);
return {
op: 'question',
conform: values => {
if (values.length === 0) {
return null;
} else if (values.length === 1) {
return conform(predicate, values[0]);
return conform(spec, values[0]);
} else {
return invalidString;
}
Expand Down
12 changes: 4 additions & 8 deletions lib/unform.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
const _ = require('lodash');

const {getSpec} = require('./def');
const {spec: specize} = require('./def');

function unform(spec, value) {
if (_.isFunction(spec)) {
return value;
} else {
const predicate = getSpec(spec).unform;
return predicate ? predicate(value) : value;
}
function unform(pred, value) {
const predicate = specize(pred).unform;
return predicate ? predicate(value) : value;
}

module.exports = unform;

0 comments on commit dc57665

Please sign in to comment.