Skip to content

Commit

Permalink
Bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 13, 2019
1 parent 60f28fd commit bdfc93a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"dependencies": {
"map-age-cleaner": "^0.1.1",
"mimic-fn": "^1.0.0",
"p-is-promise": "^1.1.0"
"p-is-promise": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"delay": "^3.0.0",
"xo": "*"
"ava": "^1.0.1",
"delay": "^4.1.0",
"xo": "^0.23.0"
}
}
42 changes: 21 additions & 21 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'ava';
import delay from 'delay';
import m from '.';
import mem from '.';

test('memoize', t => {
let i = 0;
const f = () => i++;
const memoized = m(f);
const memoized = mem(f);
t.is(memoized(), 0);
t.is(memoized(), 0);
t.is(memoized(), 0);
Expand All @@ -19,7 +19,7 @@ test('memoize', t => {

test('memoize with multiple non-primitive arguments', t => {
let i = 0;
const memoized = m(() => i++);
const memoized = mem(() => i++);
t.is(memoized(), 0);
t.is(memoized(), 0);
t.is(memoized({foo: true}, {bar: false}), 1);
Expand All @@ -30,7 +30,7 @@ test('memoize with multiple non-primitive arguments', t => {

test.failing('memoize with regexp arguments', t => {
let i = 0;
const memoized = m(() => i++);
const memoized = mem(() => i++);
t.is(memoized(), 0);
t.is(memoized(), 0);
t.is(memoized(/Sindre Sorhus/), 1);
Expand All @@ -43,7 +43,7 @@ test.failing('memoize with Symbol arguments', t => {
let i = 0;
const arg1 = Symbol('fixture1');
const arg2 = Symbol('fixture2');
const memoized = m(() => i++);
const memoized = mem(() => i++);
t.is(memoized(), 0);
t.is(memoized(), 0);
t.is(memoized(arg1), 1);
Expand All @@ -59,7 +59,7 @@ test.failing('memoize with Symbol arguments', t => {
test('maxAge option', async t => {
let i = 0;
const f = () => i++;
const memoized = m(f, {maxAge: 100});
const memoized = mem(f, {maxAge: 100});
t.is(memoized(1), 0);
t.is(memoized(1), 0);
await delay(50);
Expand All @@ -78,7 +78,7 @@ test('maxAge option deletes old items', async t => {
deleted.push(item);
return remove(item);
};
const memoized = m(f, {maxAge: 100, cache});
const memoized = mem(f, {maxAge: 100, cache});
t.is(memoized(1), 0);
t.is(memoized(1), 0);
t.is(cache.has(1), true);
Expand All @@ -100,7 +100,7 @@ test('maxAge items are deleted even if function throws', async t => {
return i++;
};
const cache = new Map();
const memoized = m(f, {maxAge: 100, cache});
const memoized = mem(f, {maxAge: 100, cache});
t.is(memoized(1), 0);
t.is(memoized(1), 0);
t.is(cache.size, 1);
Expand All @@ -114,7 +114,7 @@ test('maxAge items are deleted even if function throws', async t => {
test('cacheKey option', t => {
let i = 0;
const f = () => i++;
const memoized = m(f, {cacheKey: x => x});
const memoized = mem(f, {cacheKey: x => x});
t.is(memoized(1), 0);
t.is(memoized(1), 0);
t.is(memoized(1, 2), 0);
Expand All @@ -125,7 +125,7 @@ test('cacheKey option', t => {
test('cache option', t => {
let i = 0;
const f = () => i++;
const memoized = m(f, {
const memoized = mem(f, {
cache: new WeakMap(),
cacheKey: x => x
});
Expand All @@ -139,15 +139,15 @@ test('cache option', t => {

test('promise support', async t => {
let i = 0;
const memoized = m(async () => i++);
const memoized = mem(async () => i++);
t.is(await memoized(), 0);
t.is(await memoized(), 0);
t.is(await memoized(10), 1);
});

test('do not cache rejected promises', async t => {
let i = 0;
const memoized = m(async () => {
const memoized = mem(async () => {
i++;

if (i === 1) {
Expand All @@ -157,7 +157,7 @@ test('do not cache rejected promises', async t => {
return i;
});

await t.throws(memoized(), 'foo bar');
await t.throwsAsync(memoized(), 'foo bar');

const first = memoized();
const second = memoized();
Expand All @@ -170,7 +170,7 @@ test('do not cache rejected promises', async t => {

test('cache rejected promises if enabled', async t => {
let i = 0;
const memoized = m(async () => {
const memoized = mem(async () => {
i++;

if (i === 1) {
Expand All @@ -182,22 +182,22 @@ test('cache rejected promises if enabled', async t => {
cachePromiseRejection: true
});

await t.throws(memoized(), 'foo bar');
await t.throws(memoized(), 'foo bar');
await t.throws(memoized(), 'foo bar');
await t.throwsAsync(memoized(), 'foo bar');
await t.throwsAsync(memoized(), 'foo bar');
await t.throwsAsync(memoized(), 'foo bar');
});

test('preserves the original function name', t => {
t.is(m(function foo() {}).name, 'foo'); // eslint-disable-line func-names, prefer-arrow-callback
t.is(mem(function foo() {}).name, 'foo'); // eslint-disable-line func-names, prefer-arrow-callback
});

test('.clear()', t => {
let i = 0;
const f = () => i++;
const memoized = m(f);
const memoized = mem(f);
t.is(memoized(), 0);
t.is(memoized(), 0);
m.clear(memoized);
mem.clear(memoized);
t.is(memoized(), 1);
t.is(memoized(), 1);
});
Expand All @@ -210,7 +210,7 @@ test('prototype support', t => {
const Unicorn = function () {
this.i = 0;
};
Unicorn.prototype.foo = m(f);
Unicorn.prototype.foo = mem(f);

const unicorn = new Unicorn();

Expand Down

0 comments on commit bdfc93a

Please sign in to comment.