PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/flash/src/js/utils.js

http://echo-nest-remix.googlecode.com/
JavaScript | 31 lines | 28 code | 3 blank | 0 comment | 8 complexity | fe355c14c266c154701f0f4c93a355b7 MD5 | raw file
 1function extend(destination, source) {
 2    for (var property in source) {
 3        destination[property] = source[property];
 4    }
 5    return destination;
 6}
 7
 8Array.prototype.sum = function() {
 9    var result = 0;
10    for (var i = 0; i < this.length; i++) {
11        result += this[i];
12    }
13};
14
15if (!Array.prototype.indexOf) {
16    Array.prototype.indexOf = function(elt /*, from*/) {
17        var len = this.length >>> 0;
18
19        var from = Number(arguments[1]) || 0;
20        from = (from < 0) ? Math.ceil(from) : Math.floor(from);
21        if (from < 0) {
22            from += len;
23        }
24        for (; from < len; from++) {
25            if (from in this && this[from] === elt) {
26                return from;
27            }
28        }
29        return -1;
30    };
31};