Skip to content

Instantly share code, notes, and snippets.

@listochkin
Forked from Jack-Works/2018.js
Last active March 24, 2022 03:15
Show Gist options
  • Save listochkin/310ce126cb4479d2c9ffc21fb7b5e4c8 to your computer and use it in GitHub Desktop.
Save listochkin/310ce126cb4479d2c9ffc21fb7b5e4c8 to your computer and use it in GitHub Desktop.
cRAzY eSnEXt (*all* proposals mixed in)
#! 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 23, 2018
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
#[?]: ?; // https://github.com/tc39/proposal-private-fields
fn(...n) {
// https://github.com/tc39/proposal-nullish-coalescing
// https://github.com/tc39/proposal-slice-notation
return this.#[?] ??= n[2:3]
}
}
when _: ?
}
}
|> ::?.fn // https://github.com/tc39/proposal-bind-operator
|> ?.map do(x) { x -> x + 1}
// https://github.com/tc39/proposal-record-tuple
// https://github.com/tc39/proposal-numeric-separator
// https://github.com/tc39/proposal-extended-numeric-literals
|> (? ?? ? ?? {# a: 1_2_3 #} ?? {| b:2_px |})
|> (async _ =>* { return ? })()) { // https://github.com/tc39/proposal-generator-arrow-functions
}
#! 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 Jun 17, 2019
mixin W {} // mixin proposal, I can't find a link for it
let val = do { // https://github.com/tc39/proposal-do-expressions
// https://github.com/tc39/proposal-generator-arrow-functions
// https://github.com/tc39/proposal-logical-assignment
// https://github.com/tc39/proposal-throw-expressions
((f ||= throw new TypeError('Aaaaaahhhhh')) =>* {
"hide implementation" // https://github.com/tc39/proposal-function-implementation-hiding
protocol Ahhhhhhh { // https://github.com/tc39/proposal-first-class-protocols
tag;
toString() {
return `[object ${this[Ahhhhhhh.tag]}]`[2:6]; // https://github.com/tc39/proposal-slice-notation
}
}
Protocol.implement(Promise, function.sent); // https://github.com/tc39/proposal-function.sent
case ( // https://github.com/tc39/proposal-pattern-matching
yield
|> await // https://github.com/tc39/proposal-pipeline-operator
|> (yield #)
|> fn(a ??= ? ?? ? ?? ? ?? ? ?? ? ?? ? ?? ? ?? ? ?? ?, 2333)
|> a(1) { } // I don't recall what this proposal is
) { // https://github.com/tc39/proposal-private-fields
// https://github.com/tc39/proposal-class-static-block
when a -> a |> ? ?? ? ?? class { #[?]: ?, static { do {? ?? ?}} }
}
})?.() ?.next( // https://github.com/tc39/proposal-nullish-coalescing
class Comment extends Model |> Editable |> Sharable |> Promisable with M {
static {
using(class.f()) {}
}
constructor() { // https://github.com/littledan/proposal-new-initialize
new.initialize()
}
} // https://github.com/tc39/proposal-extended-numeric-literals
).next(233@px)
}
// https://github.com/tc39/proposal-decorators
decorator @px {
@numericTemplate(({ number }) => CSS.px(number))
}
#! 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 by @jackworks_asref
// https://github.com/tc39/proposal-import-assertions#follow-up-proposal-evaluator-attributes
import data from "./data.json" assert { type: "json" } with { as: "record" };
import { onTransform, unwrap, log, onMounted, sensitive, dispatch, smartElement, CSS } from './utils.js';
// https://github.com/tc39/ecma262/pull/2154 and https://github.com/hax/proposal-extensions
import ::{ "😂" as send } from "async-call-rpc";
// https://github.com/tc39/proposal-asset-references
asset report from "report";
// https://github.com/tc39/proposal-operator-overloading
with operators from Decimal;
// https://github.com/tc39/proposal-extended-numeric-literals
with suffix px = CSS.px
// https://github.com/tc39/proposal-first-class-protocols
protocol RPC {
address;
// https://github.com/tc39/proposal-wavy-dot
send(method, ...args) { return this.address::send()~.[method](...args) }
}
// https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#annotation-syntax
@{ author: "Jack Works" }
// https://github.com/justinfagnani/proposal-mixins
class MyHandler extends HTMLElement with smartElement {
// async init proposal
async constructor() {
super();
// https://github.com/tc39/proposal-await.ops
await.race [
import(report),
// https://github.com/tc39/proposal-js-module-blocks
import(module { export default await import('./fallback.js') })
]
}
// https://github.com/tc39/proposal-private-declarations
outer static #brand = 'my handler'
// https://github.com/tc39/proposal-class-static-block
static {
https://github.com/tc39/proposal-standardized-debug
debugger.log(['Defined as ', this, this.#brand])
}
// https://github.com/tc39/proposal-slice-notation
#data = data[0:100];
onNewChild(child) {
// https://github.com/tc39/proposal-private-fields-in-in
!(try child.#data)
// https://github.com/tc39/proposal-throw-expressions
&& throw new TypeError('Illegal')
}
// https://github.com/tc39/proposal-generator-arrow-functions
[Symbol.asyncIterator]: async () =>* {
"hide source" // https://github.com/tc39/proposal-function-implementation-hiding
// https://github.com/tc39/proposal-function.sent
while (function.sent)
for (const datum of this.#data) {
// https://github.com/tc39/proposal-explicit-resource-management
try using(const f = function.sent) {
yield do { // https://github.com/tc39/proposal-do-expressions
// https://github.com/tc39/proposal-pipeline-operator
// and https://github.com/tc39/proposal-partial-application
// and https://github.com/tc39/proposal-Declarations-in-Conditionals
if (const val = datum |> sensitive |> f(this, ?) |> await.all |> sensitive) {
// https://github.com/tc39/proposal-pattern-matching
val = case (val) {
// https://github.com/tc39/proposal-record-tuple
when #{ type: 'throw', error: e } ->
throw new Error(e),
when #{ type: 'batch', list: arr } ->
await.all arr.map(x => import(x)),
// https://github.com/tc39/proposal-deep-path-properties-for-record
when #{ type: 'normal', ...rest } ->
#{ ...val, meta.received: Date.now() }
}
runTimes++;
// https://github.com/keithamus/proposal-object-freeze-seal-syntax
val |> dispatch(this, 'transform', {| details: val |});
}
}
}
}
}
// https://github.com/tc39/proposal-decorators#option-b-init-method-decorators
@init: onTransform transformHandler =
() => this.style.fontSize ||= runTimes > 10 ? 24px : 12px
// https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#block-decorators
@onMounted {
// https://github.com/samuelgoto/proposal-block-params
// and https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#parameter-decorators-and-annotations
this.addEventListener('transform') do (@unwrap event) {
// https://github.com/tc39/proposal-class-access-expressions
console.log(event, class.#brand)
}
}
static [RPC.address] = 'http://localhost:8080/';
};
Protocol.implement(MyHandler, RPC);
// https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#let-decorators
let @(log(x => `@@iterator on ${MyHandler.#brand} ran for ${x} times`))
// https://github.com/tc39/proposal-decimal
runTimes = 0m;
try {
// nested imports
// https://github.com/benjamn/reify/blob/master/PROPOSAL.md
import dev from "enhance-devtools"; window.devtoolsFormatters = #[...window?.devtoolsFormatters, dev];
} catch {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment