es6-promise-debounce icon indicating copy to clipboard operation
es6-promise-debounce copied to clipboard

TS typings

Open apparition47 opened this issue 7 years ago • 2 comments

Usage: import debounce from 'es6-promise-debounce';

TypeScript typings definition if needed.

apparition47 avatar Nov 09 '16 23:11 apparition47

hi, can you please explain the "index.d.ts" !? I dont get it :)

moszeed avatar Nov 11 '16 07:11 moszeed

It allows your package to be imported in a TypeScript project and adds static type definitions for it too. I used the default name index.d.ts so your package.json doesn't have to be modified but a TS project can still resolve it. Other projects like momentjs include a .d.ts as well.

This is an optional PR and I can understand if you want to keep this project lightweight but I thought it would be a nice addition since it's just a small 2 lines to get it working 😄 . Thanks!

TS Usage:

import debounce from 'es6-promise-debounce';

var debouncedFunction = debounce(function() {
    return new Promise(function(resolve) {
        resolve();
    });
}, 200);

debouncedFunction().then(function() { console.log('this one should be ignored'); });
debouncedFunction().then(function() { console.log('this one should be executed'); });

apparition47 avatar Nov 12 '16 00:11 apparition47