Daniel Beardsley
Daniel Beardsley

Reputation: 20387

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.

Upvotes: 5

Views: 465

Answers (4)

Nikolay
Nikolay

Reputation: 1392

Btw, RightJS is also available on NPM

Upvotes: 1

josh3736
josh3736

Reputation: 145062

Node's GitHub wiki has a list of CommonJS-compatible modules which will run in Node and browsers.

Some of the other modules on that page may also run in a browser environment. For example, the excellent DateJS works fine in Node. (It is available as a NPM.)

Upvotes: 2

generalhenry
generalhenry

Reputation: 17319

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.

Upvotes: 4

user113716
user113716

Reputation: 322582

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.

Upvotes: 3

Related Questions