Skip to content

Commit

Permalink
Changelog: 🚀
Browse files Browse the repository at this point in the history
## New Commands

### SCAN command (stipsan#334 @DrMegavolt)

```js
redis
  .scan(0, 'MATCH', 'foo*', 'COUNT', 1)
  .then(result => console.log(result))
```
 
### LRANGE command (stipsan#335 @sseidametov)

```js
redis
  .lrange('myKey', 0, 2)
  .then(result => console.log(result))
```
  • Loading branch information
stipsan authored Nov 15, 2017
1 parent f9dad15 commit dfaf417
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to

## [Unreleased]

## [3.2.0] - 2017-11-16

### Features

* Add LRANGE support (#335 @sseidametov)
* Scan command implementation (#334 @DrMegavolt)

## [3.1.3] - 2017-11-12

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
| [lpop](http://redis.io/commands/LPOP) | :white_check_mark: | :white_check_mark: |
| [lpush](http://redis.io/commands/LPUSH) | :white_check_mark: | :white_check_mark: |
| [lpushx](http://redis.io/commands/LPUSHX) | :white_check_mark: | :white_check_mark: |
| [lrange](http://redis.io/commands/LRANGE) | :white_check_mark: | :x: |
| [lrange](http://redis.io/commands/LRANGE) | :white_check_mark: | :white_check_mark: |
| [lrem](http://redis.io/commands/LREM) | :white_check_mark: | :white_check_mark: |
| [lset](http://redis.io/commands/LSET) | :white_check_mark: | :white_check_mark: |
| [ltrim](http://redis.io/commands/LTRIM) | :white_check_mark: | :x: |
Expand Down
52 changes: 38 additions & 14 deletions scripts/update-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ const blacklist = [
'substr',
'unlink',
];
const filteredCommands = commands.list.filter(command => blacklist.indexOf(command) === -1);
const filteredCommands = commands.list.filter(
command => blacklist.indexOf(command) === -1
);

let supportedCommands = 0;
let tableRows = `
| redis | ioredis | ioredis-mock |
|-------|:-------:|:------------:|`;
filteredCommands.forEach((command) => {
const redisCol = `[${command}](http://redis.io/commands/${command.toUpperCase()})`;
filteredCommands.forEach(command => {
const redisCol = `[${
command
}](http://redis.io/commands/${command.toUpperCase()})`;
const ioredisCol = command in redis.prototype ? ':white_check_mark:' : ':x:';
const supportedCommand = command in mockedRedis;
const ioredisMockCol = supportedCommand ? ':white_check_mark:' : ':x:';
Expand All @@ -37,7 +41,9 @@ filteredCommands.forEach((command) => {
|${redisCol}|${ioredisCol}|${ioredisMockCol}|`;
});

const percentage = Math.floor((supportedCommands / filteredCommands.length) * 100);
const percentage = Math.floor(
supportedCommands / filteredCommands.length * 100
);

let color = 'red';
if (percentage >= 28) {
Expand All @@ -56,21 +62,39 @@ if (percentage === 100) {
color = 'brightgreen';
}

const tableMd = `## Supported commands ![Commands Coverage: ${percentage}%](https://img.shields.io/badge/coverage-${percentage}%25-${color}.svg)
const tableMd = `## Supported commands ![Commands Coverage: ${
percentage
}%](https://img.shields.io/badge/coverage-${percentage}%25-${color}.svg)
${tableRows}`;

fs.writeFile(path.resolve(__dirname, '..', 'compat.md'), tableMd, 'utf8', (err) => {
if (err) throw err;
});
fs.writeFile(
path.resolve(__dirname, '..', 'compat.md'),
tableMd,
'utf8',
err => {
if (err) throw err;
}
);

const readme = path.resolve(__dirname, '..', 'README.md');
fs.readFile(readme, 'utf8', (err, readmeMd) => {
if (err) throw err;

fs.writeFile(readme, readmeMd.toString().replace(
/\[!\[Redis.+\]\(compat\.md\)/g,
`[![Redis Compatibility: ${percentage}%](https://img.shields.io/badge/redis-${percentage}%25-${color}.svg?style=flat-square)](compat.md)`
), 'utf8', (err2) => {
if (err2) throw err2;
});
fs.writeFile(
readme,
readmeMd
.toString()
.replace(
/\[!\[Redis.+\]\(compat\.md\)/g,
`[![Redis Compatibility: ${
percentage
}%](https://img.shields.io/badge/redis-${percentage}%25-${
color
}.svg?style=flat-square)](compat.md)`
),
'utf8',
err2 => {
if (err2) throw err2;
}
);
});
6 changes: 3 additions & 3 deletions src/commands/lrange.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on.
* These offsets can also be negative numbers indicating offsets starting at the end of the list. For example, -1 is the last element of the list, -2 the penultimate, and so on.
*
*
* @param {string} key
* @param {string} start Start index
* @param {string} end End index (included in returned range)
Expand All @@ -13,9 +13,9 @@ export function lrange(key, s, e) {
}
let start = parseInt(s, 10);
let end = parseInt(e, 10);

const list = this.data.get(key) || [];

if (start < 0) {
start = list.length + start;
}
Expand Down
4 changes: 1 addition & 3 deletions test/commands/lrange.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ describe('lrange', () => {
},
});

return redis
.lrange('foo', 10, 100)
.then(res => expect(res).toEqual([]));
return redis.lrange('foo', 10, 100).then(res => expect(res).toEqual([]));
});

it('should throw an exception if the key contains something other than a list', () => {
Expand Down

0 comments on commit dfaf417

Please sign in to comment.