How to use mnemonist - 10 common examples

To help you get started, we’ve selected a few mnemonist 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 hashicorp / consul / ui-v2 / app / services / blocking.js View on Github external
cb();
      }
      return res;
    });
  };
};
const ifNotBlocking = function(settings) {
  return settings.findBySlug('client').then(res => !res.blocking);
};

// TODO: Expose this as a env var
const cache = new Map();
// sources are 'manually' removed when closed,
// they are only closed when the usage counter is 0
const sources = new Map();
const refs = new MultiMap(Set);

export default Service.extend({
  // TODO: Temporary repo list here
  service: service('repository/service'),
  node: service('repository/node'),
  session: service('repository/session'),

  client: service('client/http'),
  settings: service('settings'),
  // TODO: Temporary finder
  finder: function(src, filter) {
    const temp = src.split('/');
    temp.shift();
    const slug = temp.pop();
    const model = temp.pop();
    const dc = temp.shift();
github Yomguithereal / talisman / src / keyword-extraction / rake.js View on Github external
}
        }
        else {

          // Updating word frequency
          wordFrequencies[word] = wordFrequencies[word] || 0;
          wordFrequencies[word]++;

          // Adding the word to the current keyword
          keyword.push(word);
        }
      }
    }

    // Now we need to score the keywords and retrieve the best one
    const heap = new Heap(comparator),
          T = (candidateKeywords.size / 3) | 0;

    candidateKeywords.forEach(keyword => {
      const words = keyword.split(HASH_DELIMITER);
      let score = 0;

      for (let i = 0, l = words.length; i < l; i++) {
        const word = words[i];
        score += wordDegrees[word] / wordFrequencies[word];
      }

      heap.push({score, keyword: words});

      if (heap.size > T)
        heap.pop();
    });
github Yomguithereal / talisman / src / structures / vp-tree.js View on Github external
nearestNeighbors(k, query) {
    const neighbors = new Heap(COMPARATOR),
          queue = [this.root];

    let tau = Infinity;

    while (queue.length > 0) {
      const node = queue.pop();

      const d = this.distance(query, node.vantage);

      if (d < tau) {
        neighbors.push({distance: d, item: node.vantage});

        // Trimming
        if (neighbors.size > k)
          neighbors.pop();
github terascope / teraslice / packages / teraslice-state-storage / src / cached-state-storage / index.ts View on Github external
constructor(config: CacheConfig) {
        super();
        this._cache = new LRUMap(config.cache_size);
        // @ts-ignore
        this._cache.items = new BigMap(config.max_big_map_size);
    }
github hashicorp / consul / ui / packages / consul-ui / app / utils / filter / index.js View on Github external
return Object.keys(possibles).reduce((prev, key) => {
    // only set the value if the value has a length of > 0
    const value = typeof values[key] === 'undefined' ? [] : values[key];
    if (value.length > 0) {
      if (possibles[key] !== null) {
        // only include possible values
        prev[key] = [...setHelpers.intersection(possibles[key], new Set(value))];
      } else {
        // only unique values
        prev[key] = [...new Set(value)];
      }
    }
    return prev;
  }, {});
};
github Yomguithereal / talisman / src / clustering / record-linkage / vp-tree.js View on Github external
run() {

    // Building the tree
    const tree = new VPTree(this.distance, this.items);

    // Retrieving the clusters
    const clusters = [],
          visited = new Set();

    for (let i = 0, l = this.items.length; i < l; i++) {
      const item = this.items[i];

      if (visited.has(item))
        continue;

      const neighbors = tree.neighbors(this.radius, item);

      const cluster = new Array(neighbors.length);

      for (let j = 0, m = neighbors.length; j < m; j++) {
github hashicorp / consul / ui / packages / consul-ui / app / services / data-source / service.js View on Github external
init() {
    super.init(...arguments);
    cache = new Map();
    sources = new Map();
    usage = new MultiMap(Set);
    this._listeners = this.dom.listeners();
  }
github medialab / website / api / cleanup.js View on Github external
if (href)
          usedAssets.add(href);
      });

      $('img, iframe[data-internal=true]').each(function() {
        const src = $(this).attr('src');

        if (src)
          usedAssets.add(src);
      });
    });
  });

  const allAssets = new Set(fs.readdirSync(assetsPath));
  const unusedAssets = difference(allAssets, usedAssets);
  const missingAssets = difference(usedAssets, allAssets);

  if (missingAssets.size)
    console.warning('Missing assets!', missingAssets);

  return unusedAssets;
};
github medialab / website / api / cleanup.js View on Github external
if (href)
          usedAssets.add(href);
      });

      $('img, iframe[data-internal=true]').each(function() {
        const src = $(this).attr('src');

        if (src)
          usedAssets.add(src);
      });
    });
  });

  const allAssets = new Set(fs.readdirSync(assetsPath));
  const unusedAssets = difference(allAssets, usedAssets);
  const missingAssets = difference(usedAssets, allAssets);

  if (missingAssets.size)
    console.warning('Missing assets!', missingAssets);

  return unusedAssets;
};
github hashicorp / consul / ui / packages / consul-ui / app / filter / predicates / service-instance.js View on Github external
source: (item, values) => {
    return setHelpers.intersectionSize(values, new Set(item.ExternalSources || [])) !== 0;
  },
};

mnemonist

Curated collection of data structures for the JavaScript/TypeScript.

MIT
Latest version published 10 months ago

Package Health Score

76 / 100
Full package analysis