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

4

5

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.

Willena answered 21/2, 2011 at 18:32 Comment(0)
B
4

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.

Bitterroot answered 21/2, 2011 at 18:47 Comment(0)
B
3

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.

Bertha answered 21/2, 2011 at 18:35 Comment(0)
A
2

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.)

Adamsun answered 21/2, 2011 at 21:31 Comment(0)
B
1

Btw, RightJS is also available on NPM

Bloomers answered 26/2, 2011 at 18:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.