Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple instances of MIME types container #27

Closed
ixti opened this issue Apr 24, 2012 · 3 comments
Closed

Allow multiple instances of MIME types container #27

ixti opened this issue Apr 24, 2012 · 3 comments

Comments

@ixti
Copy link
Contributor

ixti commented Apr 24, 2012

Hi,

Is it possible to add subj? If so I could prepare a pull request. The idea is to have default, filled in mime instance and provide a class that could be used to have absolutely own non-defaults mime types object something like this: https://github.com/nodeca/static-lulz/blob/master/lib/static_lulz/mime.js.

@broofa
Copy link
Owner

broofa commented Apr 24, 2012

Hi Alexei,

I'm not sure how elegant this is, but we could do something like this:

function Mime() {
  // etc...
}
Mime.prototype.lookup = function() {...};
//  Other mime-methods hang of prototype, etc.

// Create, load, and export the default instance
var mime = new Mime();
mime.load(... 'mime.types');
mime.load(... 'node.types');
module.exports = mime;

Then to create a custom instance, just instantiate the constructor, like so:

var myMime = new (require('mime').constructor);
myMime.load(...);
// etc ...

Thoughts?

@ixti
Copy link
Contributor Author

ixti commented Apr 24, 2012

Hi,

Thanks for quick response. I thought about something really similar:

function Mime() {
  // ...
}

Mime.prototype.lookup = function () {
  // ...
};

// ... other prototype methods
// Create, load, and export the default instance
var mime = new Mime();
mime.load(... 'mime.types');
mime.load(... 'node.types');

So it's in fact identical to with only difference - export Mime constructor as Mime property of exported module, so to create a custom instance it would be:

var myMime = new (require('mime').Mime);
// ...

So it will look really similar to standard modules like EventEmitter etc.

@broofa
Copy link
Owner

broofa commented Apr 29, 2012

#28

@broofa broofa closed this as completed Apr 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants