78 |
79 |
|
}; |
79 |
80 |
|
if ( arguments.length ) { |
80 |
81 |
|
if ( !isObject( options ) ) { |
81 |
|
- |
throw new TypeError( 'invalid argument. Must provide an object. Value: `' + options + '`.' ); |
|
82 |
+ |
throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', options ) ); |
82 |
83 |
|
} |
83 |
84 |
|
if ( hasOwnProp( options, 'copy' ) ) { |
84 |
85 |
|
opts.copy = options.copy; |
85 |
86 |
|
if ( !isBoolean( options.copy ) ) { |
86 |
|
- |
throw new TypeError( 'invalid option. `copy` option must be a boolean. Option: `' + options.copy + '`.' ); |
|
87 |
+ |
throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'copy', options.copy ) ); |
87 |
88 |
|
} |
88 |
89 |
|
} |
89 |
90 |
|
if ( hasOwnProp( options, 'prng' ) ) { |
90 |
91 |
|
if ( !isFunction( options.prng ) ) { |
91 |
|
- |
throw new TypeError( 'invalid option. `prng` option must be a pseudorandom number generator function. Option: `' + options.prng + '`.' ); |
|
92 |
+ |
throw new TypeError( format( 'invalid option. `%s` option must be a pseudorandom number generator function. Option: `%s`.', 'prng', options.prng ) ); |
92 |
93 |
|
} |
93 |
94 |
|
randu = options.prng; |
94 |
95 |
|
} |
95 |
96 |
|
// If provided a PRNG, ignore the `state` option, as we don't support getting or setting PRNG state. |
96 |
97 |
|
else if ( hasOwnProp( options, 'state' ) ) { |
97 |
98 |
|
opts.state = options.state; |
98 |
99 |
|
if ( !isUint32Array( options.state ) ) { |
99 |
|
- |
throw new TypeError( 'invalid option. `state` option must be a Uint32Array. Option: `' + options.state + '`.' ); |
|
100 |
+ |
throw new TypeError( format( 'invalid option. `%s` option must be a Uint32Array. Option: `%s`.', 'state', options.state ) ); |
100 |
101 |
|
} |
101 |
102 |
|
} |
102 |
103 |
|
// If provided a PRNG, ignore the `seed` option, as a `seed`, by itself, is insufficient to guarantee reproducibility. If provided a state, ignore the `seed` option, as a PRNG state should contain seed information. |
103 |
104 |
|
else if ( hasOwnProp( options, 'seed' ) ) { |
104 |
105 |
|
opts.seed = options.seed; |
105 |
106 |
|
if ( options.seed === void 0 ) { |
106 |
|
- |
throw new TypeError( 'invalid option. `seed` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: `' + options.seed + '`.' ); |
|
107 |
+ |
throw new TypeError( format( 'invalid option. `%s` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: `%s`.', 'seed', options.seed ) ); |
107 |
108 |
|
} |
108 |
109 |
|
} |
109 |
110 |
|
} |
5759866
76b02ee
b13defc
6ab7d1c