From bdfc93ad856fdf5622fc6406f601c9762370bc8a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 13 Jan 2019 10:58:53 +0700 Subject: [PATCH] Bump dependencies --- package.json | 8 ++++---- test.js | 42 +++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index ae551f6..2ceced1 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/test.js b/test.js index 4ea6423..7092e07 100644 --- a/test.js +++ b/test.js @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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 }); @@ -139,7 +139,7 @@ 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); @@ -147,7 +147,7 @@ test('promise support', async t => { test('do not cache rejected promises', async t => { let i = 0; - const memoized = m(async () => { + const memoized = mem(async () => { i++; if (i === 1) { @@ -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(); @@ -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) { @@ -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); }); @@ -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();