tooly v0.9.9
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
loggerandtimermodules, which shouldn't be used in production anyway - seedist/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
eachsort- 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")
constructextendfalsyfromPrototypeinheritscaletruthytype- modified from Angus Croll's wicked-awesome toType
String
Functional versions of ECMAScript 6 stuff and useful formatters
containsendsWithextensionformat- printf style string formattingformatMoneyformatString- placeholder ('Drink {1}', "Marlort!") style string formattingformatTimeleftPadrepeatrightPadsliceRelstartsWithstripExtensiontag- jade syntax style dom builder
Timer (class)
Basic block/function execution timing
#endfunkyTime- static method, not part ofTimerclass#log#start#stop#toString
XHR
getgetJson
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 buildBy 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 buildDevelopment
"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 #
falsyto not return true for empty arrays
0.8.6 (same as 0.8.5, ...fucking bower weirdness)
0.8.5
- fixed
tagbug - check if attrs exists before querying it
0.8.3
extendTonow returns the extended object, so one-liner likevar _ = require('tooly').extendTo('lodash')works
0.8.2
- fixed logger ctor bug when no option passed
0.8.1
- added
readyfunction scaleoutput now defaults to min=0, max=1
0.8.0
- added
extendTofunction to lend tooly methods to another lib (tested with lodash) - Breaking Change: removed
isHash- usetooly.type(obj, 'object')instead - added
tooly.emptyto collections - fixed global leak
_0inFrankie#css
0.7.0
- Breaking change: Handler is now only
on,register,remove,removeAll, andtrigger(no aliases) - Breaking change:
Handler#remove(<name>)now deletes the<name>property from thehandlersobject (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#findandFrankie#attrbugfix- added
Frankie#each
0.6.4
- Logger options
bypassTimestampandbypassLinenow 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.
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago