Files
DefinitelyTyped/memoizee/memoizee-tests.ts
Andy 5bce8fab2e Merge more from types-2.0 to `master (#13770)
* Add memoizee definitions

* Fix common issues, added doc

* Removed blank line

* fix test

* Fix test methods

* Fix check style

* Fix check style

* Fixing semver header

* Fixing semver header

* `memoizee`: Clean up types

* Types 2.0 - Fix JS-quantities (#12739)

* Enable strict null checking per readme FAQ.

* Add tslint.json.

* Improve test file with project spec.

* Fix js-quantities d.ts, with adjustment of test.

* Add trailing newline to tslint.

* Simplify functional interface per linter.

* js-quantities: add readme examples to tests

* js-quantities: fix & clean declaration

* d3-selection: Mark before param of insert() as optional (#13090)

Selection<etc>.insert functions perfectly well without a `before` selector -- it does so in many d3 official examples.

This corrects the type signature to mark it as optional.

* [react-intl] bugfix for #12716 (#12906)

* fix for issue introduced in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12716

* injectIntl is now usable as class decorator

* fixed test

* use inferface instead of type

* format document

* fix chai-json-schema styling (#13537)

* googlemaps: Allow Marker.setAnimation(null) and Marker.setMap(null) (#13240)

* googlemaps: Allow Marker.setAnimation(null)

 * Also, turn on strictNullChecks
 * Allow new google.maps.Map(null) since it's technically possible with Google's example code from the docs

Signed-off-by: Iqbal Yusuf <iyusuf@corelogic.com>

* googlemaps: Allow Marker.setMap(null)

 * Also, add more test code from the Google Maps API documentation

Signed-off-by: Grant Hutchins <ghutchins@pivotal.io>

* Added the brand property to the StripeCardData and fix style issues, lint (#13084)

* Add the "brand" field to StipeCardData
Added the StipeCardDataBrand type.
Added the `brand` property to the `StripeCardData` declaration with the type
`'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'`
Reference: https://stripe.com/docs/api#card_object

* Run linter, fix issues. set --strictNullChecks.
Unsure about ambient declaration:
Removed as it seemed to be in error:
  1. case was not correct
  2. the export was the type of the global which is unconditionally defined.
  3. this module does not seem a suitable candidate for a UMD declaration.

* Use header version of 0.0; explain Stripe versioning in comments

* Restore global

* Added tests
2017-01-05 12:05:44 -08:00

62 lines
1.7 KiB
TypeScript

import memoize = require('memoizee');
var fn = function (one: string, two?: number, three?: any) { /* ... */ };
let memoized = memoize(fn);
memoized('foo', 3, 'bar');
memoized('foo', 3, 'bar');
memoized = memoize(fn, { length: 2 });
memoized('foo');
memoized('foo', undefined);
memoized('foo', 3, {});
memoized('foo', 3, 13);
memoized('foo', undefined);
memoized('foo', undefined);
memoized('foo', 3, {});
memoized('foo', 3, 13);
memoized('foo', 3, 13);
memoized = memoize(fn, { primitive: true });
memoized('/path/one');
memoized('/path/one');
memoized = memoize(fn, { dispose: function (value:number) { /*…*/ } });
var foo3 = memoized('foo', 3);
var bar7 = memoized('bar', 7);
memoized.clear('foo', 3); // Dispose called with foo3 value
memoized.clear('bar', 7); // Dispose called with bar7 value
memoized.delete('foo', 0);
var mFn = memoize(function (hash:any) {
// body of memoized function
}, { normalizer: function (args:any) {
// args is arguments object as accessible in memoized function
return JSON.stringify(args[0]);
} });
mFn({ foo: 'bar' });
memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] });
memoized(String(12), [1,2,3].length);
memoized("12", Number(true));
memoized(String({ toString: function () { return "12"; } }), Number({}));
{
var afn = function (a:number, b:number) {
return new Promise(function (res) { res(a + b); });
};
let memoized = memoize(afn, { promise: true });
memoized(3, 7);
memoized(3, 7);
}
memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 });
memoized('foo', 3);
memoized('foo', 3);
setTimeout(function () {
memoized('foo', 3);
}, 500);
setTimeout(function () {
memoized('foo', 3);
}, 1300);