From a1103158551ace4232b613d290f5d193a7c5185f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 26 Mar 2016 12:53:40 +0000 Subject: Multiple minor tweaks. Some of this code is showing its age, so these are just a number of minor tweaks (to keep things clear, consistent and concise). Also, add a couple of tests (while we're at it). --- lib/clipboard.coffee | 2 +- lib/utils.coffee | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/clipboard.coffee b/lib/clipboard.coffee index f0fb83b1..af143dd9 100644 --- a/lib/clipboard.coffee +++ b/lib/clipboard.coffee @@ -6,7 +6,7 @@ Clipboard = textArea # http://groups.google.com/group/chromium-extensions/browse_thread/thread/49027e7f3b04f68/f6ab2457dee5bf55 - copy: (data) -> + copy: ({data}) -> textArea = @_createTextArea() textArea.value = data diff --git a/lib/utils.coffee b/lib/utils.coffee index 3b2a59a4..31bb47b6 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -162,10 +162,8 @@ Utils = # Transform "zjkjkabz" into "abjkz". distinctCharacters: (str) -> - unique = "" - for char in str.split("").sort() - unique += char unless 0 <= unique.indexOf char - unique + chars = str.split("").sort() + (ch for ch, index in chars when index == 0 or ch != chars[index-1]).join "" # Compares two version strings (e.g. "1.1" and "1.5") and returns # -1 if versionA is < versionB, 0 if they're equal, and 1 if versionA is > versionB. -- cgit v1.2.3