You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • At least in my test, it did not matter, writing data or an empty string.
    writing undefined or nothing gives an error, but, surprise,surprise, a file is created.
    @fanoush, Data cannot be overwritten, thats a good point. I did not read this before.
    BTW, try this:

    st.write("a","",0,10);
    =true
    >st.read("a");
    ="\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x­FF"
    >st.readArrayBuffer("a");
    =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255]).buffer
    >st.write("a","AB",0);
    =true
    >st.read("a")
    ="AB"
    >st.readArrayBuffer("a");
    =new Uint8Array([65, 66]).buffer
    >st.write("a","CD",2);
    Uncaught Error: Too much data for file size
     at line 1 col 20
    st.write("a","CD",2);
                       ^
    >st.write("a",[66,67],2);
    Uncaught Error: Too much data for file size
     at line 1 col 23
    st.write("a",[66,67],2);
                          ^
    >st.read("a");
    ="AB"
    > 
    

    On the other hand, this works

    >st.write("a","abcd",0,10);
    =true
    >st.readArrayBuffer("a");
    =new Uint8Array([97, 98, 99, 100, 255, 255, 255, 255, 255, 255]).buffer
    >st.write("a","efg",4);
    =true
    >st.readArrayBuffer("a");
    =new Uint8Array([97, 98, 99, 100, 101, 102, 103, 255, 255, 255]).buffer
    >st.read("a")
    ="abcdefg\xFF\xFF\xFF"
    > 
    

    Anyway, it works for me now ;-)

About

Avatar for JumJum @JumJum started