File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,19 +34,14 @@ module.exports = function(env) {
3434 // Expects either a kernel name or an object containing a single
3535 // key/value pair where the key is a kernel name and the value is
3636 // an options object. e.g. 'MH' or { MH: { ... } }
37-
38- function isKernelOption ( obj ) {
39- return _ . isString ( obj ) && _ . has ( kernels , obj ) ||
40- _ . size ( obj ) === 1 && _ . has ( kernels , _ . keys ( obj ) [ 0 ] ) ;
41- }
42-
43- if ( ! isKernelOption ( obj ) ) {
44- throw new Error ( 'Unrecognized kernel option: ' + JSON . stringify ( obj ) ) ;
45- }
46-
47- var name = _ . isString ( obj ) ? obj : _ . keys ( obj ) [ 0 ] ;
48- var options = _ . isString ( obj ) ? { } : _ . values ( obj ) [ 0 ] ;
49- return kernels [ name ] ( options ) ;
37+ return util . getValAndOpts ( obj , function ( name , options ) {
38+ if ( ! _ . has ( kernels , name ) ) {
39+ throw new Error ( name + ' is not a valid kernel. ' +
40+ 'The following kernels are available: ' +
41+ _ . keys ( kernels ) . join ( ', ' ) + '.' ) ;
42+ }
43+ return kernels [ name ] ( options ) ;
44+ } ) ;
5045 }
5146
5247 // Combinators for kernel functions.
You can’t perform that action at this time.
0 commit comments