file-is-binary
Advanced tools
Comparing version 0.2.2 to 0.2.3
28
index.js
'use strict'; | ||
var stat = require('file-stat'); | ||
var isObject = require('isobject'); | ||
@@ -16,3 +15,3 @@ var isBinary = require('isbinaryfile'); | ||
if (isObject(file.contents) && typeof file.pipe === 'function') { | ||
if (typeof file.isStream === 'function' && file.isStream()) { | ||
file._isBinary = false; | ||
@@ -22,3 +21,3 @@ return false; | ||
if (isNull(file) || isDirectory(file)) { | ||
if (typeof file.isNull === 'function' && file.isNull()) { | ||
file._isBinary = false; | ||
@@ -28,2 +27,7 @@ return false; | ||
if (typeof file.isDirectory === 'function' && file.isDirectory()) { | ||
file._isBinary = false; | ||
return false; | ||
} | ||
var len = file.stat ? file.stat.size : file.contents.length; | ||
@@ -34,19 +38,1 @@ file._isBinary = isBinary.sync(file.contents, len); | ||
function isNull(file) { | ||
if (typeof file.isNull !== 'function') { | ||
file.isNull = function() { | ||
return file.contents === null; | ||
}; | ||
} | ||
return file.isNull(); | ||
} | ||
function isDirectory(file) { | ||
if (typeof file.stat === 'undefined') { | ||
stat.statSync(file); | ||
file.isDirectory = function() { | ||
return file.stat && file.stat.isDirectory(); | ||
} | ||
} | ||
return file.isDirectory(); | ||
} |
{ | ||
"name": "file-is-binary", | ||
"description": "Returns true if a file is binary. Checks the actual contents, since extensions are not reliable. Basic wrapper for isbinaryfile to support vinyl files.", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "https://github.com/jonschlinkert/file-is-binary", | ||
@@ -23,3 +23,2 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"file-stat": "^1.0.0", | ||
"isbinaryfile": "^3.0.2", | ||
@@ -36,3 +35,4 @@ "isobject": "^3.0.0" | ||
"file", | ||
"is" | ||
"is", | ||
"vinyl" | ||
], | ||
@@ -39,0 +39,0 @@ "verb": { |
@@ -1,4 +0,4 @@ | ||
# file-is-binary [![NPM version](https://img.shields.io/npm/v/file-is-binary.svg?style=flat)](https://www.npmjs.com/package/file-is-binary) [![NPM downloads](https://img.shields.io/npm/dm/file-is-binary.svg?style=flat)](https://npmjs.org/package/file-is-binary) [![Build Status](https://img.shields.io/travis/jonschlinkert/file-is-binary.svg?style=flat)](https://travis-ci.org/jonschlinkert/file-is-binary) | ||
# file-is-binary [![NPM version](https://img.shields.io/npm/v/file-is-binary.svg?style=flat)](https://www.npmjs.com/package/file-is-binary) [![NPM monthly downloads](https://img.shields.io/npm/dm/file-is-binary.svg?style=flat)](https://npmjs.org/package/file-is-binary) [![NPM total downloads](https://img.shields.io/npm/dt/file-is-binary.svg?style=flat)](https://npmjs.org/package/file-is-binary) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/file-is-binary.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/file-is-binary) | ||
Returns true if a file is binary. Checks the actual contents, since extensions are not reliable. Basic wrapper for isbinaryfile to support vinyl files. | ||
> Returns true if a file is binary. Checks the actual contents, since extensions are not reliable. Basic wrapper for isbinaryfile to support vinyl files. | ||
@@ -40,12 +40,12 @@ ## Install | ||
Please read the [contributing guide](contributing.md) for avice on opening issues, pull requests, and coding standards. | ||
Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards. | ||
### Building docs | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
@@ -55,6 +55,6 @@ | ||
Install dev dependencies: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install && npm test | ||
``` | ||
@@ -67,11 +67,11 @@ | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/file-is-binary/blob/master/LICENSE). | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 11, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 18, 2017._ |
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
6755
26
- Removedfile-stat@^1.0.0
- Removedcore-util-is@1.0.3(transitive)
- Removedfile-stat@1.0.0(transitive)
- Removedfs-exists-sync@0.1.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedisarray@1.0.0(transitive)
- Removedkind-of@3.2.2(transitive)
- Removedlazy-cache@2.0.2(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedset-getter@0.1.1(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedxtend@4.0.2(transitive)