__ __ __ __ ______
/\ \ __/\ \ /\ \ /\ \ /\__ _\
\ \ \/\ \ \ \ __ __ _____ ___ ___ \ `\`\/'/'\/_/\ \/
\ \ \ \ \ \ \ /'__`\ /'__`\ /\ '__`\ / __`\ /' _ `\`\/ > < \ \ \
\ \ \_/ \_\ \/\ __//\ \L\.\_\ \ \L\ \/\ \L\ \/\ \/\ \ \/'/\`\ \_\ \__
\ `\___x___/\ \____\ \__/.\_\\ \ ,__/\ \____/\ \_\ \_\ /\_\\ \_\ /\_____\
'\/__//__/ \/____/\/__/\/_/ \ \ \/ \/___/ \/_/\/_/ \/_/ \/_/ \/_____/
\ \_\
\/_/
__ ___
/\ \__ __ /\_ \ __
__ __\ \ ,_\/\_\\//\ \ __ _/\_\
/\ \/\ \\ \ \/\/\ \ \ \ \ /\ \/'\/\ \
\ \ \_\ \\ \ \_\ \ \ \_\ \_\/> </\ \ \
\ \____/ \ \__\\ \_\/\____\/\_/\_\\ \_\
\/___/ \/__/ \/_/\/____/\//\/_/ \/_/
UtilXI
UtilXI, a utility library extends underscore.
Jump to Section
Getting Started
To install from npm:
UtilXI works with Node >= 0.8
npm install utilxi --save
To download from github:
git clone git://github.com/aponxi/npm-utilxi.git
To Install dependencies go to directory you cloned the repository to and :
npm install
Running Tests:
npm test
or
grunt test
Usage
On node projects:
After installing from npm just require utilxi via:
var _ =
On web:
After downloading the code, you only need lib/utilxi.js
file to be on your website dir. Just add the script on your html file:
then do:
Documentation
About Functions
There are two types of functions, ones that are available for client-side [web] and server-side [node]. The ones for client-side are also available for server-side.
Underscore Functions and these:
capitalize
String capitalize ( String word) [web]
Capitalizes the first letter of string. Takes word
argument as String
and returns capitalized String
.
Usage:
console; // Fabio
contrastingColor
String contrastingColor ( String or Array color) [web]
This was also taken from somewhere on web... Gosh I wish I've saved the urls for reference... This function tells if you should use black or white on the background color. Takes the color
argument as String
or Array
and color can be a hex String
or an Array
of RGB values 0-255 such as [255, 255, 255]
. Returns "000"
or "fff"
for black or white.
Usage
# can either use "fff" or "ffffff" background = "ffffff" # white background should get black result = _contrastingColor"ffffff" # result is "000" consolelog result # "000"
hexToRGBArray
Array hexToRGBArray (String color) [web]
Taken from somewhere on web I can't recall, this function converts hex color to RGB color Array. The argument should be a 3 digit or 6 digit hex color as String
. Returns an Array
with Red Green Blue values as integer
.
Usage:
hex = "f5664c" result = _hexToRGBArray hex consoledir result # [245,102, 76]
merge
Object merge( Object left, Object right) [web]
Taken from deepmerge package by nrf110, a function that deeply merges objects. Function returns the merged Object
. Takes two arguments, left Object
and right Object
. Right side overwrites left side.
// Usagevar x = foo: bar: 3 array: does: 'work' too: 1 2 3 really: 'yes' var y = foo: baz: 4 quux: 5 array: does: 'work' too: 34 5 6 really: 'ysee' _// would result "foo": "bar": 3 "baz": 4 "array": "does": "work" "too": 1 2 3 3 4 5 6 "really": "ysee" "quux": 5
root
String root() [node]
Gives the root directory of the node project, absolutely. Takes no arguments and returns the directory as String
.
Usage:
console;// /home/logan/projects/npm-utilxi
urlGetStatusCode
void urlGetStatusCode ( String url, function callback( int responseCode)) [node]
Makes a request to the web address and calls the callback function with the http response code.
Usage:
_urlGetStatusCode "http://www.google.com/index.html" consolelog code #200 _urlGetStatusCode "http://www.google.com/indexaaaa.html" consolelog code #404
urlGetStatusCodeReadable
void urlGetStatusCodeReadable ( String url, function callback( String responseString)) [node]
Makes a request to the web address and calls the callback function with the http response code.
Usage:
_urlGetStatusCodeReadable "http://www.google.com/index.html" consolelog code #OK _urlGetStatusCodeReadable "http://www.google.com/indexaaaa.html" consolelog code #Not Found
Release History
You can find all the changelogs here.
Latest changelog is from v1.4.0.md:
02/July/2013 v1.4
- Added url functions
- can get response code of the url in readable format or integer like 404 for Not Found
- Added documentation
- Removed browserify and other packages to make it node-only plug-in
License
Copyright © 2013 aponxi info@weaponxi.com
This software is licensed under MIT License.
This readme has been automatically generated by readme generator on Tue Jul 02 2013 08:33:20 GMT-0400 (EDT).