2013-10-25 05:25:42 +08:00
|
|
|
/*
|
|
|
|
* utils
|
|
|
|
* cylonjs.com
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 The Hybrid Group
|
|
|
|
* Licensed under the Apache 2.0 license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
(function() {
|
2013-10-29 02:51:03 +08:00
|
|
|
var __slice = [].slice;
|
|
|
|
|
2013-10-25 05:25:42 +08:00
|
|
|
global.every = function(interval, action) {
|
|
|
|
return setInterval(action, interval);
|
|
|
|
};
|
|
|
|
|
|
|
|
global.after = function(delay, action) {
|
|
|
|
return setTimeout(action, delay);
|
|
|
|
};
|
|
|
|
|
2013-10-29 02:51:03 +08:00
|
|
|
global.proxyFunctionsToObject = function(methods, target, base, force) {
|
2013-10-29 08:48:29 +08:00
|
|
|
var method, _fn, _i, _len;
|
2013-10-29 02:51:03 +08:00
|
|
|
if (base == null) {
|
|
|
|
base = this;
|
|
|
|
}
|
|
|
|
if (force == null) {
|
|
|
|
force = false;
|
|
|
|
}
|
2013-10-29 08:48:29 +08:00
|
|
|
_fn = function(method) {
|
|
|
|
return base.prototype[method] = function() {
|
|
|
|
var args;
|
|
|
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
|
|
return target[method].apply(target, args);
|
|
|
|
};
|
|
|
|
};
|
2013-10-29 02:51:03 +08:00
|
|
|
for (_i = 0, _len = methods.length; _i < _len; _i++) {
|
|
|
|
method = methods[_i];
|
|
|
|
if (!force) {
|
2013-10-29 08:48:29 +08:00
|
|
|
if (typeof base.prototype[method] === 'function') {
|
2013-10-29 02:51:03 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2013-10-29 08:48:29 +08:00
|
|
|
_fn(method);
|
2013-10-29 02:51:03 +08:00
|
|
|
}
|
|
|
|
return base;
|
|
|
|
};
|
|
|
|
|
2013-10-25 05:25:42 +08:00
|
|
|
Number.prototype.seconds = function() {
|
|
|
|
return this * 1000;
|
|
|
|
};
|
|
|
|
|
|
|
|
Number.prototype.second = function() {
|
|
|
|
return this.seconds(this);
|
|
|
|
};
|
|
|
|
|
|
|
|
}).call(this);
|