Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mnemonist

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mnemonist - npm Package Compare versions

Comparing version 0.23.0 to 0.24.0

default-map.d.ts

4

bi-map.js

@@ -7,3 +7,3 @@ /**

*/
var iterate = require('./utils/iterables.js').iterate;
var forEach = require('obliterator/foreach');

@@ -180,3 +180,3 @@ /**

iterate(iterable, function(value, key) {
forEach(iterable, function(value, key) {
bimap.set(key, value);

@@ -183,0 +183,0 @@ });

@@ -16,3 +16,3 @@ /* eslint no-constant-condition: 0 */

*/
var iterate = require('./utils/iterables.js').iterate;
var forEach = require('obliterator/foreach');

@@ -168,3 +168,3 @@ /**

iterate(iterable, function(value) {
forEach(iterable, function(value) {
tree.add(value);

@@ -171,0 +171,0 @@ });

@@ -8,3 +8,3 @@ /**

var murmurhash3 = require('./utils/murmurhash3.js'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -177,3 +177,3 @@ /**

iterate(iterable, function(value) {
forEach(iterable, function(value) {
filter.add(value);

@@ -180,0 +180,0 @@ });

# Changelog
## 0.24.0
* Adding `#.forEachMultiplicity` to `MultiSet`.
* Adding `#.forEachAssociation` to `MultiMap`.
* Adding `DefaultMap`.
## 0.23.0

@@ -4,0 +10,0 @@

@@ -308,3 +308,3 @@ /**

iterables.iterate(iterable, function(value) {
iterables.forEach(iterable, function(value) {
buffer.push(value);

@@ -311,0 +311,0 @@ });

@@ -9,3 +9,3 @@ /* eslint no-constant-condition: 0 */

var comparators = require('./utils/comparators.js'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -296,3 +296,3 @@ var DEFAULT_COMPARATOR = comparators.DEFAULT_COMPARATOR,

iterate(iterable, function(value) {
forEach(iterable, function(value) {
heap.push(value);

@@ -307,3 +307,3 @@ });

iterate(iterable, function(value) {
forEach(iterable, function(value) {
heap.push(value);

@@ -310,0 +310,0 @@ });

@@ -229,3 +229,3 @@ /**

iterables.iterate(iterable, function(value) {
iterables.forEach(iterable, function(value) {
stack.push(value);

@@ -232,0 +232,0 @@ });

@@ -9,3 +9,3 @@ /**

*/
var iterate = require('./utils/iterables.js').iterate;
var forEach = require('obliterator/foreach');

@@ -170,3 +170,3 @@ var identity = function(x) {

iterate(iterable, function(value, key) {
forEach(iterable, function(value, key) {
if (useSet)

@@ -173,0 +173,0 @@ map.set(key, value);

@@ -8,3 +8,3 @@ /**

var MultiMap = require('./multi-map.js'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -181,3 +181,3 @@ var identity = function(x) {

iterate(iterable, function(value, key) {
forEach(iterable, function(value, key) {
if (useSet)

@@ -184,0 +184,0 @@ map.set(key, value);

@@ -7,3 +7,4 @@ /**

*/
var comparators = require('./utils/comparators.js'),
var forEach = require('obliterator/foreach'),
comparators = require('./utils/comparators.js'),
iterables = require('./utils/iterables.js');

@@ -228,3 +229,3 @@

iterables.iterate(iterable, function(value) {
forEach(iterable, function(value) {
if (value < min)

@@ -263,3 +264,3 @@ min = value;

iterables.iterate(iterable, function(value) {
forEach(iterable, function(value) {
if (i < n) {

@@ -325,3 +326,3 @@ result[i] = value;

iterables.iterate(iterable, function(value) {
forEach(iterable, function(value) {
if (value > max)

@@ -360,3 +361,3 @@ max = value;

iterables.iterate(iterable, function(value) {
forEach(iterable, function(value) {
if (i < n) {

@@ -363,0 +364,0 @@ result[i] = value;

@@ -9,3 +9,3 @@ /**

*/
var iterate = require('./utils/iterables.js').iterate;
var forEach = require('obliterator/foreach');

@@ -143,3 +143,3 @@ // TODO: maybe reverse iterators, since value is key etc.

iterate(function(item) {
forEach(function(item) {
map.add(item);

@@ -162,3 +162,3 @@ });

iterate(function(item) {
forEach(function(item) {
map.unsafeAdd(item);

@@ -165,0 +165,0 @@ });

@@ -15,2 +15,3 @@ /**

export {default as CircularBuffer} from './circular-buffer';
export {default as DefaultMap} from './default-map';
export {default as FibonacciHeap, MinFibonacciHeap, MaxFibonacciHeap} from './fibonacci-heap';

@@ -17,0 +18,0 @@ export {default as FixedReverseHeap} from './fixed-reverse-heap';

@@ -19,2 +19,3 @@ /**

CircularBuffer: require('./circular-buffer.js'),
DefaultMap: require('./default-map.js'),
StaticDisjointSet: require('./static-disjoint-set.js'),

@@ -21,0 +22,0 @@ FibonacciHeap: FibonacciHeap,

@@ -8,3 +8,3 @@ /**

var Iterator = require('obliterator/iterator'),
iterate = require('./utils/iterables.js').iterate,
forEach = require('obliterator/foreach'),
helpers = require('./utils/merge.js');

@@ -237,3 +237,3 @@

iterate(iterable, function(doc) {
forEach(iterable, function(doc) {
index.add(doc);

@@ -240,0 +240,0 @@ });

@@ -9,3 +9,3 @@ /**

var Iterator = require('obliterator/iterator'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -249,3 +249,3 @@ /**

iterate(iterable, function(value) {
forEach(iterable, function(value) {
list.push(value);

@@ -252,0 +252,0 @@ });

@@ -23,2 +23,3 @@ /**

forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void;
forEachAssociation(callback: (value: Array<V> | Set<V>, key: K, map: this) => void, scope?: any): void;
keys(): Iterator<K>;

@@ -25,0 +26,0 @@ values(): Iterator<V>;

@@ -8,3 +8,3 @@ /**

var Iterator = require('obliterator/iterator'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -201,2 +201,15 @@ /**

/**
* Method used to iterate over each of the associations.
*
* @param {function} callback - Function to call for each item.
* @param {object} scope - Optional scope.
* @return {undefined}
*/
MultiMap.prototype.forEachAssociation = function(callback, scope) {
scope = arguments.length > 1 ? scope : this;
this.items.forEach(callback, scope);
};
/**
* Method returning an iterator over the map's keys.

@@ -384,3 +397,3 @@ *

iterate(iterable, function(value, key) {
forEach(iterable, function(value, key) {
map.set(key, value);

@@ -387,0 +400,0 @@ });

@@ -25,2 +25,3 @@ /**

forEach(callback: (value: K, key: K, set: this) => void, scope?: any): void;
forEachMultiplicity(callback: (value: number, key: K, set: this) => void, scope?: any): void;
keys(): Iterator<K>;

@@ -27,0 +28,0 @@ values(): Iterator<number>;

@@ -8,3 +8,3 @@ /**

var Iterator = require('obliterator/iterator'),
iterate = require('./utils/iterables.js').iterate,
forEach = require('obliterator/foreach'),
FixedReverseHeap = require('./fixed-reverse-heap.js');

@@ -256,3 +256,3 @@

if (typeof n !== 'number' || n <= 0)
throw new Error('mnemonist/multi-set.mostCommon: n must be a number > 0.');
throw new Error('mnemonist/multi-set.top: n must be a number > 0.');

@@ -290,2 +290,15 @@ var heap = new FixedReverseHeap(Array, MULTISET_ITEM_COMPARATOR, n);

/**
* Method used to iterate over the set's multiplicities.
*
* @param {function} callback - Function to call for each multiplicity.
* @param {object} scope - Optional scope.
* @return {undefined}
*/
MultiSet.prototype.forEachMultiplicity = function(callback, scope) {
scope = arguments.length > 1 ? scope : this;
this.items.forEach(callback, scope);
};
/**
* Method returning an iterator over the set's keys. I.e. its unique values,

@@ -375,3 +388,3 @@ * in a sense.

iterate(iterable, function(value) {
forEach(iterable, function(value) {
set.add(value);

@@ -378,0 +391,0 @@ });

{
"name": "mnemonist",
"version": "0.23.0",
"version": "0.24.0",
"description": "Curated collection of data structures for the JavaScript language.",

@@ -32,2 +32,3 @@ "scripts": {

"data structures",
"default map",
"disjoint set",

@@ -65,3 +66,3 @@ "fibonacci heap",

"dependencies": {
"obliterator": "^1.3.0"
"obliterator": "^1.4.0"
},

@@ -73,8 +74,8 @@ "devDependencies": {

"leven": "^2.0.0",
"lodash": "^4.17.5",
"lodash": "^4.17.11",
"matcha": "^0.7.0",
"mocha": "^5.0.5",
"mocha": "^5.2.0",
"pandemonium": "^1.2.1",
"seedrandom": "^2.4.3",
"typescript": "^2.7.2"
"seedrandom": "^2.4.4",
"typescript": "^3.0.3"
},

@@ -81,0 +82,0 @@ "eslintConfig": {

@@ -9,3 +9,3 @@ /**

var Iterator = require('obliterator/iterator'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -192,3 +192,3 @@ /**

iterate(iterable, function(value) {
forEach(iterable, function(value) {
queue.enqueue(value);

@@ -195,0 +195,0 @@ });

@@ -76,2 +76,3 @@ [![Build Status](https://travis-ci.org/Yomguithereal/mnemonist.svg)](https://travis-ci.org/Yomguithereal/mnemonist)

* [BiMap](https://yomguithereal.github.io/mnemonist/bi-map)
* [DefaultMap](https://yomguithereal.github.io/mnemonist/default-map)
* [IncrementalMap](https://yomguithereal.github.io/mnemonist/incremental-map)

@@ -78,0 +79,0 @@

@@ -9,3 +9,3 @@ /**

var Iterator = require('obliterator/iterator'),
iterate = require('./utils/iterables.js').iterate;
forEach = require('obliterator/foreach');

@@ -187,3 +187,3 @@ /**

iterate(iterable, function(value) {
forEach(iterable, function(value) {
stack.push(value);

@@ -190,0 +190,0 @@ });

@@ -17,3 +17,3 @@ /* eslint no-loop-func: 0 */

*/
var iterate = require('./utils/iterables.js').iterate;
var forEach = require('obliterator/foreach');

@@ -535,3 +535,3 @@ /**

iterate(iterable, function(value) {
forEach(iterable, function(value) {
index.add(value);

@@ -538,0 +538,0 @@ });

@@ -13,3 +13,3 @@ /**

*/
var iterate = require('./utils/iterables.js').iterate,
var forEach = require('obliterator/foreach'),
Iterator = require('obliterator/iterator');

@@ -438,3 +438,3 @@

iterate(iterable, function(value, key) {
forEach(iterable, function(value, key) {
trie.set(key, value);

@@ -441,0 +441,0 @@ });

@@ -13,3 +13,3 @@ /**

*/
var iterate = require('./utils/iterables.js').iterate,
var forEach = require('obliterator/foreach'),
TrieMap = require('./trie-map.js');

@@ -154,3 +154,3 @@

iterate(iterable, function(value) {
forEach(iterable, function(value) {
trie.add(value);

@@ -157,0 +157,0 @@ });

@@ -7,2 +7,4 @@ /**

*/
var forEach = require('obliterator/foreach');
var isTypedArray = require('./typed-arrays.js').isTypedArray;

@@ -22,56 +24,2 @@

/**
* Function used to iterate in a similar way over JavaScript iterables,
* plain objects & arrays.
*
* @param {any} target - Iteration target.
* @param {function} callback - Iteration callback.
*/
function iterate(target, callback) {
var iterator, k, i, l, s;
// The target is an array or a string or function arguments
if (
isArrayLike(target) ||
typeof target === 'string' ||
target.toString() === '[object Arguments]'
) {
for (i = 0, l = target.length; i < l; i++)
callback(target[i], i);
return;
}
// The target has a #.forEach method
if (typeof target.forEach === 'function') {
target.forEach(callback);
return;
}
// The target is iterable
if (typeof Symbol !== 'undefined' && Symbol.iterator in target)
target = target[Symbol.iterator]();
// The target is an iterator
if (typeof target.next === 'function') {
iterator = target;
i = 0;
while ((s = iterator.next(), !s.done)) {
callback(s.value, i);
i++;
}
return;
}
// The target is a plain object
for (k in target) {
if (target.hasOwnProperty(k)) {
callback(target[k], k);
}
}
return;
}
/**
* Function used to guess the length of the structure over which we are going

@@ -106,3 +54,3 @@ * to iterate.

iterate(target, function(value) {
forEach(target, function(value) {
array[i++] = value;

@@ -118,4 +66,3 @@ });

exports.isArrayLike = isArrayLike;
exports.iterate = iterate;
exports.guessLength = guessLength;
exports.toArray = toArray;

@@ -11,2 +11,3 @@ /**

var Iterator = require('obliterator/iterator'),
forEach = require('obliterator/foreach'),
iterables = require('./utils/iterables.js'),

@@ -329,3 +330,3 @@ typed = require('./utils/typed-arrays.js');

iterables.iterate(iterable, function(value) {
forEach(iterable, function(value) {
vector.push(value);

@@ -332,0 +333,0 @@ });

@@ -15,3 +15,3 @@ /**

*/
var iterables = require('./utils/iterables.js'),
var forEach = require('obliterator/foreach'),
Heap = require('./heap.js');

@@ -163,3 +163,3 @@

iterables.iterate(items, function(value) {
forEach(items, function(value) {
self.items.push(value);

@@ -166,0 +166,0 @@ indexes.push(i++);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc