rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.36k stars 194 forks source link

Blob support #203

Closed honi closed 6 years ago

honi commented 7 years ago

Is there any way to have an Immutable object with a key referencing a Blob? I understand it might not be possible to make the Blob immutable, in which case can I allow having a mutable value within an immutable object?

Failing case:

import Immutable from 'seamless-immutable';
const blob = new Blob();
const test = Immutable.from({blob});
console.log(blob); // logs Blob {size: 0, type: ""}
console.log(test); // logs Object and when expanded blob key is empty
rtfeldman commented 7 years ago

According to the docs, blobs are immutable.

A Blob object represents a file-like object of immutable, raw data.

This suggests we should be able to treat them as such, just like how we currently treat strings!

yoavniran commented 6 years ago

hi @rtfeldman

in a project im working on I have an issue in safari. uploads to server are failing because the Blob I reference in my state is being treated as data instead of an object to skip (like File/React/Error).

The reason its a Blob and not a File is that creating a File instance from the binary I get (from a 3rd party API) on Safari fails (its empty) and creating a Blob works.

I think Blob should be treated the same as File, no? Id be happy to submit a PR that does the same as isFileObject for Blob.