- NOTE: This is a markdown adaptation of the original forked gist, additional file in this gist is an adaptation of the original post.
For the best guide, use search keyword: chmod. It should scroll down to:
For the best guide, use search keyword: chmod. It should scroll down to:
| div#app |
| function asyncWhile(condition, action, ctx) { | |
| var whilst = function(data) { | |
| return condition.call(ctx, data) ? | |
| Promise.resolve(action.call(ctx, data)).then(whilst) : | |
| data; | |
| } | |
| return whilst(); | |
| } |
changes:
\n, \t, and a new escape for singleSpace \ (exact recipe open for discussion)( so that the easiest-to-type grouping construct does not capture, and pollute the capture result array(?: just to be able to | a few options looks nasty(>= = positive lookaheadSome 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);| // @virtual decorator function | |
| function virtual( target: any, name: string) | |
| { | |
| // symbol to keep the proxy handler value | |
| let sym = Symbol( name + "_proxy_handler"); | |
| Object.defineProperty( target, name, { | |
| enumerable: true, | |
| get() |
| class Base | |
| { | |
| @virtual a = 1; | |
| b = this.a; | |
| } | |
| class Derived extends Base | |
| { | |
| a = 2; | |
| } |
| export function virtual( target: any, name: string) | |
| { | |
| // symbol to keep the proxy handler value | |
| let sym = Symbol( name + "_proxy_handler"); | |
| Object.defineProperty( target, name, { | |
| enumerable: true, | |
| get() | |
| { |
| class VirtHandler | |
| { | |
| target: any; | |
| get( t: any, p: PropertyKey, r: any): any | |
| { | |
| return this.target[p]; | |
| } | |
| } |
| class Base | |
| { | |
| first = { v: 1 }; | |
| second = () => this.first; | |
| } | |
| class Derived extends Base | |
| { | |
| first = { v: 2 }; | |
| } |