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.2.3 to 0.2.4

6

History.md
0.2.4 / 2013-08-10
==================
* add function to limit the number of results (pagination)
* fix failure on strings that do not contain words
0.2.3 / 2013-02-22

@@ -3,0 +9,0 @@ ==================

83

lib/reds.js

@@ -12,8 +12,8 @@

var natural = require('natural')
, metaphone = natural.Metaphone.process
, stem = natural.PorterStemmer.stem
, stopwords = natural.stopwords
, redis = require('redis')
, noop = function(){};
var natural = require('natural');
var metaphone = natural.Metaphone.process;
var stem = natural.PorterStemmer.stem;
var stopwords = natural.stopwords;
var redis = require('redis');
function noop(){};

@@ -43,6 +43,6 @@ /**

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

@@ -98,2 +98,3 @@

var ret = [];
if (!words) return ret;
for (var i = 0, len = words.length; i < len; ++i) {

@@ -115,2 +116,3 @@ ret.push(stem(words[i]));

var ret = [];
if (!words) return ret;
for (var i = 0, len = words.length; i < len; ++i) {

@@ -134,2 +136,3 @@ if (~stopwords.indexOf(words[i])) continue;

var obj = {};
if (!words) return obj;
for (var i = 0, len = words.length; i < len; ++i) {

@@ -156,2 +159,3 @@ obj[words[i]] = (obj[words[i]] || 0) + 1;

var obj = {};
if (!words) return obj;
for (var i = 0, len = words.length; i < len; ++i) {

@@ -177,4 +181,7 @@ obj[words[i]] = metaphone(words[i]);

exports.metaphoneArray = function(words){
var arr = []
, constant;
var arr = [];
var constant;
if (!words) return arr;
for (var i = 0, len = words.length; i < len; ++i) {

@@ -184,2 +191,3 @@ constant = metaphone(words[i]);

}
return arr;

@@ -234,2 +242,16 @@ };

/**
* Limit search to the specified range of elements.
*
* @param {String} start
* @param {String} stop
* @return {Query} for chaining
* @api public
*/
Query.prototype.between = function(start, stop){
this._start = start;
this._stop = stop;
return this;
};
/**
* Perform the query and callback `fn(err, ids)`.

@@ -243,15 +265,18 @@ *

Query.prototype.end = function(fn){
var key = this.search.key
, db = this.search.client
, query = this.str
, words = exports.stem(exports.stripStopWords(exports.words(query)))
, keys = exports.metaphoneKeys(key, words)
, type = this._type;
var key = this.search.key;
var db = this.search.client;
var query = this.str;
var words = exports.stem(exports.stripStopWords(exports.words(query)));
var keys = exports.metaphoneKeys(key, words);
var type = this._type;
var start = this._start || 0;
var stop = this._stop || -1;
if (!keys.length) return fn(null, []);
var tkey = key + 'tmpkey';
db.multi([
[type, tkey, keys.length].concat(keys),
['zrevrange', tkey, 0, -1],
['zremrangebyrank', tkey, 0, -1],
['zrevrange', tkey, start, stop],
['zremrangebyrank', tkey, start, stop],
]).exec(function(err, ids) {

@@ -287,8 +312,8 @@ ids = ids[1];

Search.prototype.index = function(str, id, fn){
var key = this.key
, db = this.client
, words = exports.stem(exports.stripStopWords(exports.words(str)))
, counts = exports.countWords(words)
, map = exports.metaphoneMap(words)
, keys = Object.keys(map);
var key = this.key;
var db = this.client;
var words = exports.stem(exports.stripStopWords(exports.words(str)));
var counts = exports.countWords(words);
var map = exports.metaphoneMap(words);
var keys = Object.keys(map);

@@ -314,4 +339,5 @@ var cmds = [];

fn = fn || noop;
var key = this.key
, db = this.client;
var key = this.key;
var db = this.client;
db.zrevrangebyscore(key + ':object:' + id, '+inf', 0, function(err, constants){

@@ -325,2 +351,3 @@ if (err) return fn(err);

});
return this;

@@ -327,0 +354,0 @@ };

{
"name": "reds"
, "version": "0.2.3"
, "version": "0.2.4"
, "description": "Redis search for node.js"

@@ -5,0 +5,0 @@ , "keywords": ["redis", "search", "metaphone", "phonetics", "natural"]

@@ -109,3 +109,3 @@ # reds

four: 'FR',
dollars: 'TLRS'
dollars: 'DLRS'
}

@@ -156,2 +156,2 @@ ```

TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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