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

hashring

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashring - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

13

index.js

@@ -418,2 +418,15 @@ 'use strict';

/**
* Checks if a given server exists in the hash ring.
*
* @param {String} server Server for whose existence we're checking
* @api public
*/
HashRing.prototype.has = function add(server) {
for (var i = 0; i < this.ring.length; i++) {
if (this.ring[i].server === server) return true;
}
return false;
};
/**
* Reset the HashRing to clean up all references

@@ -420,0 +433,0 @@ *

2

package.json
{
"name": "hashring",
"version": "2.0.1",
"version": "2.0.2",
"author": "Arnout Kazemier",

@@ -5,0 +5,0 @@ "description": "A consistent hashring compatible with ketama hashing and python's hash_ring",

@@ -211,2 +211,10 @@ # HashRing

#### HashRing.has(**server**)
Checks if a given server exists in the hash ring.
- **server** Server for whose existence we're checking.
---
#### HashRing.reset()

@@ -213,0 +221,0 @@

@@ -220,2 +220,24 @@ "use strict";

describe('#has', function () {
it('has a server', function () {
var ring = new Hashring([
'192.168.0.102:11212'
, '192.168.0.103:11212'
, '192.168.0.104:11212'
]);
ring.has('192.168.0.102:11212').should.equal(true);
});
it('does not have a server', function () {
var ring = new Hashring([
'192.168.0.102:11212'
, '192.168.0.103:11212'
, '192.168.0.104:11212'
]);
ring.has('192.168.0.105:11212').should.equal(false);
});
});
describe('#range', function () {

@@ -222,0 +244,0 @@ it('returns 20 servers', function () {

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