Skip to content

Commit 95bf8b5

Browse files
committed
Optimize functors
1 parent 8d2f375 commit 95bf8b5

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

JavaScript/f-functor.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
'use strict';
22

3-
const util = require('util');
4-
5-
function Functor() {
6-
}
3+
function Functor() {}
74

85
Functor.prototype.method = function() {
96
console.log('Functor.prototype.method');
107
console.dir({
118
property: this.property,
12-
exec: this.method
9+
method: this.method
1310
});
1411
this(); // you can call this as a function
1512
};
1613

17-
util.inherits(Functor, Function);
18-
1914
const factory = () => {
2015

2116
const functor = function() {
@@ -29,6 +24,7 @@ const factory = () => {
2924

3025
Object.setPrototypeOf(functor, Functor.prototype);
3126
return functor;
27+
3228
};
3329

3430
// Usage

JavaScript/g-functor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const factory = () => {
2424

2525
Object.setPrototypeOf(functor, Functor.prototype);
2626
return functor;
27+
2728
};
2829

2930
// Usage

0 commit comments

Comments
 (0)