diff options
author | Ben Firshman <ben@firshman.co.uk> | 2010-06-05 00:13:48 +0100 |
---|---|---|
committer | Ben Firshman <ben@firshman.co.uk> | 2010-06-05 00:13:48 +0100 |
commit | 4fc5d574b3372bc8e6cca3fe3862b22e7e8fda53 (patch) | |
tree | 6a0fdb6708bf76cfa94e9752f6b0eb0b510b43aa /js.2/utils.js | |
parent | f514c239772e00f3c082e387efd9dded4f85cfbf (diff) | |
download | jsnes-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.js | 18 |
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]; + } + } +} |