Commit 25a5dd10 authored by Thomas Lindstrøm's avatar Thomas Lindstrøm
Browse files

Initial commit

parents
Pipeline #3094282 passed with stage
in 1 minute and 31 seconds
node_modules
before_script:
- apt-get update -y
- apt-get install -y libssl-dev build-essential wget
- wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
- source /root/.bashrc
- nvm install node
- nvm use node
- npm install && npm install -g mocha
test:
script:
- npm test
Copyright (c) 2016, Amphibian
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.
# is-undefined
undefined type checker
```
npm install @amphibian/is-undefined
```
```javascript
var isUndefined = require('@amphibian/is-undefined');
isUndefined(undefined); // > true
isUndefined('hello'); // > false
```
// ---------------------------------------------------------------------------
// is-undefined.js
//
// undefined type checker
// - variable: Variable to be checked
// ---------------------------------------------------------------------------
function isUndefined(variable) {
return typeof variable === 'undefined';
}
module.exports = isUndefined;
{
"name": "@amphibian/is-undefined",
"version": "0.0.0",
"description": "undefined type checker",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/thomaslindstr_m/is-undefined.git"
},
"author": "Thomas Lindstrøm <t@hom.as>",
"license": "ISC",
"bugs": {
"url": "https://gitlab.com/thomaslindstr_m/is-undefined/issues"
},
"homepage": "https://gitlab.com/thomaslindstr_m/is-undefined#README"
}
// ---------------------------------------------------------------------------
// test.js
// ---------------------------------------------------------------------------
var isUndefined = require('./index.js');
var assert = require('assert');
describe('is-undefined', function () {
it('should return true for undefined', function () {
assert.equal(isUndefined(undefined), true);
});
it('should return false for false', function () {
assert.equal(isUndefined(false), false);
});
it('should return false for true', function () {
assert.equal(isUndefined(true), false);
});
it('should return false for empty strings', function () {
assert.equal(isUndefined(''), false);
});
it('should return false for strings with content', function () {
assert.equal(isUndefined('hello'), false);
});
it('should return false for numbers', function () {
assert.equal(isUndefined(1), false);
});
it('should return false for negative numbers', function () {
assert.equal(isUndefined(-1), false);
});
it('should return false for 0', function () {
assert.equal(isUndefined(0), false);
});
it('should return false for objects', function () {
assert.equal(isUndefined({}), false);
});
it('should return false for functions', function () {
assert.equal(isUndefined(function () {}), false);
});
it('should return false for arrays', function () {
assert.equal(isUndefined([]), false);
});
it('should return false for null', function () {
assert.equal(isUndefined(null), false);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment