Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: Is there a utils library? [closed]

Tags:

javascript

I'm wondering if such a library exists, where the library contains only a collection of common utility functions such as trim, indexOf (for arrays), map, each, typeOf and so on...

I'm aware that jQuery provides some of the functions I listed above, but I'm looking for something that is designed purely for this (I really don't need jQuery on the server-side running node.js for instance, nor do I want to depend on it if I'm writing a non-jQuery-related JavaScript library). I've recently begun collecting an assortment of these functions for future copy/pasting, but my guess is that there are many others that I won't even know to look for, or think of using, unless someone presents them to me.

like image 229
David Tang Avatar asked Jan 13 '11 14:01

David Tang


People also ask

What is JavaScript utility library?

The utility libraries (collections of functions implementing common tasks like finding unique items of an array, formatting dates, etc.) impact heavily the bundle size. Examples of utility libraries in JavaScript are Lodash, Ramda, Date-fns, Math. js. Let's discuss when it makes sense to use utility libraries.

How many JavaScript libraries are there?

As we've said, JavaScript libraries are used to perform specific functions. There are around 83 of them, each created to serve some purpose, and we are going to cover some of their usability in this section.


3 Answers

I'm fond of underscore.js; it doesn't provide string utilities such as trim; it's focused on object-oriented and functional utilities, including all of the other things you mention. Another nice thing about it is that it doesn't reference the DOM at all, so it's useful for javascript programming that isn't web-based or DOM related.

like image 115
Jacob Mattison Avatar answered Nov 15 '22 08:11

Jacob Mattison


The functions you mention are all standard in ECMAScript 5. And this library implements them in such a way that you can use them in older browsers/JavaScript versions as well, in a way that will be compatible when your environment catches up with the standard:

https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js

like image 4
Daniel Earwicker Avatar answered Nov 15 '22 06:11

Daniel Earwicker


Boiler.js is an up and coming utility library that offers many useful JavaScript utilities and is a direct competitor with Underscore.js.

like image 1
Xaxis Avatar answered Nov 15 '22 07:11

Xaxis