Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Wishlist

crhallberg edited this page May 31, 2012 · 31 revisions

Wishlist

This is a list of useful things that should be implementable in 140 bytes. Help out and try your hand at one!

Javascript Event Delegation

We currently have event handlers, how about event delegation like jQuery's .on() and .delegate()?

A poker chance calculator

Poker chance calculator for four players while three cards are on river in less than 140 bytes. Function should returns an array of chance of player one to four. Function can get player hands like this

function pokerChanceCalc(p1a, p1b, p2a, p2b, p3a, p3b, p4a, p4b, r1, r2, r3){
  //magic
  return [p1chance, p2chance, p3chance, p4chance];
}

magic part should be less than 140 bytes.

cards can be strings like h0 for Ace of Hearts, h3 for four of Hearts or c11 for Queen of Clubs. I don't know if we had an object for cards it would be easier to develop it or not? The cards object can be like this:

c = {
  h:[0,1,2,3,4,5,6,7,8,9,10,11,12],
  c:[0,1,2,3,4,5,6,7,8,9,10,11,12],
  d:[0,1,2,3,4,5,6,7,8,9,10,11,12],
  s:[0,1,2,3,4,5,6,7,8,9,10,11,12],
}

DOM builder

A function that turns a non-nested (fab)-style micro-DSL such as the following into a DOM, without using HTML.

domBuilder(
  [/HTML/],
    [/HEAD/],
      [/TITLE/],
        "Wouldn't this be cool?",
      [],
    [],
    [/BODY/],
      [/DIV/, {id: "container"}],
        "Hello, world",
      [],
    [],
  []
)

A chainable DOM utility

The most annoying part about document.createElement, appendChild and friends is that they're not chainable! I suspect that a wrapper that returns "this" a la jquery could be very lightweight indeed.

My real-life use case is bookmarklets, fwiw.

A hash location history plugin

ES5 polyfills

Note: See kriskowal/es5-shim for conformant implementations, some of which are already <= 140 bytes.

  • Array.isArray => DONE
  • Array.prototype.forEach => DONE
  • Array.prototype.map => DONE
  • Array.prototype.filter => DONE
  • Array.prototype.every => DONE
  • Array.prototype.some => DONE
  • Array.prototype.reduce => DONE
  • Array.prototype.reduceRight IN PROGRESS
  • Array.prototype.indexOf => DONE
  • Array.prototype.lastIndexOf => DONE
  • Object.keys => DONE
  • Date.now => DONE
  • Date.parse (for ISO parsing) => IN PROGRESS
  • Date.prototype.toISOString => DONE
  • Date.prototype.toJSON => DONE
  • Function.prototype.bind => IN PROGRESS
  • String.prototype.trim => DONE
  • String.prototype.trimLeft => DONE
  • String.prototype.trimRight => DONE

A rounded-corner polyfill

Parallel, serial, map, and other async helper functions

Background Baseline Grid

A baseline grid enabler for use when developing CSS styles and conforming to a vertical rhythm.

BitTorrent implementation

A full-fledge bittorrent implementation.

Granted

The following have been successfully golfed under 140 bytes.

Animated loading bar/spinner

Animated spinner in 138 bytes: https://gist.github.com/998900 - with a little CSS styling it looks like Apple's activity indicator.

URL Path Parsing

A function that fetches named (or keyed) path values from the current URL for use in routing now that we can use history push states.

var page = uriPath(2); // example.com/path/value/34
var page = uriPath('page'); // example.com/key/value/page/34

DONE

Cross-browser base64 encoder and decoder (140 bytes each)

Encode: a function that takes the string input and map string ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/, return the base64 encoding. Bonus points for proper "=" padding. Accomplished here, with most of the golfing action in this sla.ckers thread.

Decode: the reverse of the above. Accomplished here.