aboutsummaryrefslogtreecommitdiff
path: root/node_modules/better-assert
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/better-assert')
-rw-r--r--node_modules/better-assert/.npmignore4
-rw-r--r--node_modules/better-assert/History.md15
-rw-r--r--node_modules/better-assert/Makefile5
-rw-r--r--node_modules/better-assert/Readme.md61
-rw-r--r--node_modules/better-assert/example.js10
-rw-r--r--node_modules/better-assert/index.js38
-rw-r--r--node_modules/better-assert/package.json27
7 files changed, 160 insertions, 0 deletions
diff --git a/node_modules/better-assert/.npmignore b/node_modules/better-assert/.npmignore
new file mode 100644
index 000000000..f1250e584
--- /dev/null
+++ b/node_modules/better-assert/.npmignore
@@ -0,0 +1,4 @@
+support
+test
+examples
+*.sock
diff --git a/node_modules/better-assert/History.md b/node_modules/better-assert/History.md
new file mode 100644
index 000000000..cbb579bea
--- /dev/null
+++ b/node_modules/better-assert/History.md
@@ -0,0 +1,15 @@
+
+1.0.0 / 2013-02-03
+==================
+
+ * Stop using the removed magic __stack global getter
+
+0.1.0 / 2012-10-04
+==================
+
+ * add throwing of AssertionError for test frameworks etc
+
+0.0.1 / 2010-01-03
+==================
+
+ * Initial release
diff --git a/node_modules/better-assert/Makefile b/node_modules/better-assert/Makefile
new file mode 100644
index 000000000..36a3ed7d0
--- /dev/null
+++ b/node_modules/better-assert/Makefile
@@ -0,0 +1,5 @@
+
+test:
+ @echo "populate me"
+
+.PHONY: test \ No newline at end of file
diff --git a/node_modules/better-assert/Readme.md b/node_modules/better-assert/Readme.md
new file mode 100644
index 000000000..d8d3a63b6
--- /dev/null
+++ b/node_modules/better-assert/Readme.md
@@ -0,0 +1,61 @@
+
+# better-assert
+
+ Better c-style assertions using [callsite](https://github.com/visionmedia/callsite) for
+ self-documenting failure messages.
+
+## Installation
+
+ $ npm install better-assert
+
+## Example
+
+ By default assertions are enabled, however the __NO_ASSERT__ environment variable
+ will deactivate them when truthy.
+
+```js
+var assert = require('better-assert');
+
+test();
+
+function test() {
+ var user = { name: 'tobi' };
+ assert('tobi' == user.name);
+ assert('number' == typeof user.age);
+}
+
+AssertionError: 'number' == typeof user.age
+ at test (/Users/tj/projects/better-assert/example.js:9:3)
+ at Object.<anonymous> (/Users/tj/projects/better-assert/example.js:4:1)
+ at Module._compile (module.js:449:26)
+ at Object.Module._extensions..js (module.js:467:10)
+ at Module.load (module.js:356:32)
+ at Function.Module._load (module.js:312:12)
+ at Module.runMain (module.js:492:10)
+ at process.startup.processNextTick.process._tickCallback (node.js:244:9)
+```
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2012 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
+
+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. \ No newline at end of file
diff --git a/node_modules/better-assert/example.js b/node_modules/better-assert/example.js
new file mode 100644
index 000000000..688c29e8a
--- /dev/null
+++ b/node_modules/better-assert/example.js
@@ -0,0 +1,10 @@
+
+var assert = require('./');
+
+test();
+
+function test() {
+ var user = { name: 'tobi' };
+ assert('tobi' == user.name);
+ assert('number' == typeof user.age);
+} \ No newline at end of file
diff --git a/node_modules/better-assert/index.js b/node_modules/better-assert/index.js
new file mode 100644
index 000000000..fd1c9b7d1
--- /dev/null
+++ b/node_modules/better-assert/index.js
@@ -0,0 +1,38 @@
+/**
+ * Module dependencies.
+ */
+
+var AssertionError = require('assert').AssertionError
+ , callsite = require('callsite')
+ , fs = require('fs')
+
+/**
+ * Expose `assert`.
+ */
+
+module.exports = process.env.NO_ASSERT
+ ? function(){}
+ : assert;
+
+/**
+ * Assert the given `expr`.
+ */
+
+function assert(expr) {
+ if (expr) return;
+
+ var stack = callsite();
+ var call = stack[1];
+ var file = call.getFileName();
+ var lineno = call.getLineNumber();
+ var src = fs.readFileSync(file, 'utf8');
+ var line = src.split('\n')[lineno-1];
+ var src = line.match(/assert\((.*)\)/)[1];
+
+ var err = new AssertionError({
+ message: src,
+ stackStartFunction: stack[0].getFunction()
+ });
+
+ throw err;
+}
diff --git a/node_modules/better-assert/package.json b/node_modules/better-assert/package.json
new file mode 100644
index 000000000..ae0463507
--- /dev/null
+++ b/node_modules/better-assert/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "better-assert",
+ "version": "1.0.2",
+ "description": "Better assertions for node, reporting the expr, filename, lineno etc",
+ "keywords": [
+ "assert",
+ "stack",
+ "trace",
+ "debug"
+ ],
+ "author": "TJ Holowaychuk <tj@vision-media.ca>",
+ "contributors": [
+ "TonyHe <coolhzb@163.com>",
+ "ForbesLindesay"
+ ],
+ "dependencies": {
+ "callsite": "1.0.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/visionmedia/better-assert.git"
+ },
+ "main": "index",
+ "engines": {
+ "node": "*"
+ }
+}