detect-file-type
Advanced tools
Comparing version 0.1.0 to 0.1.2
50
index.js
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _fs = require('fs'); | ||
@@ -125,36 +123,24 @@ | ||
if (rule.type === 'contains') { | ||
var _ret = function () { | ||
var slicedHex = buffer.slice(rule.start || 0, rule.end || buffer.length).toString('hex'); | ||
if (typeof rule.bytes === 'string') { | ||
rule.bytes = [rule.bytes]; | ||
} | ||
rule.bytes.every(function (bytes) { | ||
isDetected = slicedHex.indexOf(bytes) !== -1; | ||
return isDetected; | ||
}); | ||
var _slicedHex2 = buffer.slice(rule.start || 0, rule.end || buffer.length).toString('hex'); | ||
if (typeof rule.bytes === 'string') { | ||
rule.bytes = [rule.bytes]; | ||
} | ||
rule.bytes.every(function (bytes) { | ||
isDetected = _slicedHex2.indexOf(bytes) !== -1; | ||
return isDetected; | ||
}); | ||
return { | ||
v: _this3.isReturnFalse(isDetected, type) | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
return _this3.isReturnFalse(isDetected, type); | ||
} | ||
if (rule.type === 'notContains') { | ||
var _ret2 = function () { | ||
var slicedHex = buffer.slice(rule.start || 0, rule.end || buffer.length).toString('hex'); | ||
if (typeof rule.bytes === 'string') { | ||
rule.bytes = [rule.bytes]; | ||
} | ||
rule.bytes.every(function (bytes) { | ||
isDetected = slicedHex.indexOf(bytes) === -1; | ||
return isDetected; | ||
}); | ||
return { | ||
v: _this3.isReturnFalse(isDetected, type) | ||
}; | ||
}(); | ||
if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; | ||
var _slicedHex3 = buffer.slice(rule.start || 0, rule.end || buffer.length).toString('hex'); | ||
if (typeof rule.bytes === 'string') { | ||
rule.bytes = [rule.bytes]; | ||
} | ||
rule.bytes.every(function (bytes) { | ||
isDetected = _slicedHex3.indexOf(bytes) === -1; | ||
return isDetected; | ||
}); | ||
return _this3.isReturnFalse(isDetected, type); | ||
} | ||
@@ -161,0 +147,0 @@ |
{ | ||
"name": "detect-file-type", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Detect file type by signature", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "./node_modules/babel-cli/bin/babel.js src/ -d ./", | ||
"test": "./node_modules/babel-cli/bin/babel.js src/ -d ./ && ./node_modules/mocha/bin/mocha test.js" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"signatures.json" | ||
], | ||
"author": { | ||
@@ -10,0 +15,0 @@ "name": "Dmitry Pavlovsky", |
@@ -112,3 +112,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) | ||
- `contains` - here is required field `bytes`. We get a dump of buffer from `start` (equals 0 by default) to `end` (equals buffer.length by default). After that we try to find the sequence from `bytes` in this dump. If the dump contains `bytes` then rules is correct. | ||
- `notContains` - here is required field `bytes`. We get a dump of buffer from `start` (equals 0 by default) to `end` (equals buffer.length by default). After that we try to find the sequence from `bytes` in this dump. If the dump contains `bytes` then rules is correct. | ||
- `notContains` - here is required field `bytes`. We get a dump of buffer from `start` (equals 0 by default) to `end` (equals buffer.length by default). After that we try to find the sequence from `bytes` in this dump. If the dump contains `bytes` then rules is incorrect. | ||
@@ -115,0 +115,0 @@ #### More details about the rule types `or` and `and` |
Sorry, the diff of this file is not supported yet
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
2
30470
5221
5
857