UNPKG

wasm-check

Version:

TypeScript / JavaScript library for detect WebAssembly features in node.js & browser

1 lines 1.95 kB
"use strict";function e(e,n){if(!r)return!1;const u=e.buffer;let i=l.get(u);if(null==i){if((i=t.validate(u))&&n)try{new t.Instance(new t.Module(u)).exports[0]()}catch(e){i=!1}l.set(u,i)}return i}const t=this.WebAssembly||globalThis.WebAssembly,r="object"==typeof t,n=e=>void 0!==e,u=(...e)=>Uint8Array.of(0,97,115,109,1,0,0,0,...e),i=(...e)=>Uint32Array.of(1836278016,1,...e),s=(...e)=>i(1610679297,33751040,...e,40239360,259),o=(...e)=>u(1,4,1,96,0,0,3,2,1,0,...e,11,0,10,4,110,97,109,101,2,3,1,0,0),a=(...e)=>Uint16Array.of(24832,28019,1,0,1025,24577,0,515,1,...e),g=(...e)=>a(...e,2842,4096,28164,28001,357,260,256,560,259,0),l=new WeakMap,f=i(1610679553,58589440,117440770,805372165,101318656,1107297281,268438272,1835101700,17039717,36700416,259),c=u(5,3,1,4,1,0,8,4,110,97,109,101,2,1,0),y=a(773,1,2561,269,11,65,65,65,3068,2816,2560,28164,28001,613,259,0),b=i(1610679297,33751040,134873089,100664833,185276736),m=u(2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1,0,8,4,110,97,109,101,2,1,0),p=Uint16Array.of(24832,28019,1,0,1537,24577,512,32639,515,1,2058,1537,16640,16640,2816,2560,28164,28001,613,259,0),A=g(3082,2561,17152,0,0,252),d=g(2058,1537,16640,49152),U=s(101318657,301990913,268438272,1835101700,17039717),h=o(5,4,1,3,1,1,10,7,1,5,0,254,3,0),x=s(84344833,6357249,17369600,4259847,186257917,1845758464),v=o(10,7,1,5,0,208,112,26);module.exports={support:(t=1)=>r&&e(Uint32Array.of(1836278016,t)),get supportStreaming(){return r&&n(t.instantiateStreaming)},feature:{get bigInt(){return e(f,!0)},get bulk(){return e(y)},get exceptions(){return e(b)},get memory64(){return e(c)},get mutableGlobal(){return e(m)},get multiValue(){return e(p)},get saturateConversions(){return e(A)},get signExtensions(){return e(d)},get tailCall(){return e(U)},get threads(){return e(h)},get simd(){return e(x)},get references(){return e(v)},get typeReflection(){return r&&n(t.Memory.type)},get funcReferences(){return r&&n(t.Function)}}};