View 1.md
View 1.js
function waitForEvent(elem,evtName) {
return new Promise(function c(resolve){
elem.addEventListener(evtName,function onEvent(evt){
elem.removeEventListener(evtName,onEvent,false);
resolve(evt);
},false);
});
}
View 1.md

πŸ—‘β¬’πŸ’»β¬“πŸ”€πŸ“·πŸ“ΆπŸ”„πŸ”πŸ”ŠπŸ”‡πŸ”πŸ”ŽπŸ–₯πŸ—¨πŸ’¬πŸ“ŽπŸ“‚πŸ“„πŸ“…πŸ“‹πŸ“ŒπŸ“πŸ“πŸ“žβ˜ŽπŸ”’πŸ”“πŸ””πŸ”•πŸ”—β–Άβ–²β–Όβ—€βŸ²βŸ³βŠ—βœŽβœ“βœ”βœ—βœ˜βŠ•β˜·βœ„β˜°β™₯β˜…β˜†

View 1.md

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

  • BetterPromise # unthen(..) / BetterPromise # uncatch(..) / BetterPromise # unfinally(..) allows you to unregister a fulfillment or rejection handler that you previously registered on a promise via then(..) or catch(..), or unregister a resolution handler that you previously registered on a promise via finally(..).

    NOTE: This seems to be the majority use-case for why many like/want "promise cancelation" -- IOW, often what you want is to just stop observing a promise's resolution, not actually forcibly cancel the operation is comes from.

    var p = new BetterPromise(function(res){
       setTimeout(function(){ res(42); },100);
    });
View 1.js
class Foo {
constructor(x) {
this.x = x;
this.hello = () => {
console.log(this.x);
};
}
}
var a = new Foo(12);
View 1.js
/*
NOTE: This code assumes a bare git repo in ./bare-git/,
which should have at least one text file in its root,
named "greetings.txt".
This code updates the contents of a "greetings.txt"
file, and creates a new file called "greetings-XXX.txt"
(with XXX being a random number). It then creates a new
commit for these changes. Finally, it reads and dumps
the new current contents of the repo, file by file.
View 1.js
var y;
foo();
// values: 3 10
// value: 4 10
// *******************************
function foo() {
for (let i=0; i<2; i++) {
let obj = { x: 2 }; // <-- bug because of `let` here
View 1.js
// Standard:
function fn(x) {
return function(y){
return function(z){
return x * y / z;
};
};
}
View Monokai (SL) - ESNext.tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
View 1.js
var list = [1,2,3,4,5];
zip( list, map( x => x ** 2, list ) );
// [[1,1],[2,4],[3,9],[4,16],[5,25]]