+ window.addEventListener('DOMContentLoaded', function () {
+ applyTheme();
+ });
дополнял, возможно не увидели. const proxify = (entry, hooks = {}) => new Proxy(entry, {
get: (target, property, receiver) => {
const value = Reflect.get(target, property, receiver);
const type = typeof value;
if (type === 'function' || type === 'object') {
if (property in hooks) {
return proxify(function (...args) {
try {
return type === 'function' ? value.apply(this, args) : value;
} catch (error) {
hooks[property](...args);
throw error;
}
}, hooks);
} else {
return proxify(value, hooks);
}
} else {
return value;
}
},
apply: (target, context, args) => {
const value = Reflect.apply(target, context, args);
const type = typeof value;
if (type === 'function' || type === 'object') {
return proxify(value, hooks);
} else {
return value;
}
}
});
const chai = proxify(require('chai'), {
equal: (...args) => {
console.log('+----------------------+');
console.log('| ERROR IN EQUAL |');
console.log('+----------------------+');
console.table(args);
}
});
chai.expect(3).to.equal(6);
/*
+----------------------+
| ERROR IN EQUAL |
+----------------------+
┌─────────┬────────┐
│ (index) │ Values │
├─────────┼────────┤
│ 0 │ 6 │
└─────────┴────────┘
C:\Users\Seasle\Desktop\chai-test\index.js:14
throw error;
^
AssertionError: expected 3 to equal 6
at new AssertionError (C:\Users\Seasle\Desktop\chai-test\node_modules\assertion-error\index.js:71:11)
at Proxy.Assertion.assert (C:\Users\Seasle\Desktop\chai-test\node_modules\chai\lib\chai\assertion.js:152:13)
at Object.apply (C:\Users\Seasle\Desktop\chai-test\index.js:25:31)
at Proxy.assertEqual (C:\Users\Seasle\Desktop\chai-test\node_modules\chai\lib\chai\core\assertions.js:1038:12)
at Proxy.methodWrapper (C:\Users\Seasle\Desktop\chai-test\node_modules\chai\lib\chai\utils\addMethod.js:57:25)
at Proxy.<anonymous> (C:\Users\Seasle\Desktop\chai-test\index.js:10:60)
at Object.apply (C:\Users\Seasle\Desktop\chai-test\index.js:25:31)
at Object.<anonymous> (C:\Users\Seasle\Desktop\chai-test\index.js:47:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) {
showDiff: true,
actual: 3,
expected: 6,
operator: 'strictEqual'
}
*/
var f = 0;
for (var i = 0; i < gmailValues.length; i++) {
f += parseFloat(gmailValues[i]);
}