<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Allow access to node&#x27;s Buffer class]]></title><description><![CDATA[<p>I'm building a heap on top of the RawMemory global to improve script perf, but JavaScript doesn't have great support for converting between byte arrays and strings. The least-bad method I've found is using String.fromCharCode.apply, which starts hitting stack overflows around 115 KB.</p>
<p>Can we get access to node's Buffer class in the player scripts?</p>]]></description><link>http://screeps.com/forum/topic/596/allow-access-to-node-s-buffer-class</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 17:37:26 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/596.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Oct 2016 01:07:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>I'm building a heap on top of the RawMemory global to improve script perf, but JavaScript doesn't have great support for converting between byte arrays and strings. The least-bad method I've found is using String.fromCharCode.apply, which starts hitting stack overflows around 115 KB.</p>
<p>Can we get access to node's Buffer class in the player scripts?</p>]]></description><link>http://screeps.com/forum/post/2920</link><guid isPermaLink="true">http://screeps.com/forum/post/2920</guid><dc:creator><![CDATA[Esryok]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>This would be useful for integrating node-lz4 into my bot.</p>
]]></description><link>http://screeps.com/forum/post/13445</link><guid isPermaLink="true">http://screeps.com/forum/post/13445</guid><dc:creator><![CDATA[wtfrank]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>What's special about the Buffer class? As I understand the API memory still needs to be stored as a string in MongoDB so the conversion has to take place somewhere.</p>
<p>The best approach I've found for stuff like that is to keep a copy in global and drop checkpoints into <code>Memory</code>.</p>
<p>A concrete example. I store <code>CostMatrix</code> in global but serialize it to a sparse array for storage in<code>Memory</code>.</p>
]]></description><link>http://screeps.com/forum/post/13450</link><guid isPermaLink="true">http://screeps.com/forum/post/13450</guid><dc:creator><![CDATA[deft-code]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Fri, 05 Apr 2019 17:24:23 GMT]]></title><description><![CDATA[<p>Buffer has convenient support for converting between a string  and an array. That's what interested me in it.</p>
]]></description><link>http://screeps.com/forum/post/13451</link><guid isPermaLink="true">http://screeps.com/forum/post/13451</guid><dc:creator><![CDATA[wtfrank]]></dc:creator><pubDate>Fri, 05 Apr 2019 17:24:23 GMT</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>One problem: this wouldn't work in the simulation, since it can be run in the browser without Node support. Screeps would need a polyfill to handle that. If there's a polyfill available, you can then just drop that into your existing code.</p>
<p>A quick search online gives me this:
<a href="https://github.com/feross/buffer" rel="nofollow">https://github.com/feross/buffer</a></p>
]]></description><link>http://screeps.com/forum/post/13456</link><guid isPermaLink="true">http://screeps.com/forum/post/13456</guid><dc:creator><![CDATA[JBYoshi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>I'd like to add my desire to have this added as well. I'm working on getting Rust working via wasm-bindgen (the &quot;blessed&quot; wasm implementation for Rust) and I've had a number of hoops to jump through in order to get it working. The most recent one is the Rust wasm javascript shim using <code>Buffer.from()</code> and <code>Buffer.byteLength</code> but failing because <code>Buffer</code> is unavailable.</p>
]]></description><link>http://screeps.com/forum/post/13584</link><guid isPermaLink="true">http://screeps.com/forum/post/13584</guid><dc:creator><![CDATA[aphistic]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1701">@jbyoshi</a> This is a good point about the simulation.</p>
<p>The polyfill though has awful performance. Converting some arrays of bytes to a string with node's Buffer class takes 242ms, while converting those same arrays of bytes with the polyfill buffer class takes 793ms.</p>
<p>I believe Node's buffer class uses C underneath, which means it doesn't have to create loads of intermediate string objects and explains why it's so much quicker to convert a string this way.</p>
<p>The Buffer polyfill could perhaps be provided for the simulator, while the node Buffer class could be provided on the MMO server...</p>
]]></description><link>http://screeps.com/forum/post/13599</link><guid isPermaLink="true">http://screeps.com/forum/post/13599</guid><dc:creator><![CDATA[wtfrank]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>I don't think that simulator should be the only reason to not allow that .. there could be advanced features that won't work in the simulator... it just should be documented somewhere.. and it should print a warning.</p>
<p>For example I don't use the simulator at all.</p>
]]></description><link>http://screeps.com/forum/post/13605</link><guid isPermaLink="true">http://screeps.com/forum/post/13605</guid><dc:creator><![CDATA[W4rl0ck]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>Pathfinder is amazing and accelerated in C like Node's Buffer. We assume we have a slower api compatible version for the simulator.</p>
]]></description><link>http://screeps.com/forum/post/13606</link><guid isPermaLink="true">http://screeps.com/forum/post/13606</guid><dc:creator><![CDATA[deft-code]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Tue, 23 Apr 2019 10:45:27 GMT]]></title><description><![CDATA[<p>More benchnmarking: some code that amongst other things copies some strings into the wasm heap via a Buffer takes 414ms, but the same code that uses the polyfill Buffer takes 1878ms.</p>
<p>So the polyfill buffer has abysmal performance both at converting javascript strings to arrays, and converting arrays into javascript strings.</p>
<p>The polyfill Buffer is not something that anybody should willingly use!</p>
]]></description><link>http://screeps.com/forum/post/13610</link><guid isPermaLink="true">http://screeps.com/forum/post/13610</guid><dc:creator><![CDATA[wtfrank]]></dc:creator><pubDate>Tue, 23 Apr 2019 10:45:27 GMT</pubDate></item><item><title><![CDATA[Reply to Allow access to node&#x27;s Buffer class on Invalid Date]]></title><description><![CDATA[<p>Like <a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3059">@aphistic</a>, I am also trying to use Rust through wasm-bindgen. Currently, I build with an automated script that run <code>wasm-packet -t nodejs</code> and then use <code>sed</code> to replace the <code>Buffer</code>-dependent methods with their counterparts when targeting <code>browser</code>. This works, and if anyone wants this solution just message me and I'll publish it, but I would love to have the performance benefits of <code>Buffer</code>.</p>
]]></description><link>http://screeps.com/forum/post/14635</link><guid isPermaLink="true">http://screeps.com/forum/post/14635</guid><dc:creator><![CDATA[Athestus]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>