How to use the coinstac-common.utils function in coinstac-common

To help you get started, we’ve selected a few coinstac-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trendscenter / coinstac / packages / coinstac-client-core / src / sub-api / computation-service.js View on Github external
'use strict';

/**
 * @module computation-service
 */
const common = require('coinstac-common');

const Computation = common.models.computation.Computation;
const crypto = require('crypto');
const deepEqual = require('deep-equal');

const getSyncedDatabase = common.utils.getSyncedDatabase;
const ModelService = require('../model-service');

const RemoteComputationResult = common.models.computation.RemoteComputationResult;

/**
 * @extends ModelService
 */
class ComputationService extends ModelService {
  modelServiceHooks() { // eslint-disable-line class-methods-use-this
    return {
      dbName: 'computations',
      ModelType: Computation,
    };
  }

  /**
github trendscenter / coinstac / packages / coinstac-simulator / src / local.js View on Github external
function getAllDocuments(dbRegistry, dbName) {
  const getSyncedDatabase = coinstacCommon.utils.getSyncedDatabase;

  return getSyncedDatabase(dbRegistry, dbName).then((database) => {
    const operation = retry.operation({
      maxTimeout: 3000,
      minTimeout: 250,
      retries: 5,
    });

    return new Promise((resolve, reject) => {
      operation.attempt((currentAttempt) => {
        database.all()
          .then((docs) => {
            if (!docs.length) {
              throw new Error(`${dbName} database contains no documents`);
            }
github trendscenter / coinstac / packages / coinstac-client-core / src / model-service.js View on Github external
'use strict';

const common = require('coinstac-common');
const find = require('lodash/find');
const matchesProperty = require('lodash/matchesProperty');

const getSyncedDatabase = common.utils.getSyncedDatabase;

/**
 * @abstract
 * @property {DBRegistry} this.dbs
 * @property {Pouchy} this.db
 * @property {Function} this.ModelType
 */
class ModelService {

  /**
   * model-service base class. abstracts common model methods
   * @param {object} opts
   * @param {DBRegistry} opts.dbRegistry
   * @param {CoinstacClient} opts.client
   */
  constructor(opts) {

coinstac-common

COINSTAC core functionality.

MIT
Latest version published 29 days ago

Package Health Score

73 / 100
Full package analysis

Similar packages