Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# object-to-formdata
A convenient JavaScript function that converts an object to a FormData instance.
A convenient JavaScript function that converts an object to a FormData instance

```
```js
const objectToFormData = require('object-to-formdata')

const object = {
Expand Down
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ function isArray (value) {
return Array.isArray(value)
}

function isBlob (value) {
return value != null
&& typeof value.size === 'number'
&& typeof value.type === 'string'
&& typeof value.slice === 'function'
}

function isFile (value) {
return value instanceof File
return isBlob(value)
&& typeof value.lastModified === 'number'
&& typeof value.name === 'string'
}

function isDate (value) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "object-to-formdata",
"version": "1.2.2",
"description": "A convenient JavaScript function that converts an object to a FormData instance.",
"description": "A convenient JavaScript function that converts an object to a FormData instance",
"main": "index.js",
"scripts": {
"test": "nyc ava",
Expand All @@ -22,10 +22,10 @@
"devDependencies": {
"ava": "^0.25.0",
"formdata-polyfill": "^3.0.9",
"jsdom": "^11.6.1",
"jsdom": "^11.6.2",
"nyc": "^11.4.1",
"sinon": "^4.2.2",
"standard": "^10.0.3"
"sinon": "^4.3.0",
"standard": "^11.0.0"
},
"standard": {
"globals": [
Expand Down