From 426cb13e2392e84e66431538aa15913061bae3e2 Mon Sep 17 00:00:00 2001 From: Rafid Aslam Date: Sat, 3 Dec 2016 21:52:56 +0700 Subject: [PATCH] Remove `enforce_arity` function from util.js. Remove `enforce_arity` function from util.js, because it is not used anymore. --- frontend_tests/node_tests/util.js | 27 --------------------------- static/js/util.js | 11 ----------- 2 files changed, 38 deletions(-) diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js index 3f53efe2e0..f19616353f 100644 --- a/frontend_tests/node_tests/util.js +++ b/frontend_tests/node_tests/util.js @@ -116,33 +116,6 @@ var _ = global._; }); }()); -(function test_enforce_arity() { - function f1() {} - var eaf1 = util.enforce_arity(f1); - - assert.doesNotThrow(function () { f1('foo'); }); - assert.doesNotThrow(function () { eaf1(); }); - assert.throws(function () { eaf1('foo'); }, /called with \d+ arguments/); - assert.throws(function () { eaf1('foo', 'bar'); }, /called with \d+ arguments/); - - function f2(x) {} - var eaf2 = util.enforce_arity(f2); - - assert.doesNotThrow(function () { f2(); }); - assert.doesNotThrow(function () { eaf2('foo'); }); - assert.throws(function () { eaf2(); }, /called with \d+ arguments/); - assert.throws(function () { eaf2('foo', 'bar'); }, /called with \d+ arguments/); - - function f3(x, y) {} - var eaf3 = util.enforce_arity(f3); - - assert.doesNotThrow(function () { f3(); }); - assert.doesNotThrow(function () { eaf3('foo', 'bar'); }); - assert.throws(function () { eaf3(); }, /called with \d+ arguments/); - assert.throws(function () { eaf3('foo'); }, /called with \d+ arguments/); - assert.throws(function () { eaf3('foo','bar', 'baz'); }, /called with \d+ arguments/); -}()); - (function test_all_and_everyone_mentions_regexp() { var messages_with_all_mentions = [ '@all', diff --git a/static/js/util.js b/static/js/util.js index 084ad82a03..9be0e8ed87 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -214,17 +214,6 @@ exports.CachedValue.prototype = { } }; -exports.enforce_arity = function util_enforce_arity(func) { - return function () { - if (func.length !== arguments.length) { - throw new Error("Function '" + func.name + "' called with " - + arguments.length + " arguments, but expected " - + func.length); - } - return func.apply(this, arguments); - }; -}; - exports.execute_early = function (func) { if (page_params.test_suite) { $(document).one('phantom_page_loaded', func);