utile
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -8,5 +8,5 @@ /* | ||
*/ | ||
var common = exports; | ||
var utile = exports; | ||
// | ||
@@ -16,3 +16,3 @@ // @async {Object} | ||
// | ||
common.__defineGetter__('async', function () { | ||
utile.__defineGetter__('async', function () { | ||
return require('async'); | ||
@@ -25,3 +25,3 @@ }); | ||
// | ||
common.__defineGetter__('mkdirp', function () { | ||
utile.__defineGetter__('mkdirp', function () { | ||
return require('mkdirp'); | ||
@@ -34,3 +34,3 @@ }); | ||
// | ||
common.__defineGetter__('rimraf', function () { | ||
utile.__defineGetter__('rimraf', function () { | ||
return require('rimraf'); | ||
@@ -43,3 +43,3 @@ }); | ||
// | ||
common.__defineGetter__('cpr', function () { | ||
utile.__defineGetter__('cpr', function () { | ||
return require('ncp').ncp; | ||
@@ -52,3 +52,3 @@ }); | ||
// | ||
common.__defineGetter__('read', function () { | ||
utile.__defineGetter__('read', function () { | ||
return require('./read'); | ||
@@ -74,7 +74,7 @@ }); | ||
// | ||
common.mixin = function (target) { | ||
utile.mixin = function (target) { | ||
var objs = Array.prototype.slice.call(arguments, 1); | ||
objs.forEach(function (o) { | ||
Object.keys(o).forEach(function (attr) { | ||
if (! o.__lookupGetter__(attr)) { | ||
if (!o.__lookupGetter__(attr)) { | ||
target[attr] = o[attr]; | ||
@@ -92,3 +92,3 @@ } | ||
// | ||
common.clone = function (object) { | ||
utile.clone = function (object) { | ||
return Object.keys(object).reduce(function (obj, k) { | ||
@@ -100,3 +100,2 @@ obj[k] = object[k]; | ||
// | ||
@@ -107,3 +106,3 @@ // ### function capitalize (str) | ||
// | ||
common.capitalize = function (str) { | ||
utile.capitalize = function (str) { | ||
return str && str[0].toUpperCase() + str.slice(1); | ||
@@ -119,3 +118,3 @@ }; | ||
// | ||
common.randomString = function (length) { | ||
utile.randomString = function (length) { | ||
var chars, rand, i, ret, mod; | ||
@@ -141,2 +140,8 @@ | ||
return ret; | ||
}; | ||
}; | ||
// | ||
// Extend the `utile` object with all methods from the | ||
// core node `util` methods | ||
// | ||
utile.mixin(utile, require('util')); |
{ | ||
"name": "utile", | ||
"description": "Advantageous functions for programming in javascript and node.js", | ||
"version": "0.0.2", | ||
"description": "A drop-in replacement for `util` with some additional advantageous functions", | ||
"version": "0.0.3", | ||
"author": "Nodejitsu Inc <info@nodejitsu.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -30,2 +30,7 @@ /* | ||
"When using utile": { | ||
"it should have the same methods as the `util` module": function () { | ||
Object.keys(require('util')).forEach(function (fn) { | ||
assert.isFunction(utile[fn]); | ||
}); | ||
}, | ||
"it should have the correct methods defined": function () { | ||
@@ -32,0 +37,0 @@ assert.isFunction(utile.mixin); |
6771
231