summaryrefslogtreecommitdiff
path: root/node_modules/eyes
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/eyes')
-rw-r--r--node_modules/eyes/LICENSE20
-rw-r--r--node_modules/eyes/Makefile4
-rw-r--r--node_modules/eyes/README.md73
-rw-r--r--node_modules/eyes/lib/eyes.js236
-rw-r--r--node_modules/eyes/package.json61
-rw-r--r--node_modules/eyes/test/eyes-test.js56
6 files changed, 450 insertions, 0 deletions
diff --git a/node_modules/eyes/LICENSE b/node_modules/eyes/LICENSE
new file mode 100644
index 0000000..a1edd93
--- /dev/null
+++ b/node_modules/eyes/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 cloudhead
+
+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.
diff --git a/node_modules/eyes/Makefile b/node_modules/eyes/Makefile
new file mode 100644
index 0000000..a121dea
--- /dev/null
+++ b/node_modules/eyes/Makefile
@@ -0,0 +1,4 @@
+test:
+ @@node test/eyes-test.js
+
+.PHONY: test
diff --git a/node_modules/eyes/README.md b/node_modules/eyes/README.md
new file mode 100644
index 0000000..c4f6f76
--- /dev/null
+++ b/node_modules/eyes/README.md
@@ -0,0 +1,73 @@
+eyes
+====
+
+a customizable value inspector for Node.js
+
+synopsis
+--------
+
+I was tired of looking at cluttered output in the console -- something needed to be done,
+`sys.inspect()` didn't display regexps correctly, and was too verbose, and I had an hour or two to spare.
+So I decided to have some fun. _eyes_ were born.
+
+![eyes-ss](http://dl.dropbox.com/u/251849/eyes-js-ss.gif)
+
+_example of the output of a user-customized eyes.js inspector_
+
+*eyes* also deals with circular objects in an intelligent way, and can pretty-print object literals.
+
+usage
+-----
+
+ var inspect = require('eyes').inspector({styles: {all: 'magenta'}});
+
+ inspect(something); // inspect with the settings passed to `inspector`
+
+or
+
+ var eyes = require('eyes');
+
+ eyes.inspect(something); // inspect with the default settings
+
+you can pass a _label_ to `inspect()`, to keep track of your inspections:
+
+ eyes.inspect(something, "a random value");
+
+If you want to return the output of eyes without printing it, you can set it up this way:
+
+ var inspect = require('eyes').inspector({ stream: null });
+
+ sys.puts(inspect({ something: 42 }));
+
+customization
+-------------
+
+These are the default styles and settings used by _eyes_.
+
+ styles: { // Styles applied to stdout
+ all: 'cyan', // Overall style applied to everything
+ label: 'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
+ other: 'inverted', // Objects which don't have a literal representation, such as functions
+ key: 'bold', // The keys in object literals, like 'a' in `{a: 1}`
+ special: 'grey', // null, undefined...
+ string: 'green',
+ number: 'magenta',
+ bool: 'blue', // true false
+ regexp: 'green', // /\d+/
+ },
+
+ pretty: true, // Indent object literals
+ hideFunctions: false, // Don't output functions at all
+ stream: process.stdout, // Stream to write to, or null
+ maxLength: 2048 // Truncate output if longer
+
+You can overwrite them with your own, by passing a similar object to `inspector()` or `inspect()`.
+
+ var inspect = require('eyes').inspector({
+ styles: {
+ all: 'magenta',
+ special: 'bold'
+ },
+ maxLength: 512
+ });
+
diff --git a/node_modules/eyes/lib/eyes.js b/node_modules/eyes/lib/eyes.js
new file mode 100644
index 0000000..10d964b
--- /dev/null
+++ b/node_modules/eyes/lib/eyes.js
@@ -0,0 +1,236 @@
+//
+// Eyes.js - a customizable value inspector for Node.js
+//
+// usage:
+//
+// var inspect = require('eyes').inspector({styles: {all: 'magenta'}});
+// inspect(something); // inspect with the settings passed to `inspector`
+//
+// or
+//
+// var eyes = require('eyes');
+// eyes.inspect(something); // inspect with the default settings
+//
+var eyes = exports,
+ stack = [];
+
+eyes.defaults = {
+ styles: { // Styles applied to stdout
+ all: 'cyan', // Overall style applied to everything
+ label: 'underline', // Inspection labels, like 'array' in `array: [1, 2, 3]`
+ other: 'inverted', // Objects which don't have a literal representation, such as functions
+ key: 'bold', // The keys in object literals, like 'a' in `{a: 1}`
+ special: 'grey', // null, undefined...
+ string: 'green',
+ number: 'magenta',
+ bool: 'blue', // true false
+ regexp: 'green', // /\d+/
+ },
+ pretty: true, // Indent object literals
+ hideFunctions: false,
+ showHidden: false,
+ stream: process.stdout,
+ maxLength: 2048 // Truncate output if longer
+};
+
+// Return a curried inspect() function, with the `options` argument filled in.
+eyes.inspector = function (options) {
+ var that = this;
+ return function (obj, label, opts) {
+ return that.inspect.call(that, obj, label,
+ merge(options || {}, opts || {}));
+ };
+};
+
+// If we have a `stream` defined, use it to print a styled string,
+// if not, we just return the stringified object.
+eyes.inspect = function (obj, label, options) {
+ options = merge(this.defaults, options || {});
+
+ if (options.stream) {
+ return this.print(stringify(obj, options), label, options);
+ } else {
+ return stringify(obj, options) + (options.styles ? '\033[39m' : '');
+ }
+};
+
+// Output using the 'stream', and an optional label
+// Loop through `str`, and truncate it after `options.maxLength` has been reached.
+// Because escape sequences are, at this point embeded within
+// the output string, we can't measure the length of the string
+// in a useful way, without separating what is an escape sequence,
+// versus a printable character (`c`). So we resort to counting the
+// length manually.
+eyes.print = function (str, label, options) {
+ for (var c = 0, i = 0; i < str.length; i++) {
+ if (str.charAt(i) === '\033') { i += 4 } // `4` because '\033[25m'.length + 1 == 5
+ else if (c === options.maxLength) {
+ str = str.slice(0, i - 1) + '…';
+ break;
+ } else { c++ }
+ }
+ return options.stream.write.call(options.stream, (label ?
+ this.stylize(label, options.styles.label, options.styles) + ': ' : '') +
+ this.stylize(str, options.styles.all, options.styles) + '\033[0m' + "\n");
+};
+
+// Apply a style to a string, eventually,
+// I'd like this to support passing multiple
+// styles.
+eyes.stylize = function (str, style, styles) {
+ var codes = {
+ 'bold' : [1, 22],
+ 'underline' : [4, 24],
+ 'inverse' : [7, 27],
+ 'cyan' : [36, 39],
+ 'magenta' : [35, 39],
+ 'blue' : [34, 39],
+ 'yellow' : [33, 39],
+ 'green' : [32, 39],
+ 'red' : [31, 39],
+ 'grey' : [90, 39]
+ }, endCode;
+
+ if (style && codes[style]) {
+ endCode = (codes[style][1] === 39 && styles.all) ? codes[styles.all][0]
+ : codes[style][1];
+ return '\033[' + codes[style][0] + 'm' + str +
+ '\033[' + endCode + 'm';
+ } else { return str }
+};
+
+// Convert any object to a string, ready for output.
+// When an 'array' or an 'object' are encountered, they are
+// passed to specialized functions, which can then recursively call
+// stringify().
+function stringify(obj, options) {
+ var that = this, stylize = function (str, style) {
+ return eyes.stylize(str, options.styles[style], options.styles)
+ }, index, result;
+
+ if ((index = stack.indexOf(obj)) !== -1) {
+ return stylize(new(Array)(stack.length - index + 1).join('.'), 'special');
+ }
+ stack.push(obj);
+
+ result = (function (obj) {
+ switch (typeOf(obj)) {
+ case "string" : obj = stringifyString(obj.indexOf("'") === -1 ? "'" + obj + "'"
+ : '"' + obj + '"');
+ return stylize(obj, 'string');
+ case "regexp" : return stylize('/' + obj.source + '/', 'regexp');
+ case "number" : return stylize(obj + '', 'number');
+ case "function" : return options.stream ? stylize("Function", 'other') : '[Function]';
+ case "null" : return stylize("null", 'special');
+ case "undefined": return stylize("undefined", 'special');
+ case "boolean" : return stylize(obj + '', 'bool');
+ case "date" : return stylize(obj.toUTCString());
+ case "array" : return stringifyArray(obj, options, stack.length);
+ case "object" : return stringifyObject(obj, options, stack.length);
+ }
+ })(obj);
+
+ stack.pop();
+ return result;
+};
+
+// Escape invisible characters in a string
+function stringifyString (str, options) {
+ return str.replace(/\\/g, '\\\\')
+ .replace(/\n/g, '\\n')
+ .replace(/[\u0001-\u001F]/g, function (match) {
+ return '\\0' + match[0].charCodeAt(0).toString(8);
+ });
+}
+
+// Convert an array to a string, such as [1, 2, 3].
+// This function calls stringify() for each of the elements
+// in the array.
+function stringifyArray(ary, options, level) {
+ var out = [];
+ var pretty = options.pretty && (ary.length > 4 || ary.some(function (o) {
+ return (o !== null && typeof(o) === 'object' && Object.keys(o).length > 0) ||
+ (Array.isArray(o) && o.length > 0);
+ }));
+ var ws = pretty ? '\n' + new(Array)(level * 4 + 1).join(' ') : ' ';
+
+ for (var i = 0; i < ary.length; i++) {
+ out.push(stringify(ary[i], options));
+ }
+
+ if (out.length === 0) {
+ return '[]';
+ } else {
+ return '[' + ws
+ + out.join(',' + (pretty ? ws : ' '))
+ + (pretty ? ws.slice(0, -4) : ws) +
+ ']';
+ }
+};
+
+// Convert an object to a string, such as {a: 1}.
+// This function calls stringify() for each of its values,
+// and does not output functions or prototype values.
+function stringifyObject(obj, options, level) {
+ var out = [];
+ var pretty = options.pretty && (Object.keys(obj).length > 2 ||
+ Object.keys(obj).some(function (k) { return typeof(obj[k]) === 'object' }));
+ var ws = pretty ? '\n' + new(Array)(level * 4 + 1).join(' ') : ' ';
+
+ var keys = options.showHidden ? Object.keys(obj) : Object.getOwnPropertyNames(obj);
+ keys.forEach(function (k) {
+ if (Object.prototype.hasOwnProperty.call(obj, k)
+ && !(obj[k] instanceof Function && options.hideFunctions)) {
+ out.push(eyes.stylize(k, options.styles.key, options.styles) + ': ' +
+ stringify(obj[k], options));
+ }
+ });
+
+ if (out.length === 0) {
+ return '{}';
+ } else {
+ return "{" + ws
+ + out.join(',' + (pretty ? ws : ' '))
+ + (pretty ? ws.slice(0, -4) : ws) +
+ "}";
+ }
+};
+
+// A better `typeof`
+function typeOf(value) {
+ var s = typeof(value),
+ types = [Object, Array, String, RegExp, Number, Function, Boolean, Date];
+
+ if (s === 'object' || s === 'function') {
+ if (value) {
+ types.forEach(function (t) {
+ if (value instanceof t) { s = t.name.toLowerCase() }
+ });
+ } else { s = 'null' }
+ }
+ return s;
+}
+
+function merge(/* variable args */) {
+ var objs = Array.prototype.slice.call(arguments);
+ var target = {};
+
+ objs.forEach(function (o) {
+ Object.keys(o).forEach(function (k) {
+ if (k === 'styles') {
+ if (! o.styles) {
+ target.styles = false;
+ } else {
+ target.styles = {}
+ for (var s in o.styles) {
+ target.styles[s] = o.styles[s];
+ }
+ }
+ } else {
+ target[k] = o[k];
+ }
+ });
+ });
+ return target;
+}
+
diff --git a/node_modules/eyes/package.json b/node_modules/eyes/package.json
new file mode 100644
index 0000000..3fcf7e5
--- /dev/null
+++ b/node_modules/eyes/package.json
@@ -0,0 +1,61 @@
+{
+ "_from": "eyes@0.1.x",
+ "_id": "eyes@0.1.8",
+ "_inBundle": false,
+ "_integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=",
+ "_location": "/eyes",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "eyes@0.1.x",
+ "name": "eyes",
+ "escapedName": "eyes",
+ "rawSpec": "0.1.x",
+ "saveSpec": null,
+ "fetchSpec": "0.1.x"
+ },
+ "_requiredBy": [
+ "/winston"
+ ],
+ "_resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
+ "_shasum": "62cf120234c683785d902348a800ef3e0cc20bc0",
+ "_spec": "eyes@0.1.x",
+ "_where": "/data/dev/Projets/Bingoloto Remote/node_modules/winston",
+ "author": {
+ "name": "Alexis Sellier",
+ "email": "self@cloudhead.net"
+ },
+ "bundleDependencies": false,
+ "contributors": [
+ {
+ "name": "Charlie Robbins",
+ "email": "charlie@nodejitsu.com"
+ }
+ ],
+ "deprecated": false,
+ "description": "a customizable value inspector",
+ "directories": {
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "engines": {
+ "node": "> 0.1.90"
+ },
+ "keywords": [
+ "inspector",
+ "debug",
+ "inspect",
+ "print"
+ ],
+ "licenses": [
+ "MIT"
+ ],
+ "main": "./lib/eyes",
+ "name": "eyes",
+ "scripts": {
+ "test": "node test/*-test.js"
+ },
+ "url": "http://github.com/cloudhead/eyes.js",
+ "version": "0.1.8"
+}
diff --git a/node_modules/eyes/test/eyes-test.js b/node_modules/eyes/test/eyes-test.js
new file mode 100644
index 0000000..1f9606a
--- /dev/null
+++ b/node_modules/eyes/test/eyes-test.js
@@ -0,0 +1,56 @@
+var util = require('util');
+var eyes = require('../lib/eyes');
+
+eyes.inspect({
+ number: 42,
+ string: "John Galt",
+ regexp: /[a-z]+/,
+ array: [99, 168, 'x', {}],
+ func: function () {},
+ bool: false,
+ nil: null,
+ undef: undefined,
+ object: {attr: []}
+}, "native types");
+
+eyes.inspect({
+ number: new(Number)(42),
+ string: new(String)("John Galt"),
+ regexp: new(RegExp)(/[a-z]+/),
+ array: new(Array)(99, 168, 'x', {}),
+ bool: new(Boolean)(false),
+ object: new(Object)({attr: []}),
+ date: new(Date)
+}, "wrapped types");
+
+var obj = {};
+obj.that = { self: obj };
+obj.self = obj;
+
+eyes.inspect(obj, "circular object");
+eyes.inspect({hello: 'moto'}, "small object");
+eyes.inspect({hello: new(Array)(6) }, "big object");
+eyes.inspect(["hello 'world'", 'hello "world"'], "quotes");
+eyes.inspect({
+ recommendations: [{
+ id: 'a7a6576c2c822c8e2bd81a27e41437d8',
+ key: [ 'spree', 3.764316258020699 ],
+ value: {
+ _id: 'a7a6576c2c822c8e2bd81a27e41437d8',
+ _rev: '1-2e2d2f7fd858c4a5984bcf809d22ed98',
+ type: 'domain',
+ domain: 'spree',
+ weight: 3.764316258020699,
+ product_id: 30
+ }
+ }]
+}, 'complex');
+
+eyes.inspect([null], "null in array");
+
+var inspect = eyes.inspector({ stream: null });
+
+util.puts(inspect('something', "something"));
+util.puts(inspect("something else"));
+
+util.puts(inspect(["no color"], null, { styles: false }));