我正在寻找CRC32 的现代 JavaScript实现.
此实现,这可能起源于这里,现在这里有和无处不在,是不可接受的,因为它的速度慢(500毫秒/ MB),并在空格分隔表的2KB取决于使用SUBSTR访问.呸!
CRC32似乎有一些变化,所以我需要匹配这个输出:
mysql> SELECT CRC32('abcde');
> 2240272485
Run Code Online (Sandbox Code Playgroud)
然而,函数实际上不需要接受字符串,因为我正在使用字节数组.
在ServiceWorker中展示indexedDB的示例并不多,但我看到的结构都是这样的:
const request = indexedDB.open( 'myDB', 1 );
var db;
request.onupgradeneeded = ...
request.onsuccess = function() {
db = this.result; // Average 8ms
};
self.onfetch = function(e)
{
const requestURL = new URL( e.request.url ),
path = requestURL.pathname;
if( path === '/test' )
{
const response = new Promise( function( resolve )
{
console.log( performance.now(), typeof db ); // Average 15ms
db.transaction( 'cache' ).objectStore( 'cache' ).get( 'test' ).onsuccess = function()
{
resolve( new Response( this.result, { headers: { 'content-type':'text/plain' } …
Run Code Online (Sandbox Code Playgroud)