Permalink
Browse files

new Feature( "trailer.MimeDictionary" )

Fixes #18.
  • Loading branch information...
tylermwashburn
tylermwashburn committed Dec 17, 2011
1 parent 893fad8 commit 96893f52c39ac43dbdcf20d10432a819fa403bd7
Showing with 29 additions and 0 deletions.
  1. +29 −0 Trailer.js
View
@@ -42,6 +42,35 @@ trailer.EventEmitter = function () {
return mark
}
+trailer.MimeDictionary = function ( map ) {
+ this.dictionary = {
+ extensions: this,
+ mimes: {}
+ }
+
+ this.define( map )
+}
+
+trailer.MimeDictionary.prototype.define = function ( type, extensions ) {
+ var prop;
+
+ if ( String.is( type ) ) {
+ if ( String.is( extensions ) ) {
+ extensions = [ extensions ]
+ }
+
+ extensions.forEach( function ( extension ) {
+ this.dictionary.extensions[ extension ] = type
+ }, this )
+
+ this.dictionary.mimes[ type ] = extensions[ 0 ]
+ } else {
+ for ( prop in type ) {
+ this.define( prop, type[ prop ] )
+ }
+ }
+}
+
trailer.hitch = function ( root, conf ) {
var prop, indexes;

0 comments on commit 96893f5

Please sign in to comment.