Skip to content

Instantly share code, notes, and snippets.

View iendjinn's full-sized avatar
🤔
Coding

Ivan iendjinn

🤔
Coding
View GitHub Profile
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,
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.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),
class Api {
constructor() {
this.databases = {
db1: {
x: "hi",
},
};
}
getData(database, filter) {
return this.databases[database][filter];
class Motorcycle {
...
}
describe("engine tests", function() {
it("turns over", function() {
motorcycle.start();
expect(motorcyle.running).to.be.true;
});
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];
// 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) => {
class Boiler {
constructor() {
this.temperature = 10;
this.pollCount = 0;
this.toggleCount = 0;
this.heatingUp = false;
this.cycleCount = 0;
}
poll() {
const Promise = require("bluebird");
let lastTimestamp = Date.now();
let lastPoll = lastTimestamp;
const getData = () => {
const filter = {
timestamp {
$gt: lastTimestamp,
},
class PromiseEater {
constructor() {
this.currentPromise = null;
}
addToQueue(promise) {
if (this.currentPromise !== null) {
this.currentPromise = this.currentPromise.then(promise);
} else {
this.currentPromise = promise();