This file contains 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
import {compose, merge, promiseFactory, trackerFactory, useDeps} from "@nqminds/nqm-tdx-client"; | |
import constants from "Configs/constants"; | |
const {settingsKeys} = constants; | |
import Component from "./status-view-component"; | |
const depsMapper = ({getUserDatasetId, tdxConnections, utils}) => ({ | |
getUserDatasetId, | |
tdxConnections, | |
utils, |
This file contains 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 recursiveMatch(unmatched, matched = []) { // Technically this function is evil since it will mutate unmatched... | |
const elementToMatch = unmatched.shift(); | |
if (!elementToMatch) { // We've finished | |
return matched; | |
} | |
elementToMatch.matches = _.remove(unmatched, superMatchingFunction); | |
matched.push(elementToMatch); | |
return recursiveMatch(unmatched, matched); | |
} |
This file contains 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
this.grpcServer.addService(updater.Updater.service, { | |
getAllDevices: this.getAllDevices.bind(this), | |
getCurrentFirmwareVersion: this.getCurrentFirmwareVersion.bind(this), | |
getAvailableFirmwareVersion: this.getAvailableFirmwareVersion.bind(this), | |
getInstallInstructions: this.getInstallInstructions.bind(this), | |
initiateUpdate: this.initiateUpdate.bind(this), | |
cancelUpdate: this.cancelUpdate.bind(this), | |
getUpdateProgress: this.getUpdateProgress.bind(this), | |
validateUpdate: this.validateUpdate.bind(this), | |
getDeviceConfiguration: this.getDeviceConfiguration.bind(this), |
This file contains 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
class Api { | |
constructor() { | |
this.databases = { | |
db1: { | |
x: "hi", | |
}, | |
}; | |
} | |
getData(database, filter) { | |
return this.databases[database][filter]; |
This file contains 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
class Motorcycle { | |
... | |
} | |
describe("engine tests", function() { | |
it("turns over", function() { | |
motorcycle.start(); | |
expect(motorcyle.running).to.be.true; | |
}); |
This file contains 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
class DataStore { | |
constructor(data, indexes) { | |
this.data = data; | |
this.indexes = indexes; | |
this.indexedData = {}; | |
for (let i = 0; i < this.indexes.length; i++) { | |
const index = this.indexes[i]; | |
this.indexedData[index] = []; | |
for (let j = 0; j < this.data.length; j++) { | |
const d = this.data[j]; |
This file contains 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
// In your main extension or whatever | |
// Wrap these functions with a promise as callbacks are HELL | |
const sendMessage = (tabId, message) => { | |
return new Promise((resolve) => { | |
chrome.tabs.sendMessage(tabId, message, resolve); | |
}); | |
}; | |
const getTabs = (options) => { |
This file contains 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
class Boiler { | |
constructor() { | |
this.temperature = 10; | |
this.pollCount = 0; | |
this.toggleCount = 0; | |
this.heatingUp = false; | |
this.cycleCount = 0; | |
} | |
poll() { |
This file contains 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
const Promise = require("bluebird"); | |
let lastTimestamp = Date.now(); | |
let lastPoll = lastTimestamp; | |
const getData = () => { | |
const filter = { | |
timestamp { | |
$gt: lastTimestamp, | |
}, |
This file contains 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
class PromiseEater { | |
constructor() { | |
this.currentPromise = null; | |
} | |
addToQueue(promise) { | |
if (this.currentPromise !== null) { | |
this.currentPromise = this.currentPromise.then(promise); | |
} else { | |
this.currentPromise = promise(); |
NewerOlder