Skip to content

Instantly share code, notes, and snippets.

@dead-claudia
dead-claudia / jsperf-spam.txt
Last active December 28, 2017 05:05
JSPerf spam URL searches (very likely eternally incomplete)
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"towkayzone"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"overking"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"4dgamers"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"vuecine"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"vk"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"evolvehq"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"samaritanchristiancenter"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"destinationaustralia"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"videa"
https://www.google.com/search?filter=0&q=site%3Ajsperf.com+"download"
@dead-claudia
dead-claudia / parser-test262.js
Last active December 2, 2017 18:58
Test262 runner
/**
* Copyright (c) 2017 and later, Isiah Meadows. Licensed under the ISC License.
*/
// Execute the Test262 test suite with a parser. This checks for parser
// conformance correctly, and requires little configuration on your part.
//
// Options supported, `opts.test262Dir`, `opts.test`, and `opts.parse` are
// required:
// - `opts.test262Dir` - The directory to a clone of the Test262 suite
@dead-claudia
dead-claudia / 0-js-dsl.md
Last active November 28, 2017 00:48
An alternative DSL proposal for JavaScript

Please direct all comments to this issue. I won't receive notifications if you comment here, but I will receive them if you comment there.

A DSL proposal for JavaScript

This is an attempt to create a more cohesive, easy-to-implement DSL proposal for JavaScript, attempting to work around most of the issues described in this original proposal. Of course, this is pretty poorly formatted and it's missing a few edge cases, but it's just a strawman.

Syntax

  • Blocks close over environment, but have phantom @@this context (syntax error outside DSL)
  • @foo(...) do { ... } - Invoke @@this.foo(..., block)
@dead-claudia
dead-claudia / counter-mithril.js
Last active October 25, 2017 18:34
Redux Zero in pure ES6 without React context or higher-order component support (with Mithril equivalent)
import m from "mithril"
import { Connect } from "./redux-zero-mithril"
import { increment, decrement } from "./actions"
const mapToProps = ({ count }) => ({ count })
export default function Counter() {
return {view({attrs}) {
return m(Connect, {to: attrs.store, with: mapToProps, view({count}) {
@dead-claudia
dead-claudia / repeated-permutations-with-subsets.js
Created October 23, 2017 15:49
Permutation of array and its subsets with repetition
// Note: this uses generators exclusively to avoid blowing up your RAM - 10-item
// arrays will produce about 11 billion entries. You can use
// `repeatedPermutationWithSubsetsCount` with the length to see how many items
// will be produced.
function *permRep(array, data, index) {
if (index === data.length) {
yield data.slice()
} else {
for (let i = 0; i < array.length; i++) {
data[index] = array[i]
@dead-claudia
dead-claudia / lazy.js
Created August 31, 2017 13:04
Lazy class
/**
* A lazy value that also memoizes exceptions and checks for recursion.
*/
export class Lazy {
constructor(init) {
this.state = State.Init
this.value = init
}
// This shouldn't count against the inline quota.
@dead-claudia
dead-claudia / local-date.js
Last active September 27, 2018 17:33
Simple date library
// A simpler implementation of date handling, with the following additional
// assumptions:
//
// 1. We only need the day, month, and year.
// 2. Time zones are irrelevant.
// 3. Day/month/year checks and range checks are *far* more common than date
// difference calculation.
// 4. Dates are rarely written to, mostly read.
//
// Helpfully, this lets us represent dates with a single 32-bit integer, which
@dead-claudia
dead-claudia / cancel-token.js
Last active July 30, 2017 03:39
Super simple cancellation token
/**
* A super simple cancel token utility, with support all the way to ES3. Works
* in browsers, AMD, and CommonJS environments. 874 bytes minified and gzipped.
*
* The API is pretty simple:
*
* `const source = cancelSource(parentTokens?)`
*
* - `source.cancel(reason?)`
* Trigger a cancel with some reason, and save the cancel result to
@dead-claudia
dead-claudia / 0-pattern-matching.md
Last active July 22, 2017 06:04
JS pattern matching strawman

Note: if you wish to comment on this proposal, tell me here, so I can actually be notified.


JS Pattern Matching Strawman

Just an attempt to come up with a sane pattern matching proposal that doesn't hit any of the following pitfalls:

  • Unidiomatic - if it doesn't look at all like JS, not very many will want to try it.
  • Prohibitively slow - if it can't be made fast, implementors are going to question it and users will complain.
@dead-claudia
dead-claudia / constraint-types.md
Last active October 3, 2022 19:31
TypeScript Constraint Types Proposal

(All feedback/discussion should take place in the relevant issue.)

TypeScript Constraint Types Proposal

There's multiple requests for the ability to control a type at a much more fine grained level:

  • #12424: Mapped conditional types
  • #12885: Typing function overloads
  • #12880: Bad inference for lambda closures
  • Promises wrongfully accept thenables as their generic parameter (thenables can never be the argument to a then callback).