1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 02:42:48 +00:00

updated package.json

This commit is contained in:
2016-01-04 12:25:28 -05:00
parent 3443c97de4
commit 80ca24a715
1168 changed files with 73752 additions and 26424 deletions

4
node_modules/utile/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,4 @@
node_modules
npm-debug.log
*.swp
*.swo

10
node_modules/utile/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,10 @@
language: node_js
node_js:
- 0.6
- 0.8
notifications:
email:
- travis@nodejitsu.com
irc: "irc.freenode.org#nodejitsu"

16
node_modules/utile/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,16 @@
0.1.5 / 2012-09-18
==================
* Fixed problem with underscore values in camelToUnderscore
0.1.4 / 2012-07-26
==================
* Made use of inflect for camel to underscore conversion
0.1.3 / 2012-07-25
==================
* Added camel to underscore conversion and vice-versa

19
node_modules/utile/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2010 Nodejitsu Inc.
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.

87
node_modules/utile/README.md generated vendored Normal file
View File

@@ -0,0 +1,87 @@
# utile [![Build Status](https://secure.travis-ci.org/flatiron/utile.png)](http://travis-ci.org/flatiron/utile)
A drop-in replacement for `util` with some additional advantageous functions
## Motivation
Javascript is definitely a "batteries not included language" when compared to languages like Ruby or Python. Node.js has a simple utility library which exposes some basic (but important) functionality:
```
$ node
> var util = require('util');
> util.
(...)
util.debug util.error util.exec util.inherits util.inspect
util.log util.p util.print util.pump util.puts
```
When one considers their own utility library, why ever bother requiring `util` again? That is the approach taken by this module. To compare:
```
$ node
> var utile = require('./lib')
> utile.
(...)
utile.async utile.capitalize utile.clone utile.cpr utile.createPath utile.debug
utile.each utile.error utile.exec utile.file utile.filter utile.find
utile.inherits utile.log utile.mixin utile.mkdirp utile.p utile.path
utile.print utile.pump utile.puts utile.randomString utile.requireDir uile.requireDirLazy
utile.rimraf
```
As you can see all of the original methods from `util` are there, but there are several new methods specific to `utile`. A note about implementation: _no node.js native modules are modified by utile, it simply copies those methods._
## Methods
The `utile` modules exposes some simple utility methods:
* `.each(obj, iterator)`: Iterate over the keys of an object.
* `.mixin(target [source0, source1, ...])`: Copies enumerable properties from `source0 ... sourceN` onto `target` and returns the resulting object.
* `.clone(obj)`: Shallow clones the specified object.
* `.capitalize(str)`: Capitalizes the specified `str`.
* `.randomString(length)`: randomString returns a pseudo-random ASCII string (subset) the return value is a string of length ⌈bits/6⌉ of characters from the base64 alphabet.
* `.filter(obj, test)`: return an object with the properties that `test` returns true on.
* `.args(arguments)`: Converts function arguments into actual array with special `callback`, `cb`, `array`, and `last` properties. Also supports *optional* argument contracts. See [the example](https://github.com/flatiron/utile/blob/master/examples/utile-args.js) for more details.
* `.requireDir(directory)`: Requires all files and directories from `directory`, returning an object with keys being filenames (without trailing `.js`) and respective values being return values of `require(filename)`.
* `.requireDirLazy(directory)`: Lazily requires all files and directories from `directory`, returning an object with keys being filenames (without trailing `.js`) and respective values (getters) being return values of `require(filename)`.
* `.format([string] text, [array] formats, [array] replacements)`: Replace `formats` in `text` with `replacements`. This will fall back to the original `util.format` command if it is called improperly.
## Packaged Dependencies
In addition to the methods that are built-in, utile includes a number of commonly used dependencies to reduce the number of includes in your package.json. These modules _are not eagerly loaded to be respectful of startup time,_ but instead are lazy-loaded getters on the `utile` object
* `.async`: [Async utilities for node and the browser][0]
* `.inflect`: [Customizable inflections for node.js][6]
* `.mkdirp`: [Recursively mkdir, like mkdir -p, but in node.js][1]
* `.rimraf`: [A rm -rf util for nodejs][2]
* `.cpr`: [Asynchronous recursive file copying with Node.js][3]
## Installation
### Installing npm (node package manager)
```
curl http://npmjs.org/install.sh | sh
```
### Installing utile
```
[sudo] npm install utile
```
## Tests
All tests are written with [vows][4] and should be run with [npm][5]:
``` bash
$ npm test
```
#### Author: [Nodejitsu Inc.](http://www.nodejitsu.com)
#### Contributors: [Charlie Robbins](http://github.com/indexzero), [Dominic Tarr](http://github.com/dominictarr)
#### License: MIT
[0]: https://github.com/caolan/async
[1]: https://github.com/substack/node-mkdirp
[2]: https://github.com/isaacs/rimraf
[3]: https://github.com/avianflu/ncp
[4]: https://vowsjs.org
[5]: https://npmjs.org
[6]: https://github.com/pksunkara/inflect

46
node_modules/utile/lib/args.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/*
* args.js: function argument parsing helper utility
*
* (C) 2012, Nodejitsu Inc.
* MIT LICENSE
*
*/
var utile = require('./index');
//
// ### function args(_args)
// #### _args {Arguments} Original function arguments
//
// Top-level method will accept a javascript "arguments" object (the actual keyword
// "arguments" inside any scope), and attempt to return back an intelligent object
// representing the functions arguments
//
module.exports = function (_args) {
var args = utile.rargs(_args),
_cb;
//
// Find and define the first argument
//
Object.defineProperty(args, 'first', { value: args[0] });
//
// Find and define any callback
//
_cb = args[args.length - 1] || args[args.length];
if (typeof _cb === "function") {
Object.defineProperty(args, 'callback', { value: _cb });
Object.defineProperty(args, 'cb', { value: _cb });
args.pop();
}
//
// Find and define the last argument
//
if (args.length) {
Object.defineProperty(args, 'last', { value: args[args.length - 1] });
}
return args;
};

44
node_modules/utile/lib/base64.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
/*
* base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers
*
* (C) 2010, Nodejitsu Inc.
*
*/
var base64 = exports;
//
// ### function encode (unencoded)
// #### @unencoded {string} The string to base64 encode
// Encodes the specified string to base64 using node.js Buffers.
//
base64.encode = function (unencoded) {
var encoded;
try {
encoded = new Buffer(unencoded || '').toString('base64');
}
catch (ex) {
return null;
}
return encoded;
};
//
// ### function decode (encoded)
// #### @encoded {string} The string to base64 decode
// Decodes the specified string from base64 using node.js Buffers.
//
base64.decode = function (encoded) {
var decoded;
try {
decoded = new Buffer(encoded || '', 'base64').toString('utf8');
}
catch (ex) {
return null;
}
return decoded;
};

33
node_modules/utile/lib/file.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/*
* file.js: Simple utilities for working with the file system.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var fs = require('fs');
exports.readJson = exports.readJSON = function (file, callback) {
if (typeof callback !== 'function') {
throw new Error('utile.file.readJson needs a callback');
}
fs.readFile(file, 'utf-8', function (err, data) {
if (err) {
return callback(err);
}
try {
var json = JSON.parse(data);
callback(null, json);
}
catch (err) {
return callback(err);
}
});
};
exports.readJsonSync = exports.readJSONSync = function (file) {
return JSON.parse(fs.readFileSync(file, 'utf-8'));
};

25
node_modules/utile/lib/format.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/*
* format.js: `util.format` enhancement to allow custom formatting parameters.
*
* (C) 2012, Nodejitsu Inc.
* MIT LICENSE
*
*/
var util = require('util');
exports = module.exports = function(str) {
var formats = [].slice.call(arguments, 1, 3);
if (!(formats[0] instanceof Array && formats[1] instanceof Array) || arguments.length > 3)
return util.format.apply(null, arguments);
var replacements = formats.pop(),
formats = formats.shift();
formats.forEach(function(format, id) {
str = str.replace(new RegExp(format), replacements[id]);
});
return str;
};

467
node_modules/utile/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,467 @@
/*
* index.js: Top-level include for the `utile` module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var fs = require('fs'),
path = require('path'),
util = require('util');
var utile = module.exports;
//
// Extend the `utile` object with all methods from the
// core node `util` methods.
//
Object.keys(util).forEach(function (key) {
utile[key] = util[key];
});
Object.defineProperties(utile, {
//
// ### function async
// Simple wrapper to `require('async')`.
//
'async': {
get: function() {
return utile.async = require('async');
}
},
//
// ### function inflect
// Simple wrapper to `require('i')`.
//
'inflect': {
get: function() {
return utile.inflect = require('i')();
}
},
//
// ### function mkdirp
// Simple wrapper to `require('mkdirp')`
//
'mkdirp': {
get: function() {
return utile.mkdirp = require('mkdirp');
}
},
//
// ### function deepEqual
// Simple wrapper to `require('deep-equal')`
// Remark: deepEqual is 4x faster then using assert.deepEqual
// see: https://gist.github.com/2790507
//
'deepEqual': {
get: function() {
return utile.deepEqual = require('deep-equal');
}
},
//
// ### function rimraf
// Simple wrapper to `require('rimraf')`
//
'rimraf': {
get: function() {
return utile.rimraf = require('rimraf');
}
},
//
// ### function cpr
// Simple wrapper to `require('ncp').ncp`
//
'cpr': {
get: function() {
return utile.cpr = require('ncp').ncp;
}
},
//
// ### @file {Object}
// Lazy-loaded `file` module
//
'file': {
get: function() {
return utile.file = require('./file');
}
},
//
// ### @args {Object}
// Lazy-loaded `args` module
//
'args': {
get: function() {
return utile.args = require('./args');
}
},
//
// ### @base64 {Object}
// Lazy-loaded `base64` object
//
'base64': {
get: function() {
return utile.base64 = require('./base64');
}
},
//
// ### @format {Object}
// Lazy-loaded `format` object
//
'format': {
get: function() {
return utile.format = require('./format');
}
}
});
//
// ### function rargs(_args)
// #### _args {Arguments} Original function arguments
//
// Top-level method will accept a javascript "arguments" object
// (the actual keyword "arguments" inside any scope) and return
// back an Array.
//
utile.rargs = function (_args, slice) {
if (!slice) {
slice = 0;
}
var len = (_args || []).length,
args = new Array(len - slice),
i;
//
// Convert the raw `_args` to a proper Array.
//
for (i = slice; i < len; i++) {
args[i - slice] = _args[i];
}
return args;
};
//
// ### function each (obj, iterator)
// #### @obj {Object} Object to iterate over
// #### @iterator {function} Continuation to use on each key. `function (value, key, object)`
// Iterate over the keys of an object.
//
utile.each = function (obj, iterator) {
Object.keys(obj).forEach(function (key) {
iterator(obj[key], key, obj);
});
};
//
// ### function find (o)
//
//
utile.find = function (obj, pred) {
var value, key;
for (key in obj) {
value = obj[key];
if (pred(value, key)) {
return value;
}
}
};
//
// ### function pad (str, len, chr)
// ### @str {String} String to pad
// ### @len {Number} Number of chars to pad str with
// ### @chr {String} Optional replacement character, defaults to empty space
// Appends chr to str until it reaches a length of len
//
utile.pad = function pad(str, len, chr) {
var s;
if (!chr) {
chr = ' ';
}
str = str || '';
s = str;
if (str.length < len) {
for (var i = 0; i < (len - str.length); i++) {
s += chr;
}
}
return s;
}
//
// ### function path (obj, path, value)
// ### @obj {Object} Object to insert value into
// ### @path {Array} List of nested keys to insert value at
// Retreives a value from given Object, `obj`, located at the
// nested keys, `path`.
//
utile.path = function (obj, path) {
var key, i;
for (i in path) {
if (typeof obj === 'undefined') {
return undefined;
}
key = path[i];
obj = obj[key];
}
return obj;
};
//
// ### function createPath (obj, path, value)
// ### @obj {Object} Object to insert value into
// ### @path {Array} List of nested keys to insert value at
// ### @value {*} Value to insert into the object.
// Inserts the `value` into the given Object, `obj`, creating
// any keys in `path` along the way if necessary.
//
utile.createPath = function (obj, path, value) {
var key, i;
for (i in path) {
key = path[i];
if (!obj[key]) {
obj[key] = ((+i + 1 === path.length) ? value : {});
}
obj = obj[key];
}
};
//
// ### function mixin (target [source0, source1, ...])
// Copies enumerable properties from `source0 ... sourceN`
// onto `target` and returns the resulting object.
//
utile.mixin = function (target) {
utile.rargs(arguments, 1).forEach(function (o) {
Object.getOwnPropertyNames(o).forEach(function(attr) {
var getter = Object.getOwnPropertyDescriptor(o, attr).get,
setter = Object.getOwnPropertyDescriptor(o, attr).set;
if (!getter && !setter) {
target[attr] = o[attr];
}
else {
Object.defineProperty(target, attr, {
get: getter,
set: setter
});
}
});
});
return target;
};
//
// ### function capitalize (str)
// #### @str {string} String to capitalize
// Capitalizes the specified `str`.
//
utile.capitalize = utile.inflect.camelize;
//
// ### function escapeRegExp (str)
// #### @str {string} String to be escaped
// Escape string for use in Javascript regex
//
utile.escapeRegExp = function (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
//
// ### function randomString (length)
// #### @length {integer} The number of bits for the random base64 string returned to contain
// randomString returns a pseude-random ASCII string (subset)
// the return value is a string of length ⌈bits/6⌉ of characters
// from the base64 alphabet.
//
utile.randomString = function (length) {
var chars, rand, i, ret, mod, bits;
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
ret = '';
// standard 4
mod = 4;
// default is 16
bits = length * mod || 64;
// in v8, Math.random() yields 32 pseudo-random bits (in spidermonkey it gives 53)
while (bits > 0) {
// 32-bit integer
rand = Math.floor(Math.random() * 0x100000000);
//we use the top bits
for (i = 26; i > 0 && bits > 0; i -= mod, bits -= mod) {
ret += chars[0x3F & rand >>> i];
}
}
return ret;
};
//
// ### function filter (object, test)
// #### @obj {Object} Object to iterate over
// #### @pred {function} Predicate applied to each property. `function (value, key, object)`
// Returns an object with properties from `obj` which satisfy
// the predicate `pred`
//
utile.filter = function (obj, pred) {
var copy;
if (Array.isArray(obj)) {
copy = [];
utile.each(obj, function (val, key) {
if (pred(val, key, obj)) {
copy.push(val);
}
});
}
else {
copy = {};
utile.each(obj, function (val, key) {
if (pred(val, key, obj)) {
copy[key] = val;
}
});
}
return copy;
};
//
// ### function requireDir (directory)
// #### @directory {string} Directory to require
// Requires all files and directories from `directory`, returning an object
// with keys being filenames (without trailing `.js`) and respective values
// being return values of `require(filename)`.
//
utile.requireDir = function (directory) {
var result = {},
files = fs.readdirSync(directory);
files.forEach(function (file) {
if (file.substr(-3) === '.js') {
file = file.substr(0, file.length - 3);
}
result[file] = require(path.resolve(directory, file));
});
return result;
};
//
// ### function requireDirLazy (directory)
// #### @directory {string} Directory to require
// Lazily requires all files and directories from `directory`, returning an
// object with keys being filenames (without trailing `.js`) and respective
// values (getters) being return values of `require(filename)`.
//
utile.requireDirLazy = function (directory) {
var result = {},
files = fs.readdirSync(directory);
files.forEach(function (file) {
if (file.substr(-3) === '.js') {
file = file.substr(0, file.length - 3);
}
Object.defineProperty(result, file, {
get: function() {
return result[file] = require(path.resolve(directory, file));
}
});
});
return result;
};
//
// ### function clone (object, filter)
// #### @object {Object} Object to clone
// #### @filter {Function} Filter to be used
// Shallow clones the specified object.
//
utile.clone = function (object, filter) {
return Object.keys(object).reduce(filter ? function (obj, k) {
if (filter(k)) obj[k] = object[k];
return obj;
} : function (obj, k) {
obj[k] = object[k];
return obj;
}, {});
};
//
// ### function camelToUnderscore (obj)
// #### @obj {Object} Object to convert keys on.
// Converts all keys of the type `keyName` to `key_name` on the
// specified `obj`.
//
utile.camelToUnderscore = function (obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
if (Array.isArray(obj)) {
obj.forEach(utile.camelToUnderscore);
return obj;
}
Object.keys(obj).forEach(function (key) {
var k = utile.inflect.underscore(key);
if (k !== key) {
obj[k] = obj[key];
delete obj[key];
key = k;
}
utile.camelToUnderscore(obj[key]);
});
return obj;
};
//
// ### function underscoreToCamel (obj)
// #### @obj {Object} Object to convert keys on.
// Converts all keys of the type `key_name` to `keyName` on the
// specified `obj`.
//
utile.underscoreToCamel = function (obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
if (Array.isArray(obj)) {
obj.forEach(utile.underscoreToCamel);
return obj;
}
Object.keys(obj).forEach(function (key) {
var k = utile.inflect.camelize(key, false);
if (k !== key) {
obj[k] = obj[key];
delete obj[key];
key = k;
}
utile.underscoreToCamel(obj[key]);
});
return obj;
};

90
node_modules/utile/package.json generated vendored Normal file
View File

@@ -0,0 +1,90 @@
{
"_args": [
[
"utile@~0.2.1",
"/home/mywebsite/node_modules/forever-monitor"
]
],
"_from": "utile@>=0.2.1 <0.3.0",
"_id": "utile@0.2.1",
"_inCache": true,
"_installable": true,
"_location": "/utile",
"_npmUser": {
"email": "jcrugzz@gmail.com",
"name": "jcrugzz"
},
"_npmVersion": "1.3.8",
"_phantomChildren": {},
"_requested": {
"name": "utile",
"raw": "utile@~0.2.1",
"rawSpec": "~0.2.1",
"scope": null,
"spec": ">=0.2.1 <0.3.0",
"type": "range"
},
"_requiredBy": [
"/broadway",
"/forever-monitor"
],
"_resolved": "https://registry.npmjs.org/utile/-/utile-0.2.1.tgz",
"_shasum": "930c88e99098d6220834c356cbd9a770522d90d7",
"_shrinkwrap": null,
"_spec": "utile@~0.2.1",
"_where": "/home/mywebsite/node_modules/forever-monitor",
"author": {
"email": "info@nodejitsu.com",
"name": "Nodejitsu Inc."
},
"bugs": {
"url": "https://github.com/flatiron/utile/issues"
},
"dependencies": {
"async": "~0.2.9",
"deep-equal": "*",
"i": "0.3.x",
"mkdirp": "0.x.x",
"ncp": "0.4.x",
"rimraf": "2.x.x"
},
"description": "A drop-in replacement for `util` with some additional advantageous functions",
"devDependencies": {
"vows": "0.7.x"
},
"directories": {},
"dist": {
"shasum": "930c88e99098d6220834c356cbd9a770522d90d7",
"tarball": "http://registry.npmjs.org/utile/-/utile-0.2.1.tgz"
},
"engines": {
"node": ">= 0.6.4"
},
"homepage": "https://github.com/flatiron/utile#readme",
"main": "./lib/index",
"maintainers": [
{
"name": "indexzero",
"email": "charlie.robbins@gmail.com"
},
{
"name": "mmalecki",
"email": "me@mmalecki.com"
},
{
"name": "jcrugzz",
"email": "jcrugzz@gmail.com"
}
],
"name": "utile",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/flatiron/utile.git"
},
"scripts": {
"test": "vows --spec"
},
"version": "0.2.1"
}

31
node_modules/utile/test/file-test.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/*
* file-test.js: Tests for `utile.file` module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
path = require('path'),
vows = require('vows'),
macros = require('./helpers/macros'),
utile = require('../');
var fixture = path.join(__dirname, 'fixtures', 'read-json-file', 'config.json');
vows.describe('utile/file').addBatch({
'When using utile': {
'the `.file.readJson()` function': {
topic: function () {
utile.file.readJson(fixture, this.callback);
},
'should return correct JSON structure': macros.assertReadCorrectJson
},
'the `.file.readJsonSync()` function': {
topic: utile.file.readJsonSync(fixture),
'should return correct JSON structure': macros.assertReadCorrectJson
}
}
}).export(module);

View File

@@ -0,0 +1,9 @@
{
"hello": "World",
"I am": ["the utile module"],
"thisMakesMe": {
"really": 1337,
"right?": true
}
}

View File

@@ -0,0 +1,2 @@
exports.me = 'directory/index.js';

View File

@@ -0,0 +1,2 @@
exports.me = 'helloWorld.js';

31
node_modules/utile/test/format-test.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/*
* format-test.js: Tests for `utile.format` module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var vows = require('vows'),
assert = require('assert'),
utile = require('../lib');
vows.describe('utile/format').addBatch({
'Should use the original `util.format` if there are no custom parameters to replace.': function() {
assert.equal(utile.format('%s %s %s', 'test', 'test2', 'test3'), 'test test2 test3');
},
'Should use `utile.format` if custom parameters are provided.': function() {
assert.equal(utile.format('%a %b %c', [
'%a',
'%b',
'%c'
], [
'test',
'test2',
'test3'
]), 'test test2 test3');
}
}).export(module);

104
node_modules/utile/test/function-args-test.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
/*
* function-args-test.js: Tests for `args` method
*
* (C) 2012, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
path = require('path'),
vows = require('vows'),
macros = require('./helpers/macros'),
utile = require('../');
vows.describe('utile/args').addBatch({
'When using utile': {
'the `args` function': {
topic: utile,
'should be a function': function (_utile) {
assert.isFunction(_utile.args);
},
}
},
'utile.rargs()': {
'with no arguments': {
topic: utile.rargs(),
'should return an empty object': function (result) {
assert.isArray(result);
assert.lengthOf(result, 0);
}
},
'with simple arguments': {
topic: function () {
return (function () {
return utile.rargs(arguments);
})('a', 'b', 'c');
},
'should return an array with three items': function (result) {
assert.isArray(result);
assert.equal(3, result.length);
assert.equal(result[0], 'a');
assert.equal(result[1], 'b');
assert.equal(result[2], 'c');
}
},
'with a simple slice': {
topic: function () {
return (function () {
return utile.rargs(arguments, 1);
})('a', 'b', 'c');
},
'should return an array with three items': function (result) {
assert.isArray(result);
assert.equal(2, result.length);
assert.equal(result[0], 'b');
assert.equal(result[1], 'c');
}
}
},
'utile.args()': {
'with no arguments': {
topic: utile.args(),
'should return an empty Array': function (result) {
assert.isUndefined(result.callback);
assert.isArray(result);
assert.lengthOf(result, 0);
}
},
'with simple arguments': {
topic: function () {
return (function () {
return utile.args(arguments);
})('a', 'b', 'c', function () {
return 'ok';
});
},
'should return an array with three items': function (result) {
assert.isArray(result);
assert.equal(3, result.length);
assert.equal(result[0], 'a');
assert.equal(result[1], 'b');
assert.equal(result[2], 'c');
//
// Ensure that the Array returned
// by `utile.args()` enumerates correctly
//
var length = 0;
result.forEach(function (item) {
length++;
});
assert.equal(length, 3);
},
'should return lookup helpers': function (result) {
assert.isArray(result);
assert.equal(result.first, 'a');
assert.equal(result.last, 'c');
assert.isFunction(result.callback);
assert.isFunction(result.cb);
}
}
}
}).export(module);

37
node_modules/utile/test/helpers/macros.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
/*
* macros.js: Test macros for `utile` module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
utile = require('../../lib');
var macros = exports;
macros.assertReadCorrectJson = function (obj) {
assert.isObject(obj);
utile.deepEqual(obj, {
hello: 'World',
'I am': ['the utile module'],
thisMakesMe: {
really: 1337,
'right?': true
}
});
};
macros.assertDirectoryRequired = function (obj) {
assert.isObject(obj);
utile.deepEqual(obj, {
directory: {
me: 'directory/index.js'
},
helloWorld: {
me: 'helloWorld.js'
}
});
};

39
node_modules/utile/test/random-string-test.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/*
* common-test.js : testing common.js for expected functionality
*
* (C) 2011, Nodejitsu Inc.
*
*/
var assert = require('assert'),
vows = require('vows'),
utile = require('../lib');
vows.describe('utile/randomString').addBatch({
"When using utile": {
"the randomString() function": {
topic: function () {
return utile.randomString();
},
"should return 16 characters that are actually random by default": function (random) {
assert.isString(random);
assert.lengthOf(random, 16);
assert.notEqual(random, utile.randomString());
},
"when you can asked for different length strings": {
topic: function () {
return [utile.randomString(4), utile.randomString(128)];
},
"where they actually are of length 4, 128": function (strings) {
assert.isArray(strings);
assert.lengthOf(strings,2);
assert.isString(strings[0]);
assert.isString(strings[1]);
assert.lengthOf(strings[0], 4);
assert.lengthOf(strings[1], 128);
assert.notEqual(strings[0], strings[1].substr(0,4));
}
}
}
}
}).export(module);

35
node_modules/utile/test/require-directory-test.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
/*
* require-directory-test.js: Tests for `requireDir` and `requireDirLazy`
* methods.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
path = require('path'),
vows = require('vows'),
macros = require('./helpers/macros'),
utile = require('../');
var requireFixtures = path.join(__dirname, 'fixtures', 'require-directory');
vows.describe('utile/require-directory').addBatch({
'When using utile': {
'the `requireDir()` function': {
topic: utile.requireDir(requireFixtures),
'should contain all wanted modules': macros.assertDirectoryRequired
},
'the `requireDirLazy()` function': {
topic: utile.requireDirLazy(requireFixtures),
'all properties should be getters': function (obj) {
assert.isObject(obj);
assert.isTrue(!!Object.getOwnPropertyDescriptor(obj, 'directory').get);
assert.isTrue(!!Object.getOwnPropertyDescriptor(obj, 'helloWorld').get);
},
'should contain all wanted modules': macros.assertDirectoryRequired
}
}
}).export(module);

126
node_modules/utile/test/utile-test.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
/*
* utile-test.js: Tests for `utile` module.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
var assert = require('assert'),
vows = require('vows'),
utile = require('../lib');
var obj1, obj2;
obj1 = {
foo: true,
bar: {
bar1: true,
bar2: 'bar2'
}
};
obj2 = {
baz: true,
buzz: 'buzz'
};
Object.defineProperties(obj2, {
'bazz': {
get: function() {
return 'bazz';
},
set: function() {
return 'bazz';
}
},
'wat': {
set: function() {
return 'wat';
}
}
});
vows.describe('utile').addBatch({
"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 () {
assert.isFunction(utile.mixin);
assert.isFunction(utile.clone);
assert.isFunction(utile.rimraf);
assert.isFunction(utile.mkdirp);
assert.isFunction(utile.cpr);
},
"the mixin() method": function () {
var mixed = utile.mixin({}, obj1, obj2);
assert.isTrue(mixed.foo);
assert.isObject(mixed.bar);
assert.isTrue(mixed.baz);
assert.isString(mixed.buzz);
assert.isTrue(!!Object.getOwnPropertyDescriptor(mixed, 'bazz').get);
assert.isTrue(!!Object.getOwnPropertyDescriptor(mixed, 'bazz').set);
assert.isTrue(!!Object.getOwnPropertyDescriptor(mixed, 'wat').set);
assert.isString(mixed.bazz);
},
"the clone() method": function () {
var clone = utile.clone(obj1);
assert.isTrue(clone.foo);
assert.isObject(clone.bar);
assert.notStrictEqual(obj1, clone);
},
"the createPath() method": function () {
var x = {},
r = Math.random();
utile.createPath(x, ['a','b','c'], r)
assert.equal(x.a.b.c, r)
},
"the capitalize() method": function () {
assert.isFunction(utile.capitalize);
assert.equal(utile.capitalize('bullet'), 'Bullet');
assert.equal(utile.capitalize('bullet_train'), 'BulletTrain');
},
"the escapeRegExp() method": function () {
var ans = "\\/path\\/to\\/resource\\.html\\?search=query";
assert.isFunction(utile.escapeRegExp);
assert.equal(utile.escapeRegExp('/path/to/resource.html?search=query'), ans);
},
"the underscoreToCamel() method": function () {
var obj = utile.underscoreToCamel({
key_with_underscore: {
andNested: 'values',
several: [1, 2, 3],
nested_underscores: true
},
just_one: 'underscore'
});
assert.isObject(obj.keyWithUnderscore);
assert.isString(obj.justOne);
assert.isTrue(obj.keyWithUnderscore.nestedUnderscores);
},
"the camelToUnderscore() method": function () {
var obj = utile.camelToUnderscore({
keyWithCamel: {
andNested: 'values',
several: [1, 2, 3],
nestedCamel: true
},
justOne: 'camel'
});
assert.isObject(obj.key_with_camel);
assert.isString(obj.just_one);
assert.isTrue(obj.key_with_camel.nested_camel);
}
}
}).export(module);