From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../components/flight/lib/advice.js | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/flight/lib/advice.js (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/flight/lib/advice.js') diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/flight/lib/advice.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/flight/lib/advice.js new file mode 100644 index 0000000000..0f4686929a --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/flight/lib/advice.js @@ -0,0 +1,69 @@ +// ========================================== +// Copyright 2013 Twitter, Inc +// Licensed under The MIT License +// http://opensource.org/licenses/MIT +// ========================================== + +"use strict"; + +define( + + [ + './utils', + './compose' + ], + + function (util, compose) { + + var advice = { + + around: function(base, wrapped) { + return function composedAround() { + // unpacking arguments by hand benchmarked faster + var i = 0, l = arguments.length, args = new Array(l + 1); + args[0] = base.bind(this); + for (; i < l; i++) args[i + 1] = arguments[i]; + + return wrapped.apply(this, args); + } + }, + + before: function(base, before) { + var beforeFn = (typeof before == 'function') ? before : before.obj[before.fnName]; + return function composedBefore() { + beforeFn.apply(this, arguments); + return base.apply(this, arguments); + } + }, + + after: function(base, after) { + var afterFn = (typeof after == 'function') ? after : after.obj[after.fnName]; + return function composedAfter() { + var res = (base.unbound || base).apply(this, arguments); + afterFn.apply(this, arguments); + return res; + } + }, + + // a mixin that allows other mixins to augment existing functions by adding additional + // code before, after or around. + withAdvice: function() { + ['before', 'after', 'around'].forEach(function(m) { + this[m] = function(method, fn) { + + compose.unlockProperty(this, method, function() { + if (typeof this[method] == 'function') { + return this[method] = advice[m](this[method], fn); + } else { + return this[method] = fn; + } + }); + + }; + }, this); + } + }; + + return advice; + } +); -- cgit v1.2.3