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
| /** | |
| * Convert between Uint8Array and Base64 strings | |
| * Allows for any encoded JS string to be converted (as opposed to atob()/btoa() which only supports latin1) | |
| * | |
| * Original implementation by madmurphy on MDN | |
| * @see https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_1_–_JavaScript%27s_UTF-16_%3E_base64 | |
| */ | |
| function b64ToUint6(nChr) { | |
| return nChr > 64 && nChr < 91 |
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
| let isAlreadyFetchingAccessToken = false | |
| let subscribers = [] | |
| function onAccessTokenFetched(access_token) { | |
| subscribers = subscribers.filter(callback => callback(access_token)) | |
| } | |
| function addSubscriber(callback) { | |
| subscribers.push(callback) | |
| } |
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
| package main | |
| import ( | |
| "encoding/json" | |
| "os" | |
| "reflect" | |
| "text/template" | |
| ) |
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
| package main | |
| // This is a basic example of running an nsqd instance embedded. It creates | |
| // and runs an nsqd with all of the default options, and then produces | |
| // and consumes a single message. You are probably better off running a | |
| // standalone instance, but embedding it can simplify deployment and is | |
| // useful in testing. | |
| // See https://github.com/nsqio/nsq/blob/master/nsqd/options.go and | |
| // https://github.com/nsqio/nsq/blob/master/apps/nsqd/nsqd.go for |