aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nanoassert
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/nanoassert
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/nanoassert')
-rw-r--r--node_modules/nanoassert/LICENSE13
-rw-r--r--node_modules/nanoassert/README.md49
-rw-r--r--node_modules/nanoassert/index.js22
-rw-r--r--node_modules/nanoassert/package.json31
-rw-r--r--node_modules/nanoassert/test.js27
5 files changed, 142 insertions, 0 deletions
diff --git a/node_modules/nanoassert/LICENSE b/node_modules/nanoassert/LICENSE
new file mode 100644
index 00000000..b45703b8
--- /dev/null
+++ b/node_modules/nanoassert/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2017, Emil Bay <github@tixz.dk>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/nanoassert/README.md b/node_modules/nanoassert/README.md
new file mode 100644
index 00000000..799060a5
--- /dev/null
+++ b/node_modules/nanoassert/README.md
@@ -0,0 +1,49 @@
+# `nanoassert`
+
+> Nanoscale assertion module
+
+## Usage
+
+```js
+var assert = require('nanoassert')
+
+assert(a !== b, `${a} !== ${b}`)
+```
+
+## API
+
+### `assert(declaration, [message])`
+### `assert.ok(declaration, [message])`
+
+Assert that `declaration` is truthy otherwise throw `Error` with
+optional `message`, which defaults to `AssertionError`.
+If you want friendlier messages you can use template strings to show the
+assertion made like in the example above.
+
+### `assert.notOk(declaration, [message])`
+
+Assert that `declaration` is not truthy.
+
+### `assert.equal(a, b, [message])`
+
+Assert that `a` is loosely equal to `b`. Uses `==` for the comparison.
+
+### `assert.notEqual(a, b, [message])`
+
+Assert that `a` is loosely not equal to `b`. Uses `==` for the comparison.
+
+## Why
+
+I like to write public facing code very defensively, but have complaints about
+the size incurred by the `assert` module. I only use the top-level `assert`
+method anyway, so this should make everyone happy :)
+
+## Install
+
+```sh
+npm install nanoassert
+```
+
+## License
+
+[ISC](LICENSE)
diff --git a/node_modules/nanoassert/index.js b/node_modules/nanoassert/index.js
new file mode 100644
index 00000000..49361a1f
--- /dev/null
+++ b/node_modules/nanoassert/index.js
@@ -0,0 +1,22 @@
+assert.notEqual = notEqual
+assert.notOk = notOk
+assert.equal = equal
+assert.ok = assert
+
+module.exports = assert
+
+function equal (a, b, m) {
+ assert(a == b, m) // eslint-disable-line eqeqeq
+}
+
+function notEqual (a, b, m) {
+ assert(a != b, m) // eslint-disable-line eqeqeq
+}
+
+function notOk (t, m) {
+ assert(!t, m)
+}
+
+function assert (t, m) {
+ if (!t) throw new Error(m || 'AssertionError')
+}
diff --git a/node_modules/nanoassert/package.json b/node_modules/nanoassert/package.json
new file mode 100644
index 00000000..339a4433
--- /dev/null
+++ b/node_modules/nanoassert/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "nanoassert",
+ "version": "1.1.0",
+ "description": "Nanoscale assertion module",
+ "main": "index.js",
+ "dependencies": {},
+ "devDependencies": {
+ "tape": "^4.6.3"
+ },
+ "scripts": {
+ "test": "tape test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/emilbayes/nanoassert.git"
+ },
+ "keywords": [
+ "assert",
+ "unassert",
+ "power-assert",
+ "tiny",
+ "nano",
+ "pico"
+ ],
+ "author": "Emil Bay <github@tixz.dk>",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/emilbayes/nanoassert/issues"
+ },
+ "homepage": "https://github.com/emilbayes/nanoassert#readme"
+}
diff --git a/node_modules/nanoassert/test.js b/node_modules/nanoassert/test.js
new file mode 100644
index 00000000..2aed76fb
--- /dev/null
+++ b/node_modules/nanoassert/test.js
@@ -0,0 +1,27 @@
+var assert = require('.')
+var test = require('tape')
+
+test('test', function (t) {
+ try {
+ assert(true === true) // test that it doesn't throw
+ t.pass('does not throw on truthy')
+ } catch (e) {
+ t.fail()
+ }
+
+ t.throws(assert.bind(null, false), 'throws on falsy')
+
+ try {
+ assert(false)
+ } catch (e) {
+ t.equal(e.message, 'AssertionError', 'default message')
+ }
+
+ try {
+ assert(false, 'hello world')
+ } catch (e) {
+ t.equal(e.message, 'hello world', 'custom message')
+ }
+
+ t.end()
+})