Skip to content

Commit 5844aa5

Browse files
committed
Fix lint
1 parent 19b4d3e commit 5844aa5

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

benchmark/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const memoizedRamda = R.memoize(fibonacci)
6969
const memoizedImemoized = iMemoized.memoize(fibonacci)
7070
const memoizedLRUSingleCache = lruMemoize(fibonacci)
7171
const memoizedLRUWithLimit = lruMemoize(fibCount)(fibonacci)
72-
const memoizedNano = nano(fibonacci);
72+
const memoizedNano = nano(fibonacci)
7373
const memoizedFastMemoizeCurrentVersion = fastMemoize(fibonacci)
7474

7575
const benchmark = new Benchmark.Suite()
@@ -100,7 +100,7 @@ benchmark
100100
memoizedLRUWithLimit(fibNumber)
101101
})
102102
.add('nano-memoize', () => {
103-
memoizedNano(fibNumber)
103+
memoizedNano(fibNumber)
104104
})
105105
.add(`fast-memoize@current`, () => {
106106
memoizedFastMemoizeCurrentVersion(fibNumber)

src/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ function memoize (fn, options) {
2626
//
2727

2828
function isPrimitive (value) {
29-
return value == null || typeof value === "number" || typeof value === "boolean"; // || typeof value === "string" 'unsafe' primitive for our needs
29+
return value == null || typeof value === 'number' || typeof value === 'boolean' // || typeof value === "string" 'unsafe' primitive for our needs
3030
}
3131

3232
function monadic (fn, cache, serializer, arg) {
3333
var cacheKey = isPrimitive(arg) ? arg : serializer(arg)
3434

35-
var computedValue = cache.get(cacheKey);
36-
if (typeof computedValue==="undefined") {
35+
var computedValue = cache.get(cacheKey)
36+
if (typeof computedValue === 'undefined') {
3737
computedValue = fn.call(this, arg)
3838
cache.set(cacheKey, computedValue)
3939
}
4040

41-
return computedValue;
41+
return computedValue
4242
}
4343

4444
function variadic (fn, cache, serializer) {
4545
var args = Array.prototype.slice.call(arguments, 3)
4646
var cacheKey = serializer(args)
4747

48-
var computedValue = cache.get(cacheKey);
49-
if (typeof computedValue==="undefined") {
48+
var computedValue = cache.get(cacheKey)
49+
if (typeof computedValue === 'undefined') {
5050
computedValue = fn.apply(this, args)
5151
cache.set(cacheKey, computedValue)
5252
}
5353

54-
return computedValue;
54+
return computedValue
5555
}
5656

5757
function assemble (fn, context, strategy, cache, serialize) {

test/index.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,19 @@ test('memoize functions with spread arguments', () => {
8888
expect(memoizedMultiply(2, 4, 5, 6)).toEqual([8, 10, 12])
8989
})
9090

91-
9291
test('single arg primitive test', () => {
9392
function kindOf (arg) {
94-
return (arg && typeof arg ==="object" ? arg.constructor.name : typeof arg)
93+
return (arg && typeof arg === 'object' ? arg.constructor.name : typeof arg)
9594
}
9695

9796
const memoizedKindOf = memoize(kindOf)
9897

9998
// Assertions
100-
expect(memoizedKindOf(2)).toEqual("number")
101-
expect(memoizedKindOf("2")).toEqual("string")
99+
expect(memoizedKindOf(2)).toEqual('number')
100+
expect(memoizedKindOf('2')).toEqual('string')
102101
})
103102

104103
test('inject custom cache', () => {
105-
let hasMethodExecutionCount = 0
106104
let setMethodExecutionCount = 0
107105

108106
// a custom cache instance must implement:
@@ -111,8 +109,7 @@ test('inject custom cache', () => {
111109
// - set
112110
// - delete
113111
const customCacheProto = {
114-
has (key) {
115-
hasMethodExecutionCount++
112+
has (key) {
116113
return (key in this.cache)
117114
},
118115
get (key) {
@@ -144,7 +141,6 @@ test('inject custom cache', () => {
144141
memoizedMinus(3, 1)
145142
memoizedMinus(3, 1)
146143

147-
// expect(hasMethodExecutionCount).toBe(2)
148144
expect(setMethodExecutionCount).toBe(1)
149145
})
150146

@@ -171,8 +167,6 @@ test('inject custom serializer', () => {
171167
expect(serializerMethodExecutionCount).toBe(2)
172168
})
173169

174-
175-
176170
test('explicitly use exposed monadic strategy', () => {
177171
let numberOfCalls = 0
178172
function plusPlus (number) {

0 commit comments

Comments
 (0)