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
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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