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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tooly

v0.9.9

Published

js utility functions

Downloads

29

Readme

tooly

A Javascript utility library covering everything from dom selection and css manipulation, object inheritance and extension, logging, event handling, string formatting, function execution timing, etc. Basically everything that I usually want/need at my fingertips for any given project. Compatible with node, amd, and modern browsers. 4.6kb minified and gzipped (3.4kb without the logger and timer modules, which shouldn't be used in production anyway - see dist/tooly-slim.js).

Update 2015.05.21

Tooly is now available as an angular service.

Install

npm: npm install tooly --save

bower: bower install tooly --save

Overview

Tooly is organized into categories, which are just that - organizational constructs - as opposed to individual modules. In a few cases the "category" is encompassed by a class. Below is a list of all categories, their related methods, and a description for the more interesting bits. The method names alone should give you an idea if tooly is something you'd find useful. Consult the documentation for a complete reference.

Collections

  • each
  • sort - sort array of objects by key

Frankie (class)

jQuery-like dom selection/manipulation

  • #addClass
  • #append
  • #attr
  • #children
  • #css
  • #each
  • #empty
  • #eq
  • #find
  • #get
  • #hasClass
  • #html
  • #on
  • #parent
  • #prepend
  • #remove
  • #removeClass
  • #toggleClass
  • #zilch

Handler (class)

Tiny "Event Emitter"; Observer pattern

  • #on
  • #register
  • #remove
  • #removeAll
  • #trigger

Logger (class)

Highly configurable, level-based and styled console logging for node and browser

  • #debug
  • #error
  • #group
  • #groupEnd
  • #info
  • #log
  • #warn
  • #trace

Object (or "everything else")

  • construct
  • extend
  • falsy
  • fromPrototype
  • inherit
  • scale
  • truthy
  • type - modified from Angus Croll's wicked-awesome toType

String

Functional versions of ECMAScript 6 stuff and useful formatters

  • contains
  • endsWith
  • extension
  • format - printf style string formatting
  • formatMoney
  • formatString - placeholder ('Drink {1}', "Marlort!") style string formatting
  • formatTime
  • leftPad
  • repeat
  • rightPad
  • sliceRel
  • startsWith
  • stripExtension
  • tag - jade syntax style dom builder

Timer (class)

Basic block/function execution timing

  • #end
  • funkyTime - static method, not part of Timer class
  • #log
  • #start
  • #stop
  • #toString

XHR

  • get
  • getJson

Documentation

View online at lokua.github.io/tooly or locally at ./doc/index.html

Custom Build

You can create a custom build of any combination of particular categories.

cd path_to/node_modules/tooly
# from the tooly module root, install dev dependecies
npm install
# run the script and `include` command
# passing as arguments modules (lowercase) you want included
node bin/build include logger timer string
# run the `grunt build` task to wrap tooly in umd, minify etc.
grunt build

By default the custom build will be located at ./dist/tooly-custom.js, or alternatively, you can specify a custom output file during the build instruction:

node bin/build include dom string -o tooly-custom.js && grunt build

Development

"Rough Drafts" are worked out in the test/_spec folder, either as .js files for node testing or .html for browser-based code, before being implemented in src. Testing is done with Mocha and Chai. Run with npm run test, or serve test/test.html for dom-related functions. Build with npm run all.

Changelog

0.9.9

  • fixed #falsy to not return true for empty arrays

0.8.6 (same as 0.8.5, ...fucking bower weirdness)

0.8.5

  • fixed tag bug - check if attrs exists before querying it

0.8.3

  • extendTo now returns the extended object, so one-liner like var _ = require('tooly').extendTo('lodash') works

0.8.2

  • fixed logger ctor bug when no option passed

0.8.1

  • added ready function
  • scale output now defaults to min=0, max=1

0.8.0

  • added extendTo function to lend tooly methods to another lib (tested with lodash)
  • Breaking Change: removed isHash- use tooly.type(obj, 'object') instead
  • added tooly.empty to collections
  • fixed global leak _0 in Frankie#css

0.7.0

  • Breaking change: Handler is now only on, register, remove, removeAll, and trigger (no aliases)
  • Breaking change: Handler#remove(<name>) now deletes the <name> property from the handlers object (instead of just emptying that <name>'s array)
  • Breaking change: tooly.Logger now defaults to level 0, and can be instantiated without arguments
  • added symbol param to formatMoney

0.6.5

  • Frankie#find and Frankie#attr bugfix
  • added Frankie#each

0.6.4

  • Logger options bypassTimestamp and bypassLine now default to true

License

The MIT License (MIT)

© 2014, 2015 Joshua Kleckner

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.