New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

reds

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reds - npm Package Compare versions

Comparing version 0.1.4 to 0.2.1

12

History.md
0.2.1 / 2012-09-05
==================
* handle punctuation better [kbsymanz]
0.2.0 / 2012-08-21
==================
* add weighted search [kbsymanz]
* update redis dep
* update natural dep
0.1.4 / 2012-06-28

@@ -3,0 +15,0 @@ ==================

53

lib/reds.js

@@ -42,6 +42,6 @@

var types = {
intersect: 'sinter'
, union: 'sunion'
, and: 'sinter'
, or: 'sunion'
intersect: 'zinterstore'
, union: 'zunionstore'
, and: 'zinterstore'
, or: 'zunionstore'
};

@@ -84,3 +84,3 @@

exports.words = function(str){
return String(str).trim().split(/\W+/);
return String(str).match(/\w+/g);
};

@@ -122,2 +122,19 @@

/**
* Returns an object mapping each word in a Array
* to the number of times it occurs in the Array.
*
* @param {Array} words
* @return {Object}
* @api private
*/
exports.countWords = function(words){
var obj = {};
for (var i = 0, len = words.length; i < len; ++i) {
obj[words[i]] = (obj[words[i]] || 0) + 1;
}
return obj;
};
/**
* Return the given `words` mapped to the metaphone constant.

@@ -228,3 +245,11 @@ *

if (!keys.length) return fn(null, []);
db[type](keys, fn);
var tkey = key + 'tmpkey';
db.multi([
[type, tkey, keys.length, keys],
['zrevrange', tkey, 0, -1],
['zremrangebyrank', tkey, 0, -1],
]).exec(function(err, ids) {
ids = ids[1];
fn(err, ids);
});

@@ -259,12 +284,12 @@ return this;

, words = exports.stem(exports.stripStopWords(exports.words(str)))
, counts = exports.countWords(words)
, map = exports.metaphoneMap(words)
, keys = Object.keys(map)
, len = keys.length;
, keys = Object.keys(map);
var multi = db.multi();
var cmds = [];
keys.forEach(function(word, i){
multi.sadd(key + ':word:' + map[word], id);
multi.sadd(key + ':object:' + id, map[word]);
cmds.push(['zadd', key + ':word:' + map[word], counts[word], id]);
cmds.push(['zadd', key + ':object:' + id, counts[word], map[word]]);
});
multi.exec(fn || noop);
db.multi(cmds).exec(fn || noop);

@@ -285,7 +310,7 @@ return this;

, db = this.client;
db.smembers(key + ':object:' + id, function(err, constants){
db.zrevrangebyscore(key + ':object:' + id, '+inf', 0, function(err, constants){
if (err) return fn(err);
var multi = db.multi().del(key + ':object:' + id);
constants.forEach(function(c){
multi.srem(key + ':word:' + c, id);
multi.zrem(key + ':word:' + c, id);
});

@@ -292,0 +317,0 @@ multi.exec(fn);

{
"name": "reds"
, "version": "0.1.4"
, "version": "0.2.1"
, "description": "Redis search for node.js"

@@ -8,4 +8,4 @@ , "keywords": ["redis", "search", "metaphone", "phonetics", "natural"]

, "dependencies": {
"natural": "0.0.69"
, "redis": ">= 0.6.6"
"natural": "0.1.15"
, "redis": "0.7.2"
}

@@ -12,0 +12,0 @@ , "devDependencies": {

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