Permalink
Browse files

unique fn fix, support objects and functions.

  • Loading branch information...
1 parent 080561e commit 4c77fce0ef4fdaf64f9d1fb4ebaf895fdb6a1418 @cainrus committed Dec 20, 2011
Showing with 9 additions and 8 deletions.
  1. +9 −8 Source/Types/Array.Extras.js
@@ -47,14 +47,15 @@ Array.implement({
},
unique: function(){
- var h = {}, ret = [], arrLen = this.length, next=0, el;
- while (arrLen--) {
- el = this[arrLen];
- if (h[el]) continue;
- ret[next++] = el;
- h[el] = 1;
- }
- return ret;
+ var h = {}, ret = [], arrLen = this.length, next=0, el, type;
+ while (arrLen--) {
+ el = this[arrLen];
+ type = typeof el;
+ if (type !== 'object' && type !== 'function' && h[el]) continue;
+ ret[next++] = el;
+ h[el] = 1;
+ }
+ return ret;
},
shuffle: function(){

0 comments on commit 4c77fce

Please sign in to comment.