#! Aaaaaaaaaaa this is JS!!! // https://github.com/tc39/proposal-hashbang // This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics // Enjoy!!! // Created at Nov 21, 2020 import data from "./data.json" assert { type: "json" } with { as: "record" }; // https://github.com/tc39/proposal-import-assertions#follow-up-proposal-evaluator-attributes import { onTransform, unwrap, log, onMounted, sensitive, dispatch, smartElement, CSS } from './utils.js'; import ::{ "😂" as send } from "async-call-rpc"; // https://github.com/tc39/ecma262/pull/2154 and https://github.com/hax/proposal-extensions asset report from "report"; // https://github.com/tc39/proposal-asset-references with operators from Decimal; // https://github.com/tc39/proposal-operator-overloading with suffix px = CSS.px // https://github.com/tc39/proposal-extended-numeric-literals protocol RPC { // https://github.com/tc39/proposal-first-class-protocols address; send(method, ...args) { return this.address::send()~.[method](...args) } } // https://github.com/tc39/proposal-wavy-dot @{ author: "Jack Works" } class MyHandler extends HTMLElement with smartElement { // https://github.com/justinfagnani/proposal-mixins and https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#annotation-syntax async constructor() { super(); await.race [import(report), import(module { export default await import('./fallback.js') })] } // async init proposal and https://github.com/tc39/proposal-await.ops and https://github.com/tc39/proposal-js-module-blocks outer static #brand = 'my handler' // https://github.com/tc39/proposal-private-declarations static { debugger.log(['Defined as ', this, this.#brand]) } // https://github.com/tc39/proposal-class-static-block and https://github.com/tc39/proposal-standardized-debug #data = data[0:100]; // https://github.com/tc39/proposal-slice-notation onNewChild(child) { !(try child.#data) && throw new TypeError('Illegal') } // https://github.com/tc39/proposal-private-fields-in-in and https://github.com/tc39/proposal-throw-expressions [Symbol.asyncIterator]: async () =>* { "hide source" // https://github.com/tc39/proposal-function-implementation-hiding and https://github.com/tc39/proposal-generator-arrow-functions while (function.sent) // https://github.com/tc39/proposal-function.sent for (const datum of this.#data) { try using(const f = function.sent) { // https://github.com/tc39/proposal-explicit-resource-management yield do { // https://github.com/tc39/proposal-do-expressions if (const val = datum |> sensitive |> f(this, ?) |> await.all |> sensitive) { // https://github.com/tc39/proposal-pipeline-operator and https://github.com/tc39/proposal-partial-application and https://github.com/tc39/proposal-Declarations-in-Conditionals val = case (val) { // https://github.com/tc39/proposal-pattern-matching when #{ type: 'throw', error: e } -> throw new Error(e), // https://github.com/tc39/proposal-record-tuple when #{ type: 'batch', list: arr } -> await.all arr.map(x => import(x)), when #{ type: 'normal', ...rest } -> #{ ...val, meta.received: Date.now() } // https://github.com/tc39/proposal-deep-path-properties-for-record } runTimes++; val |> dispatch(this, 'transform', {| details: val |}); } } } } } // https://github.com/keithamus/proposal-object-freeze-seal-syntax @init: onTransform transformHandler = () => this.style.fontSize ||= runTimes > 10 ? 24px : 12px // https://github.com/tc39/proposal-decorators#option-b-init-method-decorators @onMounted { // https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#block-decorators this.addEventListener('transform') do (@unwrap event) { // https://github.com/samuelgoto/proposal-block-params and https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#parameter-decorators-and-annotations console.log(event, class.#brand) } } // https://github.com/tc39/proposal-class-access-expressions static [RPC.address] = 'http://localhost:8080/'; }; Protocol.implement(MyHandler, RPC); let @(log(x => `@@iterator on ${MyHandler.#brand} ran for ${x} times`)) runTimes = 0m; // https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#let-decorators and https://github.com/tc39/proposal-decimal try { import dev from "enhance-devtools"; window.devtoolsFormatters = #[...window?.devtoolsFormatters, dev]; } catch {} // https://github.com/benjamn/reify/blob/master/PROPOSAL.md