Skip to content

Commit e0df4bd

Browse files
Avaqdavidchambers
andcommitted
Improve code formatting based on suggestions
Co-authored-by: David Chambers <[email protected]>
1 parent 3bae914 commit e0df4bd

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

lib/doctest.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function iifeWrap(s) {
138138
}
139139

140140
// toModule :: (String, String?, Array String) -> String
141-
function toModule(source, moduleType, logFunctions) {
141+
function toModule(source, moduleType, logFunctionNames) {
142142
switch (moduleType) {
143143
case 'amd':
144144
return common.unlines ([
@@ -160,10 +160,10 @@ function toModule(source, moduleType, logFunctions) {
160160
' enqueue: function(io) { this.queue.push(io); },',
161161
' logMediator: {emit: function() {}}',
162162
'};',
163-
logFunctions.map (function(logFunction) {
163+
logFunctionNames.map (function(logFunctionName) {
164164
return '\n' + common.unlines ([
165-
'var ' + logFunction + ' = function(value) {',
166-
' __doctest.logMediator.emit ("' + logFunction + '", value);',
165+
'var ' + logFunctionName + ' = function(value) {',
166+
' __doctest.logMediator.emit ("' + logFunctionName + '", value);',
167167
'};'
168168
]);
169169
}).join (''),
@@ -577,27 +577,27 @@ function rewrite$coffee(options, input) {
577577
);
578578
}
579579

580-
function functionEval(options, source, logFunctions) {
580+
function functionEval(options, source, logFunctionNames) {
581581
// Functions created via the Function function are always run in the
582582
// global context, which ensures that doctests can't access variables
583583
// in _this_ context.
584584
//
585585
// The `evaluate` function takes as arguments all the logger functions and
586586
// the doctest runtime broker as `__doctest`.
587-
var argNames = logFunctions.concat (['__doctest', source]);
587+
var argNames = logFunctionNames.concat (['__doctest', source]);
588588
var evaluate = Function.apply (null, argNames);
589589

590590
var queue = [];
591591
var logMediator = {emit: function() {}};
592592
var runtimeBroker = {enqueue: function(io) { queue.push (io); }};
593593

594-
var loggers = logFunctions.map (function(logFunction) {
594+
var logFunctions = logFunctionNames.map (function(logFunctionName) {
595595
return function log(value) {
596-
logMediator.emit (logFunction, value);
596+
logMediator.emit (logFunctionName, value);
597597
};
598598
});
599599

600-
evaluate.apply (null, loggers.concat ([runtimeBroker]));
600+
evaluate.apply (null, logFunctions.concat ([runtimeBroker]));
601601

602602
return run (options, queue, logMediator);
603603
}

lib/doctest.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ export default async function(path, options) {
4040
}
4141
}
4242

43-
function wrap(source, logFunctions) {
43+
function wrap(source, logFunctionNames) {
4444
return common.unlines ([
4545
'export const __doctest = {',
4646
' queue: [],',
4747
' enqueue: function(io) { this.queue.push(io); },',
4848
' logMediator: {emit: function() {}}',
4949
'};',
50-
logFunctions.map (function(logFunction) {
50+
logFunctionNames.map (function(logFunctionName) {
5151
return '\n' + common.unlines ([
52-
'const ' + logFunction + ' = value => {',
53-
' __doctest.logMediator.emit ("' + logFunction + '", value);',
52+
'const ' + logFunctionName + ' = value => {',
53+
' __doctest.logMediator.emit ("' + logFunctionName + '", value);',
5454
'};'
5555
]);
5656
}).join (''),

lib/program.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var program = require ('commander');
55
var pkg = require ('../package.json');
66

77

8-
function collect(value, previous) {
9-
return previous.concat ([value]);
8+
function append(x, xs) {
9+
return xs.concat ([x]);
1010
}
1111

1212
program
@@ -23,9 +23,9 @@ program
2323
.option (' --closing-delimiter <delimiter>',
2424
'specify line following doctest block (e.g. "```")')
2525
.option (' --log-function <name>',
26-
'inject a log function of the given name into your doctests' +
27-
', can be supplied multiple times',
28-
collect,
26+
'expose a log function with the given name to your doctests' +
27+
' (can be specified multiple times)',
28+
append,
2929
[])
3030
.option (' --log-timeout <milliseconds>',
3131
'specify an alternative log timeout time (defaults to 100)',

0 commit comments

Comments
 (0)