aboutsummaryrefslogtreecommitdiff
path: root/node_modules/defined
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/defined
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/defined')
-rw-r--r--node_modules/defined/.travis.yml4
-rw-r--r--node_modules/defined/LICENSE18
-rw-r--r--node_modules/defined/example/defined.js4
-rw-r--r--node_modules/defined/index.js5
-rw-r--r--node_modules/defined/package.json46
-rw-r--r--node_modules/defined/readme.markdown53
-rw-r--r--node_modules/defined/test/def.js22
-rw-r--r--node_modules/defined/test/falsy.js9
8 files changed, 161 insertions, 0 deletions
diff --git a/node_modules/defined/.travis.yml b/node_modules/defined/.travis.yml
new file mode 100644
index 00000000..895dbd36
--- /dev/null
+++ b/node_modules/defined/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/node_modules/defined/LICENSE b/node_modules/defined/LICENSE
new file mode 100644
index 00000000..ee27ba4b
--- /dev/null
+++ b/node_modules/defined/LICENSE
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+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/defined/example/defined.js b/node_modules/defined/example/defined.js
new file mode 100644
index 00000000..7b5d982f
--- /dev/null
+++ b/node_modules/defined/example/defined.js
@@ -0,0 +1,4 @@
+var defined = require('../');
+var opts = { y : false, w : 4 };
+var x = defined(opts.x, opts.y, opts.w, 8);
+console.log(x);
diff --git a/node_modules/defined/index.js b/node_modules/defined/index.js
new file mode 100644
index 00000000..f8a22198
--- /dev/null
+++ b/node_modules/defined/index.js
@@ -0,0 +1,5 @@
+module.exports = function () {
+ for (var i = 0; i < arguments.length; i++) {
+ if (arguments[i] !== undefined) return arguments[i];
+ }
+};
diff --git a/node_modules/defined/package.json b/node_modules/defined/package.json
new file mode 100644
index 00000000..7f699760
--- /dev/null
+++ b/node_modules/defined/package.json
@@ -0,0 +1,46 @@
+{
+ "name" : "defined",
+ "version" : "1.0.0",
+ "description" : "return the first argument that is `!== undefined`",
+ "main" : "index.js",
+ "directories" : {
+ "example" : "example",
+ "test" : "test"
+ },
+ "dependencies" : {},
+ "devDependencies" : {
+ "tape" : "~3.5.0"
+ },
+ "scripts" : {
+ "test" : "tape test/*.js"
+ },
+ "testling" : {
+ "files" : "test/*.js",
+ "browsers" : {
+ "ie" : [ 6, 7, 8, 9 ],
+ "ff" : [ 3.5, 10, 15.0 ],
+ "chrome" : [ 10, 22 ],
+ "safari" : [ 5.1 ],
+ "opera" : [ 12 ]
+ }
+ },
+ "repository" : {
+ "type" : "git",
+ "url" : "git://github.com/substack/defined.git"
+ },
+ "homepage" : "https://github.com/substack/defined",
+ "keywords" : [
+ "undefined",
+ "short-circuit",
+ "||",
+ "or",
+ "//",
+ "defined-or"
+ ],
+ "author" : {
+ "name" : "James Halliday",
+ "email" : "mail@substack.net",
+ "url" : "http://substack.net"
+ },
+ "license" : "MIT"
+}
diff --git a/node_modules/defined/readme.markdown b/node_modules/defined/readme.markdown
new file mode 100644
index 00000000..9616195d
--- /dev/null
+++ b/node_modules/defined/readme.markdown
@@ -0,0 +1,53 @@
+# defined
+
+return the first argument that is `!== undefined`
+
+[![browser support](http://ci.testling.com/substack/defined.png)](http://ci.testling.com/substack/defined)
+
+[![build status](https://secure.travis-ci.org/substack/defined.png)](http://travis-ci.org/substack/defined)
+
+Most of the time when I chain together `||`s, I actually just want the first
+item that is not `undefined`, not the first non-falsy item.
+
+This module is like the defined-or (`//`) operator in perl 5.10+.
+
+# example
+
+``` js
+var defined = require('defined');
+var opts = { y : false, w : 4 };
+var x = defined(opts.x, opts.y, opts.w, 100);
+console.log(x);
+```
+
+```
+$ node example/defined.js
+false
+```
+
+The return value is `false` because `false` is the first item that is
+`!== undefined`.
+
+# methods
+
+``` js
+var defined = require('defined')
+```
+
+## var x = defined(a, b, c...)
+
+Return the first item in the argument list `a, b, c...` that is `!== undefined`.
+
+If all the items are `=== undefined`, return undefined.
+
+# install
+
+With [npm](https://npmjs.org) do:
+
+```
+npm install defined
+```
+
+# license
+
+MIT
diff --git a/node_modules/defined/test/def.js b/node_modules/defined/test/def.js
new file mode 100644
index 00000000..48da5171
--- /dev/null
+++ b/node_modules/defined/test/def.js
@@ -0,0 +1,22 @@
+var defined = require('../');
+var test = require('tape');
+
+test('defined-or', function (t) {
+ var u = undefined;
+
+ t.equal(defined(), u, 'empty arguments');
+ t.equal(defined(u), u, '1 undefined');
+ t.equal(defined(u, u), u, '2 undefined');
+ t.equal(defined(u, u, u, u), u, '4 undefineds');
+
+ t.equal(defined(undefined, false, true), false, 'false[0]');
+ t.equal(defined(false, true), false, 'false[1]');
+ t.equal(defined(undefined, 0, true), 0, 'zero[0]');
+ t.equal(defined(0, true), 0, 'zero[1]');
+
+ t.equal(defined(3, undefined, 4), 3, 'first arg');
+ t.equal(defined(undefined, 3, 4), 3, 'second arg');
+ t.equal(defined(undefined, undefined, 3), 3, 'third arg');
+
+ t.end();
+});
diff --git a/node_modules/defined/test/falsy.js b/node_modules/defined/test/falsy.js
new file mode 100644
index 00000000..6b7d623f
--- /dev/null
+++ b/node_modules/defined/test/falsy.js
@@ -0,0 +1,9 @@
+var test = require('tape');
+var defined = require('../');
+
+test('falsy', function (t) {
+ t.plan(1);
+ var opts = { y : false, w : 4 };
+ var x = defined(opts.x, opts.y, opts.w, 8);
+ t.equal(x, false);
+});