From 15710e8ab6cc57233225c10e675222aeb7c42c5f Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Sun, 18 Aug 2019 20:41:41 -0700 Subject: [PATCH] debounce carbon duplication --- lib/api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 36d84fe..982ab0b 100644 --- a/lib/api.js +++ b/lib/api.js @@ -109,11 +109,16 @@ function deleteSnippet(uid) { }) } +const createSnippet = debounce(data => updateSnippet(null, data), ms('5s'), { + leading: true, + trailing: false +}) + export default { snippet: { get: getSnippet, update: debounce(updateSnippet, ms('1s'), { leading: true, trailing: true }), - create: data => updateSnippet(null, data), + create: createSnippet, delete: id => deleteSnippet(id) }, tweet: debounce(tweet, ms('5s'), { leading: true, trailing: false }),