summaryrefslogtreecommitdiffstats
path: root/js.2/utils.js
diff options
context:
space:
mode:
authorBen Firshman <ben@firshman.co.uk>2010-06-05 00:13:48 +0100
committerBen Firshman <ben@firshman.co.uk>2010-06-05 00:13:48 +0100
commit4fc5d574b3372bc8e6cca3fe3862b22e7e8fda53 (patch)
tree6a0fdb6708bf76cfa94e9752f6b0eb0b510b43aa /js.2/utils.js
parentf514c239772e00f3c082e387efd9dded4f85cfbf (diff)
downloadjsnes-4fc5d574b3372bc8e6cca3fe3862b22e7e8fda53.zip
jsnes-4fc5d574b3372bc8e6cca3fe3862b22e7e8fda53.tar.gz
jsnes-4fc5d574b3372bc8e6cca3fe3862b22e7e8fda53.tar.bz2
Eurgh. Better versioning system will be done when Jake is sorted
Diffstat (limited to 'js.2/utils.js')
-rw-r--r--js.2/utils.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js.2/utils.js b/js.2/utils.js
new file mode 100644
index 0000000..859296c
--- /dev/null
+++ b/js.2/utils.js
@@ -0,0 +1,18 @@
+
+NES.Utils = {
+ arraycopy: function(src, srcPos, dest, destPos, length) {
+ for (var i=0; i<length; ++i) {
+ dest[destPos+i] = src[srcPos+i];
+ }
+ },
+
+ // http://www.sitepoint.com/blogs/2006/01/17/javascript-inheritance/
+ copyPrototype: function(descendant, parent) {
+ var sConstructor = parent.toString();
+ var aMatch = sConstructor.match( /\s*function (.*)\(/ );
+ if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }
+ for (var m in parent.prototype) {
+ descendant.prototype[m] = parent.prototype[m];
+ }
+ }
+}