Bug - Fixed JavaScript: bufferToFile() fails due to type issues (+ patch added)

philmasterplus

Active member
The bufferToFile(string, string) function is the JS-equivalent of the ASH function buffer_to_file(string, string). However, calling this function in JS currently fails with:

Code:
> js require("kolmafia").bufferToFile("asdf", "foo.txt");

Script exception: Function 'buffer_to_file( string, string )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (command line#1)

I suspect this is because the "compatibility layer" between ASH and JS does not translate string type to buffer for this call. Unfortunately, there is no native "Buffer" type in our JS runtime, so we can't use this function at all.
 
Last edited:
Is this fileToBuffer or bufferToFile? you mention both below.
The fileToBuffer(string, string) function is the JS-equivalent of the ASH function file_to_buffer(string, string). However, calling this function in JS currently fails with:

Code:
> js require("kolmafia").bufferToFile("asdf", "foo.txt");

Code:
> ashref buffer

boolean buffer_to_file( buffer, string )
buffer file_to_buffer( string )

> jsref buffer

boolean bufferToFile(string, string)
string fileToBuffer(string)

> js require("kolmafia").fileToBuffer("foo.txt");

Returned:
 
Last edited:
Thanks for this phil! r20629
 
Back
Top