From de1704f007523da4e8309d799adc24e9adcb0ea7 Mon Sep 17 00:00:00 2001 From: David Majda Date: Thu, 6 Aug 2015 17:22:06 +0200 Subject: [PATCH] Replace |util.{puts,error}| by |console.{log,error}| MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The |util.puts| and |util.error| functions are deprecated in Node.js 0.12.x. Based on a pull request by Jan Stránský (@burningtree): https://github.com/pegjs/pegjs/pull/334 --- benchmark/run | 41 ++++++++++++++++----------------- bin/pegjs | 63 +++++++++++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/benchmark/run b/benchmark/run index c1f6025..e977cae 100755 --- a/benchmark/run +++ b/benchmark/run @@ -2,9 +2,8 @@ "use strict"; -var util = require("util"); -var fs = require("fs"); -var PEG = require("../lib/peg"); +var fs = require("fs"); +var PEG = require("../lib/peg"); var benchmarks = require("./benchmarks.js"); var Runner = require("./runner.js")(PEG); @@ -35,21 +34,21 @@ function center(text, length) { } function writeTableHeader() { - util.puts("┌─────────────────────────────────────┬───────────┬────────────┬──────────────┐"); - util.puts("│ Test │ Inp. size │ Avg. time │ Avg. speed │"); + console.log("┌─────────────────────────────────────┬───────────┬────────────┬──────────────┐"); + console.log("│ Test │ Inp. size │ Avg. time │ Avg. speed │"); } function writeHeading(heading) { - util.puts("├─────────────────────────────────────┴───────────┴────────────┴──────────────┤"); - util.puts("│ " + center(heading, 75) + " │"); - util.puts("├─────────────────────────────────────┬───────────┬────────────┬──────────────┤"); + console.log("├─────────────────────────────────────┴───────────┴────────────┴──────────────┤"); + console.log("│ " + center(heading, 75) + " │"); + console.log("├─────────────────────────────────────┬───────────┬────────────┬──────────────┤"); } function writeResult(title, inputSize, parseTime) { var KB = 1024; var MS_IN_S = 1000; - util.puts("│ " + console.log("│ " + padRight(title, 35) + " │ " + padLeft((inputSize / KB).toFixed(2), 6) @@ -62,25 +61,25 @@ function writeResult(title, inputSize, parseTime) { } function writeSeparator() { - util.puts("├─────────────────────────────────────┼───────────┼────────────┼──────────────┤"); + console.log("├─────────────────────────────────────┼───────────┼────────────┼──────────────┤"); } function writeTableFooter() { - util.puts("└─────────────────────────────────────┴───────────┴────────────┴──────────────┘"); + console.log("└─────────────────────────────────────┴───────────┴────────────┴──────────────┘"); } /* Helpers */ function printHelp() { - util.puts("Usage: run [options]"); - util.puts(""); - util.puts("Runs PEG.js benchmark suite."); - util.puts(""); - util.puts("Options:"); - util.puts(" -n, --run-count number of runs (default: 10)"); - util.puts(" --cache make tested parsers cache results"); - util.puts(" -o, --optimize select optimization for speed or size (default:"); - util.puts(" speed)"); + console.log("Usage: run [options]"); + console.log(""); + console.log("Runs PEG.js benchmark suite."); + console.log(""); + console.log("Options:"); + console.log(" -n, --run-count number of runs (default: 10)"); + console.log(" --cache make tested parsers cache results"); + console.log(" -o, --optimize select optimization for speed or size (default:"); + console.log(" speed)"); } function exitSuccess() { @@ -92,7 +91,7 @@ function exitFailure() { } function abort(message) { - util.error(message); + console.error(message); exitFailure(); } diff --git a/bin/pegjs b/bin/pegjs index 3eb8452..e934ed9 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -2,7 +2,6 @@ "use strict"; -var util = require("util"); var fs = require("fs"); var path = require("path"); var PEG = require("../lib/peg"); @@ -10,39 +9,39 @@ var PEG = require("../lib/peg"); /* Helpers */ function printVersion() { - util.puts("PEG.js " + PEG.VERSION); + console.log("PEG.js " + PEG.VERSION); } function printHelp() { - util.puts("Usage: pegjs [options] [--] [] []"); - util.puts(""); - util.puts("Generates a parser from the PEG grammar specified in the and writes"); - util.puts("it to the ."); - util.puts(""); - util.puts("If the is omitted, its name is generated by changing the"); - util.puts(" extension to \".js\". If both and are"); - util.puts("omitted, standard input and output are used."); - util.puts(""); - util.puts("Options:"); - util.puts(" -e, --export-var name of the variable where the parser"); - util.puts(" object will be stored (default:"); - util.puts(" \"module.exports\")"); - util.puts(" --cache make generated parser cache results"); - util.puts(" --allowed-start-rules comma-separated list of rules the generated"); - util.puts(" parser will be allowed to start parsing"); - util.puts(" from (default: the first rule in the"); - util.puts(" grammar)"); - util.puts(" -o, --optimize select optimization for speed or size"); - util.puts(" (default: speed)"); - util.puts(" --trace enable tracing in generated parser"); - util.puts(" --plugin use a specified plugin (can be specified"); - util.puts(" multiple times)"); - util.puts(" --extra-options additional options (in JSON format) to pass"); - util.puts(" to PEG.buildParser"); - util.puts(" --extra-options-file file with additional options (in JSON"); - util.puts(" format) to pass to PEG.buildParser"); - util.puts(" -v, --version print version information and exit"); - util.puts(" -h, --help print help and exit"); + console.log("Usage: pegjs [options] [--] [] []"); + console.log(""); + console.log("Generates a parser from the PEG grammar specified in the and writes"); + console.log("it to the ."); + console.log(""); + console.log("If the is omitted, its name is generated by changing the"); + console.log(" extension to \".js\". If both and are"); + console.log("omitted, standard input and output are used."); + console.log(""); + console.log("Options:"); + console.log(" -e, --export-var name of the variable where the parser"); + console.log(" object will be stored (default:"); + console.log(" \"module.exports\")"); + console.log(" --cache make generated parser cache results"); + console.log(" --allowed-start-rules comma-separated list of rules the generated"); + console.log(" parser will be allowed to start parsing"); + console.log(" from (default: the first rule in the"); + console.log(" grammar)"); + console.log(" -o, --optimize select optimization for speed or size"); + console.log(" (default: speed)"); + console.log(" --trace enable tracing in generated parser"); + console.log(" --plugin use a specified plugin (can be specified"); + console.log(" multiple times)"); + console.log(" --extra-options additional options (in JSON format) to pass"); + console.log(" to PEG.buildParser"); + console.log(" --extra-options-file file with additional options (in JSON"); + console.log(" format) to pass to PEG.buildParser"); + console.log(" -v, --version print version information and exit"); + console.log(" -h, --help print help and exit"); } function exitSuccess() { @@ -54,7 +53,7 @@ function exitFailure() { } function abort(message) { - util.error(message); + console.error(message); exitFailure(); }