Function.prototype.toStringreturns a program function's source text as written: an arrow orfunctionas is, a method or accessor from its name, a class as its wholeclass … {}. Built-in, bound and host functions returnfunction name() { [native code] }. A host can now keep a function a program hands it as text.String(fn)is unchanged.ArrayBuffer: the constructor,byteLength,slice,ArrayBuffer.isView, and theresizable,maxByteLengthanddetachedaccessors.Uint8ArrayandBuffersit on realArrayBuffers:.bufferworks,new Uint8Array(arrayBuffer, offset, length),subarrayandBuffer.from(arrayBuffer, offset, length)view its memory, and views over one buffer share its memory and its identity, also across a suspend and resume.TextDecoder.decodetakes anArrayBuffer. A host function gets a programArrayBufferas aUint8Arraycopy of its bytes; hostArrayBuffers still come in asUint8Arrays. Snapshot format 4: saved runs from earlier builds don't resume.JSON.parsegiven an object or array, which is already parsed, returns it unchanged instead of parsing its text ("[object Object]", or the array's elements joined). Other non-string values are parsed as before.- A default
sort()ortoSorted()over numbers only is numeric:[10, 9, 1].sort()is[1, 9, 10], not JavaScript's[1, 10, 9]. Any other mix of elements keeps the string order. - A default
sort()ortoSorted()that would compare an object throws aTypeErrorat the call asking for a comparator, instead of sorting by"[object Object]". Uint8Array.prototype.byteLengthandbyteOffset. They wereundefined, so code that sized bytes withbyteLength(such as afetchresponse'sarrayBuffer()) got no size.- RegExp:
RegExp(re)withoutnewreturnsrewhen itsconstructorisRegExp; match results always havegroups, and group objects (includingindices.groupsand the replace callback's groups) have a null prototype;RegExp.prototype.source/flags/flag getters read as on an empty pattern instead of throwing. Number.prototype.toLocaleStringandBigInt.prototype.toLocaleStringhonor their locales and options through the host's Intl instead of ignoring them, andArray.prototype.toLocaleStringpasses both on to each element.- Uint8Array:
toSorted,toReversed,with,copyWithin,setFromBase64,setFromHex, array-like sources, and fractional lengths. Buffer: inherits Uint8Array's statics,of,copyBytesFrom, thereadUint*/writeUint*aliases, andfrom(bytes, offset, length)copies the whole input as Node does.TextEncoder.prototype.encodeInto. Symbol.toPrimitiveandSymbol.toStringTagwork, and symbols haveSymbol.prototype,description, andtoString("Symbol(Symbol.iterator)").- BigInt: literals, arithmetic,
BigInt(),BigInt.asIntN/asUintN, the prototype methods, and Buffer's 64-bitreadBigInt64*/writeBigInt64*methods. A BigInt is capped at 2^20 bits and cannot cross to the host;JSON.stringifythrows on one unless the program definesBigInt.prototype.toJSON. Snapshots keep BigInts. String.prototype.matchAllreturns an iterator instead of an array;String.rawaccepts a stringraw; andObject.keys/values/entries/assign/hasOwn, object spread andfor...inindex a string by UTF-16 code unit.- Promises:
Promise.try(nonFunction)returns a rejected promise instead of throwing, andnew Promiseaccepts bound functions as executors. Array.fromAsync; aJSON.parsereviver gets its third argument ({ source }for primitives); andArray.prototype.toStringcalls the receiver'sjoin, as in JS.- Object:
Object.fromEntriesaccepts any entry value,hasOwnProperty/propertyIsEnumerableaccept primitive receivers, own-property checks apply ToPropertyKey to object keys,Object.prototype.toStringreports Math, JSON, crypto, TextEncoder/TextDecoder, symbols and async/generator functions, andObject.getOwnPropertySymbolsexists. - A
StreamingResponsenow hastype,clone()andreader.closed;blob(),formData()and the body'stee,pipeToandpipeThroughthrow a TypeError instead of being undefined. - Console: nested
undefinedprints asundefined(notnull),console.tableshows a table holding a function instead of[opaque reference], andconsole.assert/count/countReset/group/groupCollapsed/groupEnd/trace/time/timeLog/timeEndexist.
psychoscript/effect: a plain function the host gives the program (inside a host function's result, such as a method of a returned object, or among the globals) may return an Effect again, as in 0.1; it runs with the run's services and the same failure mapping as aHost.fn's Effect.- The program sees a
Host.fn's ownnameandlengthagain, not those of a wrapper.
Breaking.
-
The root API is Promise-based:
runtime.execute,program.run,program.suspendandruntime.resume(...).runreturn Promises, and host functions return values or Promises. -
The Effect API moved to
psychoscript/effect. To migrate, changefrom "psychoscript"tofrom "psychoscript/effect"; nothing else changes. -
effectis now an optional peer dependency, needed only forpsychoscript/effect. -
Host calls get
call.signal, aborted when the run stops or a suspend interrupts the call. -
Aborting
execute(code, { signal })orrun({ signal })rejects with aDOMExceptionnamed"AbortError". -
A sync host function that returns a Promise now sees its signal abort when the run stops.
-
Errors have a V8-style, non-enumerable
stack:name: messageand up to 10at fn (<program>:line:col)frames, taken when the error is made and kept across a suspend and resume. -
Array destructuring, spread,
for...of,yield*,Array.fromand other iterable intake honour a program's replacement ofArray.prototype[Symbol.iterator], the built-in iterators'next, or an array's own[Symbol.iterator]. Runs that never replace them keep iterating arrays directly; the choice survives a suspend and resume. A default derived constructor passes its arguments on without iterating them.
First release.
- A confined JavaScript interpreter: strict-mode programs compiled to bytecode, with no ambient I/O,
evalor prototype mutation, and a standard library covering the core built-ins plusURL,Headers,Uint8ArrayandBuffer. Runtime.makeruns programs against host functions (Host.fn,Host.durableFn,Host.namespace) in Effect.- Runs can be suspended, saved with
toBytes, and resumed withfromBytesin another process of the same build. - Time and output limits, and fixed caps on strings, arrays and pending promises.