detector.js 376 B

12345678910111213141516171819
  1. 'use strict';
  2. var typeMap = {};
  3. var types = require('./types');
  4. // load all available handlers
  5. types.forEach(function (type) {
  6. typeMap[type] = require('./types/' + type).detect;
  7. });
  8. module.exports = function (buffer, filepath) {
  9. var type, result;
  10. for (type in typeMap) {
  11. result = typeMap[type](buffer, filepath);
  12. if (result) {
  13. return type;
  14. }
  15. }
  16. };