This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function shuffle(array) { | |
| var currentIndex = array.length, randomIndex; | |
| // While there remain elements to shuffle... | |
| while (0 !== currentIndex) { | |
| // Pick a remaining element... | |
| randomIndex = Math.floor(Math.random() * currentIndex); | |
| currentIndex--; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createComponent(cmp, attributes) { | |
| return new Promise(function(resolve, reject) { | |
| function doCreateComponent() { | |
| $A.createComponent(cmpDef, attributes, function(newCmp, status, errorMsg) { | |
| if (newCmp && status === 'SUCCESS') { | |
| resolve(newCmp); | |
| } else if (status === 'ERROR') { | |
| reject(errorMsg); | |
| } else if (status === 'INCOMPLETE') { | |
| $A.getEvt('markup://force:showOfflineMessage').fire({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * promiseSerial resolves Promises sequentially. | |
| * Puts results into an array and get it from then() | |
| * | |
| * @example | |
| * const urls = ['/url1', '/url2', '/url3'] | |
| * const funcs = urls.map(url => () => $.ajax(url)) | |
| * | |
| * promiseSerial(funcs) | |
| * .then(console.log.bind(console)) |