ioredis-mock
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -1,8 +0,9 @@ | ||
# ioredis-mock change log | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
## [Unreleased] | ||
## [2.4.0] - 2017-03-05 | ||
@@ -330,3 +331,3 @@ | ||
[Unreleased]: https://github.com/stipsan/ioredis-mock/compare/v2.4.0...HEAD | ||
[v2.4.0]: https://github.com/stipsan/ioredis-mock/compare/v2.3.0...v2.4.0 | ||
[2.4.0]: https://github.com/stipsan/ioredis-mock/compare/v2.3.0...v2.4.0 | ||
[2.3.0]: https://github.com/stipsan/ioredis-mock/compare/v2.2.0...v2.3.0 | ||
@@ -333,0 +334,0 @@ [2.2.0]: https://github.com/stipsan/ioredis-mock/compare/v2.1.0...v2.2.0 |
@@ -7,6 +7,40 @@ 'use strict'; | ||
exports.set = set; | ||
var _index = require('./index'); | ||
function createGroupedArray(arr, groupSize) { | ||
var groups = []; | ||
for (var i = 0; i < arr.length; i += groupSize) { | ||
groups.push(arr.slice(i, i + groupSize)); | ||
} | ||
return groups; | ||
} | ||
function set(key, value) { | ||
for (var _len = arguments.length, options = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
options[_key - 2] = arguments[_key]; | ||
} | ||
var nx = options.indexOf('NX') !== -1; | ||
var xx = options.indexOf('XX') !== -1; | ||
var filteredOptions = options.filter(function (option) { | ||
return option !== 'NX' && option !== 'XX'; | ||
}); | ||
if (nx && xx) throw new Error('ERR syntax error'); | ||
if (nx && this.data.has(key)) return null; | ||
if (xx && !this.data.has(key)) return null; | ||
this.data.set(key, value); | ||
this.expires.delete(key); | ||
var expireOptions = new Map(createGroupedArray(filteredOptions, 2)); | ||
var ttlSeconds = expireOptions.get('EX') || expireOptions.get('PX') / 1000.0; | ||
if (ttlSeconds) { | ||
_index.expire.call(this, key, ttlSeconds); | ||
} else { | ||
this.expires.delete(key); | ||
} | ||
return 'OK'; | ||
} |
{ | ||
"name": "ioredis-mock", | ||
"version": "2.4.0", | ||
"description": "This library emulates ioredis by performing all operations in-memory.", | ||
@@ -9,7 +8,6 @@ "main": "./lib", | ||
"prepublish": "npm run clean && npm run build", | ||
"postpublish": "gh-release", | ||
"preversion": "node scripts/update-compat && git add . && git commit --allow-empty -m \"chore(compat): update feature table\"", | ||
"postversion": "git add package.json && git commit -m \"chore(package): update version\"", | ||
"prepush": "node scripts/update-compat && git add compat.md README.md && git commit --quiet -m \"Chore: Update feature compat table\" &> /dev/null || true", | ||
"build": "mkdirp lib && babel src --out-dir lib", | ||
"build:watch": "npm run build -- --watch", | ||
"pretest": "printf \"node \" && node --version", | ||
"test": "mocha --compilers js:babel-register --recursive", | ||
@@ -20,4 +18,13 @@ "test:watch": "npm test -- --watch --growl", | ||
"codeclimate": "codeclimate-test-reporter < ./coverage/lcov.info", | ||
"coverage": "npm run coveralls && npm run codeclimate" | ||
"coverage": "npm run coveralls && npm run codeclimate", | ||
"changelog:preview": "sr-changelog", | ||
"changelog:commit": "sr-changelog commit", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"release": { | ||
"analyzeCommits": "semantic-release-tamia/analyzeCommits", | ||
"verifyConditions": "condition-circle", | ||
"generateNotes": "semantic-release-tamia/generateNotes", | ||
"verifyRelease": "semantic-release-tamia/verifyRelease" | ||
}, | ||
"repository": { | ||
@@ -53,21 +60,22 @@ "type": "git", | ||
"peerDependencies": { | ||
"ioredis": "2.x" | ||
"ioredis": "2.x || 3.x" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "6.23.0", | ||
"babel-eslint": "7.1.1", | ||
"babel-preset-es2015": "6.22.0", | ||
"babel-register": "6.23.0", | ||
"babel-cli": "6.24.1", | ||
"babel-eslint": "7.2.1", | ||
"babel-preset-es2015": "6.24.0", | ||
"babel-register": "6.24.0", | ||
"codeclimate-test-reporter": "0.4.1", | ||
"coveralls": "2.11.16", | ||
"eslint": "3.17.0", | ||
"eslint-config-airbnb-base": "11.1.1", | ||
"coveralls": "2.13.0", | ||
"eslint": "3.19.0", | ||
"eslint-config-airbnb-base": "11.1.3", | ||
"eslint-plugin-import": "2.2.0", | ||
"expect": "1.20.2", | ||
"gh-release": "2.2.1", | ||
"growl": "1.9.2", | ||
"ioredis": "2.5.0", | ||
"husky": "^0.14.3", | ||
"ioredis": "^3.1.1", | ||
"istanbul": "1.1.0-alpha.1", | ||
"mkdirp": "0.5.1", | ||
"mocha": "3.2.0", | ||
"release-relief": "^1.0.1", | ||
"rimraf": "2.6.1" | ||
@@ -83,3 +91,4 @@ }, | ||
"redis-commands": "1.3.1" | ||
} | ||
} | ||
}, | ||
"version": "2.4.1" | ||
} |
@@ -1,17 +0,3 @@ | ||
ioredis-mock | ||
============ | ||
# ioredis-mock · [](https://circleci.com/gh/stipsan/ioredis-mock) [](https://ci.appveyor.com/project/stipsan/ioredis-mock) [](https://npm-stat.com/charts.html?package=ioredis-mock) [](https://www.npmjs.com/package/ioredis-mock) [](compat.md) | ||
[](https://greenkeeper.io/) | ||
[](https://ci.appveyor.com/project/stipsan/ioredis-mock) | ||
[](https://travis-ci.org/stipsan/ioredis-mock) | ||
[](https://circleci.com/gh/stipsan/ioredis-mock) | ||
[](https://codeclimate.com/github/stipsan/ioredis-mock) | ||
[](https://coveralls.io/github/stipsan/ioredis-mock) | ||
[](compat.md) | ||
[](https://www.npmjs.com/package/ioredis-mock) | ||
[](https://www.npmjs.com/package/ioredis-mock) | ||
[](https://nodei.co/npm/ioredis-mock/) | ||
This library emulates [ioredis](https://github.com/luin/ioredis) by performing all operations in-memory. | ||
@@ -18,0 +4,0 @@ The best way to do integration testing against redis and ioredis is on a real redis-server instance. |
@@ -71,4 +71,4 @@ require('babel-register'); | ||
fs.writeFile(readme, readmeMd.toString().replace( | ||
/\[!\[.+\(compat\.md\)/g, | ||
`[](compat.md)` | ||
/\[!\[Redis.+\]\(compat\.md\)/g, | ||
`[](compat.md)` | ||
), 'utf8', (err2) => { | ||
@@ -75,0 +75,0 @@ if (err2) throw err2; |
Sorry, the diff of this file is not supported yet
248684
2306
18
107
48