Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 35b216e

Browse files
grpn-bulk-nlmMark Owsiak
authored andcommitted
chore: Apply latest nlm generator
1 parent 412a0fa commit 35b216e

18 files changed

+160
-108
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "groupon/legacy"
2+
"extends": "groupon/node4"
33
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/yarn.lock
2+
/package-lock.json
13
node_modules/
24
npm-debug.log
35
/tmp

.travis.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
language: node_js
22
node_js:
3-
- '0.10'
4-
- '4'
5-
before_install:
6-
- npm install -g npm@latest-2
7-
before_deploy:
8-
- 'git config --global user.email "[email protected]"'
9-
- 'git config --global user.name "Groupon"'
3+
- 4.6.1
4+
- 6.11.5
5+
- 8.9.0
106
deploy:
11-
provider: script
12-
script: ./node_modules/.bin/nlm release
13-
skip_cleanup: true
14-
'on':
15-
branch: master
16-
node: '4'
7+
- provider: script
8+
script: ./node_modules/.bin/nlm release
9+
skip_cleanup: true
10+
'on':
11+
branch: master
12+
node: 8.9.0
1713
services: memcached

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Generated by generator-nlm -->
1+
<!-- Generated by generator-js -->
22

33
# Contributing
44

@@ -8,6 +8,7 @@ This document outlines some of the practices we care about.
88
If you have any questions or suggestions about the process,
99
feel free to [open an issue](#reporting-issues)
1010
.
11+
1112
## How Can I Contribute?
1213

1314
### Reporting Issues
@@ -51,7 +52,7 @@ The general steps for creating a pull request are:
5152
1. If you're fixing a bug, be sure to write a test *first*.
5253
That way you can validate that the test actually catches the bug and doesn't pass.
5354
1. Make your changes to the code.
54-
Remember to update the tests if you add new features or change behavior.
55+
Remember to update the tests if you add new features or change behavior.
5556
1. Run the tests via `npm test`. This will also run style checks and other validations.
5657
You might see errors about uncommitted files.
5758
This is expected until you commit your changes.

lib/backend.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32+
3233
'use strict';
3334

34-
var typeMap = Object.create(null);
35+
const typeMap = Object.create(null);
3536

3637
function isBackend(object) {
3738
return typeof object.get === 'function' && typeof object.set === 'function';
@@ -44,10 +45,10 @@ exports.create = function create(options) {
4445
return options;
4546
}
4647

47-
var type = options.type || 'noop';
48-
var BackendClass = typeMap[type];
48+
const type = options.type || 'noop';
49+
const BackendClass = typeMap[type];
4950
if (!BackendClass) {
50-
throw new Error(type + ' is not a supported cache backend type');
51+
throw new Error(`${type} is not a supported cache backend type`);
5152
}
5253
return new BackendClass(options);
5354
};

lib/backends/memcached.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32+
3233
'use strict';
3334

34-
var promisify = require('bluebird').promisify;
35-
var _ = require('lodash');
36-
var Memcached = require('memcached');
35+
const promisify = require('bluebird').promisify;
36+
const _ = require('lodash');
37+
const Memcached = require('memcached');
3738

3839
function createClient(options) {
3940
if (options.client) {
4041
return options.client;
4142
}
42-
var hosts = options.hosts || '127.0.0.1:11211';
43+
const hosts = options.hosts || '127.0.0.1:11211';
4344
return new Memcached(hosts, options);
4445
}
4546

@@ -50,7 +51,7 @@ function normalizeValue(value) {
5051
/* Uses anything supporting the memcache protocol */
5152
function MemcachedBackend(options) {
5253
this.type = 'memcached';
53-
var client = this.client = createClient(options);
54+
const client = (this.client = createClient(options));
5455
this._clientGet = promisify(client.get, { context: client });
5556
this._clientSet = promisify(client.set, { context: client });
5657
this._clientDel = promisify(client.del, { context: client });
@@ -62,8 +63,7 @@ MemcachedBackend.prototype.get = function get(key) {
6263
};
6364

6465
MemcachedBackend.prototype.set = function set(key, value, options) {
65-
return this._clientSet(key, value, options.expire)
66-
.then(_.constant(value));
66+
return this._clientSet(key, value, options.expire).then(_.constant(value));
6767
};
6868

6969
MemcachedBackend.prototype.unset = function unset(key) {

lib/backends/memory.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32+
3233
'use strict';
3334

34-
var Bluebird = require('bluebird');
35+
const Bluebird = require('bluebird');
3536

36-
var util = require('../util');
37+
const util = require('../util');
3738

3839
/* Stores everything just in memory */
3940
function MemoryBackend() {
@@ -43,7 +44,7 @@ function MemoryBackend() {
4344
module.exports = MemoryBackend;
4445

4546
MemoryBackend.prototype.get = function get(key) {
46-
var wrappedValue = this.cache[key] || null;
47+
let wrappedValue = this.cache[key] || null;
4748
if (util.isExpired(wrappedValue && wrappedValue.e)) {
4849
wrappedValue = null;
4950
delete this.cache[key];

lib/backends/noop.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32+
3233
'use strict';
3334

34-
var Bluebird = require('bluebird');
35+
const Bluebird = require('bluebird');
3536

3637
/* Simple backend doing nothing */
3738
function NoopBackend() {

lib/cache.js

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32+
33+
/* eslint-disable no-underscore-dangle */
34+
3235
'use strict';
3336

34-
var _ = require('lodash');
37+
const _ = require('lodash');
3538

36-
var Backend = require('./backend');
37-
var getOrElse = require('./get-or-else');
38-
var util = require('./util');
39+
const Backend = require('./backend');
40+
const getOrElse = require('./get-or-else');
41+
const util = require('./util');
3942

4043
function Cache(options) {
4144
this.defaults = {
4245
freshFor: 0,
4346
expire: 0,
4447
};
4548
this.name = options.name || 'default';
46-
this.prefix = this.name + ':';
49+
this.prefix = `${this.name}:`;
4750
this.staleOrPending = {};
4851

4952
this.setDefaults(options.defaults);
@@ -60,9 +63,12 @@ Cache.prototype.setDefaults = function setDefaults(defaults) {
6063
};
6164

6265
Cache.prototype.setBackend = function setBackend(backendOptions) {
63-
backendOptions = typeof backendOptions === 'string' ? {
64-
type: backendOptions,
65-
} : backendOptions || {};
66+
backendOptions =
67+
typeof backendOptions === 'string'
68+
? {
69+
type: backendOptions,
70+
}
71+
: backendOptions || {};
6672
this.end();
6773
this.backend = Backend.create(backendOptions);
6874
return this.backend;
@@ -79,27 +85,31 @@ Cache.prototype.prepareOptions = function prepareOptions(options) {
7985
};
8086

8187
Cache.prototype._set = function _set(key, val, options) {
82-
var self = this;
88+
const self = this;
8389
function writeToBackend(resolvedValue) {
84-
return self.backend.set(key, {
85-
b: util.expiresAt(options.freshFor),
86-
d: resolvedValue,
87-
}, options);
90+
return self.backend.set(
91+
key,
92+
{
93+
b: util.expiresAt(options.freshFor),
94+
d: resolvedValue,
95+
},
96+
options
97+
);
8898
}
8999

90100
return this._applyTimeout(util.toPromise(val).then(writeToBackend));
91101
};
92102

93103
Cache.prototype.set = function set(rawKey, val, _opts, _cb) {
94-
var args = util.optionalOpts(_opts, _cb);
95-
var key = this.applyPrefix(rawKey);
96-
var optsWithDefaults = this.prepareOptions(args.opts);
104+
const args = util.optionalOpts(_opts, _cb);
105+
const key = this.applyPrefix(rawKey);
106+
const optsWithDefaults = this.prepareOptions(args.opts);
97107

98108
return this._set(key, val, optsWithDefaults).nodeify(args.cb);
99109
};
100110

101111
Cache.prototype._applyTimeout = function _applyTimeout(value) {
102-
var timeoutMs = this.defaults.timeout;
112+
const timeoutMs = this.defaults.timeout;
103113
if (timeoutMs > 0) {
104114
return value.timeout(timeoutMs);
105115
}
@@ -114,21 +124,23 @@ Cache.prototype._getWrapped = function _getWrapped(key) {
114124
Cache.prototype.getWrapped = Cache.prototype._getWrapped;
115125

116126
Cache.prototype.get = function get(rawKey, cb) {
117-
var key = this.applyPrefix(rawKey);
127+
const key = this.applyPrefix(rawKey);
118128

119-
return this._getWrapped(key).then(util.extractValue).nodeify(cb);
129+
return this._getWrapped(key)
130+
.then(util.extractValue)
131+
.nodeify(cb);
120132
};
121133

122134
Cache.prototype.getOrElse = function _getOrElse(rawKey, val, _opts, _cb) {
123-
var key = this.applyPrefix(rawKey);
124-
var args = util.optionalOpts(_opts, _cb);
125-
var optsWithDefaults = this.prepareOptions(args.opts);
135+
const key = this.applyPrefix(rawKey);
136+
const args = util.optionalOpts(_opts, _cb);
137+
const optsWithDefaults = this.prepareOptions(args.opts);
126138

127139
return getOrElse(this, key, val, optsWithDefaults).nodeify(args.cb);
128140
};
129141

130142
Cache.prototype.unset = function unset(rawKey, cb) {
131-
var key = this.applyPrefix(rawKey);
143+
const key = this.applyPrefix(rawKey);
132144

133145
return this._unset(key).nodeify(cb);
134146
};

lib/cached.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32+
3233
'use strict';
3334

34-
var Bluebird = require('bluebird');
35-
var _ = require('lodash');
36-
var util = require('util');
35+
const Bluebird = require('bluebird');
36+
const _ = require('lodash');
37+
const util = require('util');
3738

38-
var Cache = require('./cache');
39+
const Cache = require('./cache');
3940

40-
var namedCaches = Object.create(null);
41+
let namedCaches = Object.create(null);
4142

42-
var getName = util.deprecate(function getName(name) {
43+
const getName = util.deprecate(function getName(name) {
4344
return name || 'default';
4445
}, 'Unnamed caches and caches with non-string names are deprecated.');
4546

@@ -49,9 +50,14 @@ function cached(name, options) {
4950
}
5051

5152
if (!(name in namedCaches)) {
52-
namedCaches[name] = cached.createCache(_.extend({
53-
name: name,
54-
}, options || {}));
53+
namedCaches[name] = cached.createCache(
54+
_.extend(
55+
{
56+
name: name,
57+
},
58+
options || {}
59+
)
60+
);
5561
}
5662
return namedCaches[name];
5763
}

0 commit comments

Comments
 (0)