Skip to content

Commit

Permalink
feat: Bind exported methods
Browse files Browse the repository at this point in the history
So that code like this, which is increasingly common, doesn't fail
because `this` isn't bound to the right object.

```
const {getType} = require("mime");

getType("hello.txt");
```
  • Loading branch information
marijnh committed Apr 12, 2018
1 parent abcb6e1 commit 9d2a7b8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Mime.js
Expand Up @@ -11,6 +11,10 @@ function Mime() {
for (var i = 0; i < arguments.length; i++) {
this.define(arguments[i]);
}

this.define = this.define.bind(this);
this.getType = this.getType.bind(this);
this.getExtension = this.getExtension.bind(this);
}

/**
Expand Down

0 comments on commit 9d2a7b8

Please sign in to comment.