Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS library that provides simple utilities for browsers and the nodejs environment?

I'm looking for a javascript library that attempts to provide the same simple utilities in both the browser environment AND nodejs (iteration, mapping, maybe control-flow) so that code can more easily be re-used across server and client. I know you can hack out parts of any JS library (YUI, jQuery, ...) and get them to work in both environments, I'm just wondering if it's already been done or standardized.

The closest I've seen is this: https://github.com/kof/sharedjs

But it's incomplete and has some odd stuff. I'm wondering if there is something more polished before I fork and hack.

like image 741
Daniel Beardsley Avatar asked Feb 21 '11 18:02

Daniel Beardsley


2 Answers

The underscore library was built to add more functional programming to jquery, things like mapping, and also templating.

Because it doesn't rely on the DOM (it leaves that to jquery) it functions well in node.

like image 149
generalhenry Avatar answered Sep 26 '22 08:09

generalhenry


The RightJS link library has a server build link that has node.js in mind.

From the download page:

RightJS is also available as a server-side library. In this case it contains only the native JavaScript unit extensions and the Class, Observer, Options units along with all the non-DOM utility functions from the Util module.

Our server-side build follows the CommonJS principles and is ready for use with the node.js framework.

like image 30
user113716 Avatar answered Sep 22 '22 08:09

user113716