detect-file-type
Advanced tools
Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "detect-file-type", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Detect file type by signature", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,3 @@ # detect-file-type | ||
### Поддерживаемые типы (будет пополнятся) | ||
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar, rar, gz, bz2, 7z, dmg, mp4, m4v, midi, mkv, webm, wmv, mpg, mov, avi, mp3, m4a, opus, ogg, flac, wav, amr, pdf, exe, swf, rtf | ||
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar, rar, gz, bz2, 7z, dmg, mp4, m4v, midi, mkv, webm, wmv, mpg, mov, avi, mp3, m4a, opus, ogg, flac, wav, amr, pdf, exe, swf, rtf, woff, woff2, eot, ttf, otf, ico, ps, flv, xz, sqlite, nes, crx, cab, deb, rpm, Z, lz, msi | ||
@@ -9,0 +9,0 @@ ## Usage |
@@ -6,3 +6,3 @@ # detect-file-type [![Build Status](https://travis-ci.org/dimapaloskin/detect-file-type.svg?branch=master)](https://travis-ci.org/dimapaloskin/detect-file-type) | ||
### Supported types (will be updated) | ||
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar, rar, gz, bz2, 7z, dmg, mp4, m4v, midi, mkv, webm, wmv, mpg, mov, avi, mp3, m4a, opus, ogg, flac, wav, amr, pdf, exe, swf, rtf | ||
jpg, png, gif, bmp, webp, tif, cr2, jxr, psd, zip, epub, xpi, tar, rar, gz, bz2, 7z, dmg, mp4, m4v, midi, mkv, webm, wmv, mpg, mov, avi, mp3, m4a, opus, ogg, flac, wav, amr, pdf, exe, swf, rtf, woff, woff2, eot, ttf, otf, ico, ps, flv, xz, sqlite, nes, crx, cab, deb, rpm, Z, lz, msi | ||
@@ -9,0 +9,0 @@ ## Installation |
@@ -444,3 +444,204 @@ [ | ||
] | ||
}, | ||
{ | ||
"type": "woff", | ||
"ext": "woff", | ||
"mime": "application/font-woff", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "774f4646" }, | ||
{ "type": "or", "rules": | ||
[ | ||
{ "type": "equal", "start": 4, "end": 8, "bytes": "00010000" }, | ||
{ "type": "equal", "start": 4, "end": 8, "bytes": "4f54544f" } | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "woff2", | ||
"ext": "woff2", | ||
"mime": "application/font-woff", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "774f4632" }, | ||
{ "type": "or", "rules": | ||
[ | ||
{ "type": "equal", "start": 4, "end": 8, "bytes": "00010000" }, | ||
{ "type": "equal", "start": 4, "end": 8, "bytes": "4f54544f" } | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "eot", | ||
"ext": "eot", | ||
"mime": "application/octet-stream", | ||
"rules": [ | ||
{ "type": "equal", "start": 34, "end": 36, "bytes": "4c50" }, | ||
{ "type": "or", "rules": | ||
[ | ||
{ "type": "equal", "start": 8, "end": 11, "bytes": "000001" }, | ||
{ "type": "equal", "start": 8, "end": 11, "bytes": "010002" }, | ||
{ "type": "equal", "start": 8, "end": 11, "bytes": "020002" } | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "ttf", | ||
"ext": "ttf", | ||
"mime": "application/font-sfnt", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 5, "bytes": "0001000000" } | ||
] | ||
}, | ||
{ | ||
"type": "otf", | ||
"ext": "otf", | ||
"mime": "application/font-sfnt", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 5, "bytes": "4f54544f00" } | ||
] | ||
}, | ||
{ | ||
"type": "ico", | ||
"ext": "ico", | ||
"mime": "application/x-icon", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "00000100" } | ||
] | ||
}, | ||
{ | ||
"type": "flv", | ||
"ext": "flv", | ||
"mime": "application/x-flv", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "464c5601" } | ||
] | ||
}, | ||
{ | ||
"type": "ps", | ||
"ext": "ps", | ||
"mime": "application/postscript", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 2, "bytes": "2521" } | ||
] | ||
}, | ||
{ | ||
"type": "xz", | ||
"ext": "xz", | ||
"mime": "application/x-xz", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 6, "bytes": "fd377a585a00" } | ||
] | ||
}, | ||
{ | ||
"type": "sqlite", | ||
"ext": "sqlite", | ||
"mime": "application/x-sqlite3", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "53514c69" } | ||
] | ||
}, | ||
{ | ||
"type": "nes", | ||
"ext": "nes", | ||
"mime": "application/x-nintendo-nes-rom", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "4e45531a" } | ||
] | ||
}, | ||
{ | ||
"type": "crx", | ||
"ext": "crx", | ||
"mime": "application/x-google-chrome-extension", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "43723234" } | ||
] | ||
}, | ||
{ | ||
"type": "cab", | ||
"ext": "cab", | ||
"mime": "application/vnd.ms-cab-compressed", | ||
"rules": [ | ||
{ "type": "or", "rules": | ||
[ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "4d534346" }, | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "49536328" } | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "ar", | ||
"ext": "ar", | ||
"mime": "application/x-unix-archive", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 7, "bytes": "213c617263683e" }, | ||
{ "type": "notEqual", "start": 0, "end": 21, "bytes": "213c617263683e0a64656269616e2d62696e617279" } | ||
] | ||
}, | ||
{ | ||
"type": "deb", | ||
"ext": "deb", | ||
"mime": "application/x-deb", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 21, "bytes": "213c617263683e0a64656269616e2d62696e617279" } | ||
] | ||
}, | ||
{ | ||
"type": "rpm", | ||
"ext": "rpm", | ||
"mime": "application/x-rpm", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "edabeedb" } | ||
] | ||
}, | ||
{ | ||
"type": "Z", | ||
"ext": "Z", | ||
"mime": "application/x-compress", | ||
"rules": [ | ||
{ "type": "or", "rules": | ||
[ | ||
{ "type": "equal", "start": 0, "end": 2, "bytes": "1fa0" }, | ||
{ "type": "equal", "start": 0, "end": 2, "bytes": "1f9d" } | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "lz", | ||
"ext": "lz", | ||
"mime": "application/x-lzip", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 4, "bytes": "4c5a4950" } | ||
] | ||
}, | ||
{ | ||
"type": "msi", | ||
"ext": "msi", | ||
"mime": "application/x-msi", | ||
"rules": [ | ||
{ "type": "equal", "start": 0, "end": 8, "bytes": "d0cf11e0a1b11ae1" } | ||
] | ||
} | ||
] |
209
src/test.js
@@ -435,2 +435,211 @@ import {assert} from 'chai'; | ||
it('should detect woff', (done) => { | ||
detect.fromFile('./files/fixture.woff', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'woff', | ||
mime: 'application/font-woff' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect woff2', (done) => { | ||
detect.fromFile('./files/fixture.woff2', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'woff2', | ||
mime: 'application/font-woff' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect eot', (done) => { | ||
detect.fromFile('./files/fixture.eot', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'eot', | ||
mime: 'application/octet-stream' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ttf', (done) => { | ||
detect.fromFile('./files/fixture.ttf', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'ttf', | ||
mime: 'application/font-sfnt' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect otf', (done) => { | ||
detect.fromFile('./files/fixture.otf', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'otf', | ||
mime: 'application/font-sfnt' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ico', (done) => { | ||
detect.fromFile('./files/fixture.ico', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'ico', | ||
mime: 'application/x-icon' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect flv', (done) => { | ||
detect.fromFile('./files/fixture.flv', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'flv', | ||
mime: 'application/x-flv' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ps', (done) => { | ||
detect.fromFile('./files/fixture.ps', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'ps', | ||
mime: 'application/postscript' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect xz', (done) => { | ||
detect.fromFile('./files/fixture.tar.xz', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'xz', | ||
mime: 'application/x-xz' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect sqlite', (done) => { | ||
detect.fromFile('./files/fixture.sqlite', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'sqlite', | ||
mime: 'application/x-sqlite3' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect nes', (done) => { | ||
detect.fromFile('./files/fixture.nes', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'nes', | ||
mime: 'application/x-nintendo-nes-rom' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect crx', (done) => { | ||
detect.fromFile('./files/fixture.crx', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'crx', | ||
mime: 'application/x-google-chrome-extension' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect cab', (done) => { | ||
detect.fromFile('./files/fixture.cab', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'cab', | ||
mime: 'application/vnd.ms-cab-compressed' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect deb', (done) => { | ||
detect.fromFile('./files/fixture.deb', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'deb', | ||
mime: 'application/x-deb' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ar', (done) => { | ||
detect.fromFile('./files/fixture.ar', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'ar', | ||
mime: 'application/x-unix-archive' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect rpm', (done) => { | ||
detect.fromFile('./files/fixture.rpm', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'rpm', | ||
mime: 'application/x-rpm' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect tar.Z', (done) => { | ||
detect.fromFile('./files/fixture.tar.Z', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'Z', | ||
mime: 'application/x-compress' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect lz', (done) => { | ||
detect.fromFile('./files/fixture.tar.lz', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'lz', | ||
mime: 'application/x-lzip' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect msi', (done) => { | ||
detect.fromFile('./files/fixture.msi', (err, result) => { | ||
assert.equal(err, null); | ||
assert.deepEqual(result, { | ||
ext: 'msi', | ||
mime: 'application/x-msi' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); |
209
test.js
@@ -441,2 +441,211 @@ 'use strict'; | ||
}); | ||
it('should detect woff', function (done) { | ||
_index2.default.fromFile('./files/fixture.woff', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'woff', | ||
mime: 'application/font-woff' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect woff2', function (done) { | ||
_index2.default.fromFile('./files/fixture.woff2', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'woff2', | ||
mime: 'application/font-woff' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect eot', function (done) { | ||
_index2.default.fromFile('./files/fixture.eot', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'eot', | ||
mime: 'application/octet-stream' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ttf', function (done) { | ||
_index2.default.fromFile('./files/fixture.ttf', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'ttf', | ||
mime: 'application/font-sfnt' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect otf', function (done) { | ||
_index2.default.fromFile('./files/fixture.otf', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'otf', | ||
mime: 'application/font-sfnt' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ico', function (done) { | ||
_index2.default.fromFile('./files/fixture.ico', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'ico', | ||
mime: 'application/x-icon' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect flv', function (done) { | ||
_index2.default.fromFile('./files/fixture.flv', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'flv', | ||
mime: 'application/x-flv' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ps', function (done) { | ||
_index2.default.fromFile('./files/fixture.ps', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'ps', | ||
mime: 'application/postscript' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect xz', function (done) { | ||
_index2.default.fromFile('./files/fixture.tar.xz', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'xz', | ||
mime: 'application/x-xz' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect sqlite', function (done) { | ||
_index2.default.fromFile('./files/fixture.sqlite', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'sqlite', | ||
mime: 'application/x-sqlite3' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect nes', function (done) { | ||
_index2.default.fromFile('./files/fixture.nes', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'nes', | ||
mime: 'application/x-nintendo-nes-rom' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect crx', function (done) { | ||
_index2.default.fromFile('./files/fixture.crx', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'crx', | ||
mime: 'application/x-google-chrome-extension' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect cab', function (done) { | ||
_index2.default.fromFile('./files/fixture.cab', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'cab', | ||
mime: 'application/vnd.ms-cab-compressed' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect deb', function (done) { | ||
_index2.default.fromFile('./files/fixture.deb', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'deb', | ||
mime: 'application/x-deb' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect ar', function (done) { | ||
_index2.default.fromFile('./files/fixture.ar', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'ar', | ||
mime: 'application/x-unix-archive' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect rpm', function (done) { | ||
_index2.default.fromFile('./files/fixture.rpm', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'rpm', | ||
mime: 'application/x-rpm' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect tar.Z', function (done) { | ||
_index2.default.fromFile('./files/fixture.tar.Z', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'Z', | ||
mime: 'application/x-compress' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect lz', function (done) { | ||
_index2.default.fromFile('./files/fixture.tar.lz', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'lz', | ||
mime: 'application/x-lzip' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
it('should detect msi', function (done) { | ||
_index2.default.fromFile('./files/fixture.msi', function (err, result) { | ||
_chai.assert.equal(err, null); | ||
_chai.assert.deepEqual(result, { | ||
ext: 'msi', | ||
mime: 'application/x-msi' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16200783
2199