From d346d2a66dfc79ba9284031095f026c7eade7f3c Mon Sep 17 00:00:00 2001 From: David Majda Date: Tue, 30 Aug 2016 08:17:22 +0200 Subject: [PATCH] Replace objects.keys with Object.keys See #441. --- bin/pegjs | 3 +-- lib/compiler/passes/generate-bytecode.js | 6 +++--- lib/compiler/passes/generate-js.js | 6 +++--- lib/utils/objects.js | 12 ------------ 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/bin/pegjs b/bin/pegjs index 1807da2..6ea1ec1 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -5,7 +5,6 @@ var fs = require("fs"); var path = require("path"); var peg = require("../lib/peg"); -var objects = require("../lib/utils/objects"); /* Helpers */ @@ -256,7 +255,7 @@ while (args.length > 0 && isOption(args[0])) { nextArg(); } -if (objects.keys(options.dependencies).length > 0) { +if (Object.keys(options.dependencies).length > 0) { if (options.format !== "amd" && options.format !== "commonjs" && options.format !== "umd") { abort("Can't use the -d/--dependency option with the \"" + options.format + "\" module format."); } diff --git a/lib/compiler/passes/generate-bytecode.js b/lib/compiler/passes/generate-bytecode.js index bef6284..7bf673e 100644 --- a/lib/compiler/passes/generate-bytecode.js +++ b/lib/compiler/passes/generate-bytecode.js @@ -254,7 +254,7 @@ function generateBytecode(ast) { } function buildSemanticPredicate(code, negative, context) { - var functionIndex = addFunctionConst(objects.keys(context.env), code); + var functionIndex = addFunctionConst(Object.keys(context.env), code); return buildSequence( [op.UPDATE_SAVED_POS], @@ -347,7 +347,7 @@ function generateBytecode(ast) { env: env, action: node }), - functionIndex = addFunctionConst(objects.keys(env), node.code); + functionIndex = addFunctionConst(Object.keys(env), node.code); return emitCall ? buildSequence( @@ -396,7 +396,7 @@ function generateBytecode(ast) { } else { if (context.action) { functionIndex = addFunctionConst( - objects.keys(context.env), + Object.keys(context.env), context.action.code ); diff --git a/lib/compiler/passes/generate-js.js b/lib/compiler/passes/generate-js.js index feb6994..5f34c29 100644 --- a/lib/compiler/passes/generate-js.js +++ b/lib/compiler/passes/generate-js.js @@ -1260,7 +1260,7 @@ function generateJS(ast, options) { commonjs: function() { var parts = [], - dependencyVars = objects.keys(options.dependencies), + dependencyVars = Object.keys(options.dependencies), requires = dependencyVars.map( function(variable) { return variable @@ -1294,7 +1294,7 @@ function generateJS(ast, options) { amd: function() { var dependencyIds = objects.values(options.dependencies), - dependencyVars = objects.keys(options.dependencies), + dependencyVars = Object.keys(options.dependencies), dependencies = '[' + dependencyIds.map( function(id) { return '"' + js.stringEscape(id) + '"'; } @@ -1332,7 +1332,7 @@ function generateJS(ast, options) { umd: function() { var parts = [], dependencyIds = objects.values(options.dependencies), - dependencyVars = objects.keys(options.dependencies), + dependencyVars = Object.keys(options.dependencies), dependencies = '[' + dependencyIds.map( function(id) { return '"' + js.stringEscape(id) + '"'; } diff --git a/lib/utils/objects.js b/lib/utils/objects.js index 09587c1..6973095 100644 --- a/lib/utils/objects.js +++ b/lib/utils/objects.js @@ -2,18 +2,6 @@ /* Object utilities. */ var objects = { - keys: function(object) { - var result = [], key; - - for (key in object) { - if (object.hasOwnProperty(key)) { - result.push(key); - } - } - - return result; - }, - values: function(object) { var result = [], key;