npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tul

v0.0.31

Published

Tiny Utilities Library

Readme

TUL - Tiny Utilities Library

"Tiny" === around 5.7K when minified, 2.3K when minified + gzipped

If you want something well tested which is guaranteed to work all the time on all browsers, this isn't it - try lodash and/or jQuery and their friends instead.

TUL works in a lot of the cases where I want it to (mainly very up to date Chrome/Crosswalk and Firefox/Firefox OS) and that's the only promise I can make.

It also has a slightly idiosyncratic API. I seem to end up writing and using the same chunks of code over and over, so I put them in here, hence the apparently random bundle of functions.

I will probably add/remove stuff to this as I think of it and change my mind.

Usage

Use an AMD loader like requirejs:

require('tul', function (TUL) {
  // ...
});

Or load it in your HTML file:

<script src="tul.js"></script>

Or use (some of) it from node:

var TUL = require('tul');

("some of" because parts of TUL won't work without a DOM.)

API

The following are available:

  • TUL.$(): wrapper for document.querySelectorAll(), which returns an array of elements or single element (depending on the number of matching elements) rather than a NodeList
  • TUL.req(): Ajax request
  • TUL.jsonp(): JSONP request
  • TUL.ext(): extend an object with other objects
  • TUL.defaults(): set undefined object properties to default values
  • TUL.forEach(): iterate object properties
  • TUL.tpl(): very simple templating (iterators and properties, no filters)
  • TUL.keygen(): key generating function which generates unique random keys (though not unique across multiple TUL instances, e.g. if you use it for database keys which are written from multiple pages)
  • TUL.find(): find items in a collection which satisfy a test function
  • Array.forEach(), Array.find(): shims for ES6 array methods
  • Array.map(): similar to Underscore's _.map() function
  • TUL.throttle(): same as Underscore's _.throttle() function - restrict a function so it can only be invoked every N ms
  • TUL.isArray(): check whether a value is an array
  • TUL.chomp(): remove trailing character from a string (useful for making URLs)
  • TUL.norm(): normalise a string by removing non-word characters, replacing accented characters with equivalents without accents, replacing spaces with hyphens, and lowercasing; useful for creating keys/URL slugs
  • TUL.round(): round a number
  • TUL.zpad(): zero pad a number < 10
  • TUL.timefmt(): format seconds to "HH:MM:ss"
  • TUL.Ev(): prototype which can be used to add on()/off()/fire() methods to an object (mix it into an object with TUL.ext())
  • TUL.Collection/TUL.Model: factory functions to create event-firing collections/models, e.g. TUL.ext(MyObject, TUL.Model())

See the source for details (I may get round to some automated docs eventually).

Build

To make a minified version of the library:

grunt min

The output goes into build/TUL.min.js.

Tests

You can run the node-testable pieces with grunt:

grunt test

The non-node pieces are manually tested using the HTML files in the examples/ directory.

Test coverage is far from 100%.

Licence

MIT - see LICENCE-MIT