@@ 889-905 (lines=17) @@ | ||
886 | return out; |
|
887 | }, |
|
888 | ||
889 | pickMatching: function(slots, evenIfNull = false){ |
|
890 | var list = this; |
|
891 | var out = []; |
|
892 | ||
893 | if (!slots){ |
|
894 | return out; |
|
895 | } |
|
896 | ||
897 | for (var i = 0, il = slots.length;i<il;i++){ |
|
898 | id = slots[i]; |
|
899 | val = list[id]; |
|
900 | if (val != null || evenIfNull) { |
|
901 | out[id] = val; |
|
902 | } |
|
903 | } |
|
904 | return out; |
|
905 | }, |
|
906 | ||
907 | /** Get the data of `list`, by searching `indexID` in `indexArr`, or return `defaultVal` if not found */ |
|
908 | getByMatchingArray: function(indexArr, indexID, defaultVal = null){ |
|
@@ 871-887 (lines=17) @@ | ||
868 | return list[parseInt(Math.random() * 1000000) % list.length]; |
|
869 | }, |
|
870 | ||
871 | pick: function(slots){ |
|
872 | var list = this; |
|
873 | var out = []; |
|
874 | ||
875 | if (!slots){ |
|
876 | return out; |
|
877 | } |
|
878 | ||
879 | for (var i = 0, il = slots.length;i<il;i++){ |
|
880 | id = slots[i]; |
|
881 | val = list[id]; |
|
882 | if (val != null) { |
|
883 | out.push(val); |
|
884 | } |
|
885 | } |
|
886 | return out; |
|
887 | }, |
|
888 | ||
889 | pickMatching: function(slots, evenIfNull = false){ |
|
890 | var list = this; |