On Sat, Nov 10, 2012 at 11:22 AM, Kevin Smith <[email protected]> wrote:
>
> return AFS.stat(path)
>> .fail(error => null) // map failure to success condition
>> .then(stat =>
>>
>> if (!stat) // Path doesn't exist - create the directory
>> return AFS.mkdir(path);
>> else if (stat.isDirectory()) // done already
>> return 'nothing to do';
>> else // no can do
>>
>> throw new Error("Path is not a directory.");
>>
>> ).then(val => console.log("done"));
>>
>>
> Provided that fail provides the implicit success handler `val => val`, I
> think that's correct. Question: is one-arg `then` + `fail` equally as
> powerful as two-arg then? Proof?
>
Is the following a counter-example?
On Fri, Nov 9, 2012 at 8:33 AM, Mark S. Miller <[email protected]> wrote:
> Hi David, thanks for your thoughtful post. I've always used the two-arg
> form of .then[1], but your post makes a strong case for more often using
> separate one-arg .then and .fail calls. I say only "more often" because the
> two arg form can easily make distinctions that the one-arg forms cannot
>
> var p2 = Q(p1).then(val => { throw foo(val); },
> reason => { return bar(reason); });
>
> is different than either of the one-arg chainings.
>
>
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss