How to Determine a JavaScript Promise’s Status / / No Comments Promises have changed the landscape of JavaScript. Many old APIs have been reincarnated to use Promises (XHR to fetch, Battery API), while new APIs trend toward Promises. Developers can use async/await to handle promises, or then/catch/finally with callbacks, but what Promises don’t tell you is their status. Wouldn’t it be great if the Promise.prototype provided developers a status property to know whether a promise is rejected, resolved, or just done? My research led me to this gist which I found quite clever. I took some time to modify a bit of code and add comments. The following solution provides helper methods for determining a Promise’s status: // Uses setTimeout with... more → Posted in: JavaScript Tagged with: determine, JavaScript, promises, status
Determine Default App for File Type from Command Line / / No Comments One quality of life improvement any developer can make for themselves is ensuring different file types open in the app they’re most proficient in. If you know me, you know I prefer accomplishing as much as possible from the command line. The duti utility allows users to determine default file type from command line. The duti utility allows developers to query which app is the default for different file types. You can install duti with brew: brew install duti Once you have duti available, you can check on the default app for file type with the following command: ~ duti -x md Xcode.app /Applications/Xcode.app com.apple.dt.Xcode You can set the default app by using its package: duti... more → Posted in: JavaScript Tagged with: Command, default, determine, file, from, line, type