I want to use some features for server-side javascript. I think prototype is checking the browser type, but of course node.js is not a browser. I get the following error:
$ node
> require('./prototype') ;
ReferenceError: navigator is not defined
at /home/guest/projects/javascript/prototype.js:14:5
at Object.<anonymous> (/home/guest/projects/javascript/prototype.js:23:4)
at Module._compile (node.js:462:23)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at loadModule (node.js:283:14)
at require (node.js:411:14)
at cwdRequire (repl:29:10)
at [object Context]:1:1
at Interface.<anonymous> (repl:96:19)
prototype.js is version 1.7, node.js is version 0.2.6
Prototype is written to be modular. This means you can use just the useful parts that extend Array and Class and Function (I love those bits!) and leave out the parts that deal with browser and DOM (the bits that are slow in IE and non-existent in node).
Start by going to https://github.com/sstephenson/prototype then pick out the desired parts from src/prototype/
and src/prototype/lang/
.
I wish you luck on such a fascinating challenge.
Late answer, but I'm sure it can still be useful to some people:
https://github.com/Rixius/prototype.node.js
Few days ago, I did something like that myself, and realized it had already been done... This repo is hard to find even with the github search.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With