Easy JS Solution
\nvar findPairs = function(nums, k) {\n    if (k < 0) return 0;   \n    nums = (k === 0) ? nums : Array.from(new Set(nums));\n    let m = new Map(), res = 0;\n 
```\nvar findPairs = function(nums, k) {\n    if (k < 0) return 0;   \n    nums = (k === 0) ? nums : Array.from(new Set(nums));\n    let m = new Map(), res = 0;\n    for (let num of nums) {\n        if (m.get(num+k) === 1) res++;\n        if (num+k !== num-k && m.get(num-k) === 1) res++;\n        m.set(num, m.get(num)+1 || 1);\n    }\n    return res;\n};\n```
['JavaScript']