fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@ -0,0 +1,15 @@
---
title: Promise
---
## Promise
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/promise/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,15 @@
---
title: Promise All
---
## Promise All
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/promise/promise-all/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,15 @@
---
title: Promise.prototype.catch
---
## Promise.prototype.catch
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/promise/promise-prototype-catch/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,57 @@
---
title: Promise.prototype.then
---
## Promise.prototype.then
A ```Promise.prototype.then``` function accepts two arguments and returns a Promise.
The first argument is a required function that accepts one argument. Successful fulfillment of a Promise will trigger this function.
The second argument is an optional function that also accepts one argument of its own. A thrown Error or Rejection of a Promise will trigger this function.
```javascript
function onResolved (resolvedValue) {
/*
* access to resolved values of promise
*/
}
function onRejected(rejectedReason) {
/*
* access to rejection reasons of promise
*/
}
promiseReturningFunction(paramList)
.then( // then function
onResolved,
[onRejected]
);
```
```Promise.prototype.then``` allows you to perform many asynchronous activities in sequence. You do this by attaching one ```then``` function to another separated by a dot operator.
```javascript
promiseReturningFunction(paramList)
.then( // first then function
function(arg1) {
// ...
return someValue;
}
)
...
.then( // nth then function
function(arg2) {
// ...
return otherValue;
}
)
```
<!--
1. add return value handling
-->
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,15 @@
---
title: Promise Race
---
## Promise Race
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/promise/promise-race/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,20 @@
---
title: Promise Reject
---
## Promise Reject
A ```Promise.reject``` function returns an error condition to the calling function. It takes a single parameter, an Error object or value, as the reason for rejection.
Chaining a catch function at the end of a Promise caller will allow you to catch the error condition.
```javascript
promiseCallingFunction(paramList)
.then( ... )
...
.then( ... )
.catch( function(err) { // catch function
/*
* this is where you can access the reason for the rejection
*/
});
```

View File

@ -0,0 +1,45 @@
---
title: Promise Resolve
---
## Promise Resolve
### Description
A ```Promise.resolve``` function indicates the successful completion of a Promise. This function allows you to return a Promise to the calling function.
```Promise.resolve``` takes a single parameter to return to the calling function. This parameter can either be a value, a thenable, or another Promise.
A "value" for a resolve function can be basic JavaScript types, arrays, or objects.
```javascript
Promise.resolve('success'); // string
Promise.resolve([2, 3, 5]); // array
Promise.resolve({name: 'John', age: '43'}); // object
```
A "thenable" is a function that takes two callback functions as parameters. You can use the first parameter to trigger a successful completion, and the second to return an error on the Promise.
```javascript
thenableFunction = {then: function(onSuccesss, onFailure) {
if (condition === 'success') {
onSuccess(paramList); // success condition
} else {
onFailure(paramList); // error condition
}
}
}
Promise.resolve(thenableFunction);
```
Chaining a then function to a promise caller will give you access to the result of ```Promise.resolve```.
```javascript
promiseCallingFunction(paramList)
.then(function(value) {
/*
* this is where you get access to the value
* returned by a promise on successful completion
*/
});
```