Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Nagel jeznag

  • COzero
  • Sydney
View GitHub Profile
@getify
getify / 1.md
Last active Oct 15, 2020
BetterPromise: a strawman experiment in subclassing Promise and "fixing" a bunch of its awkward/bad parts
View 1.md

Some things that are "better" with this BetterPromise implementation:

  • BetterPromise # then(..) accepts a BetterPromise (or Promise) instance passed directly, instead of requiring a function to return it, so that the promise is linked into the chain.

    var p = BetterPromise.resolve(42);
    
    var q = Promise.resolve(10);
    
    p.then(console.log).then(q).then(console.log);
@lsaffie
lsaffie / pre-commit
Created Aug 5, 2012
pre-commit git hook that checks for values in the FORBIDDEN array
View pre-commit
#!/bin/bash
# Pre commit hook that prevents FORBIDDEN code from being commited.
# Add unwanted code to the FORBIDDEN array as necessary
FILES_PATTERN='\.(rb|js|coffee)(\..+)?$'
FORBIDDEN=( debugger ruby-debug )
for i in "${FORBIDDEN[@]}"
do
You can’t perform that action at this time.