Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boolify-string

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boolify-string - npm Package Compare versions

Comparing version 0.1.0 to 1.0.1

53

package.json
{
"name": "boolify-string",
"description": "Check a string whether truthy or falsy.",
"version": "0.1.0",
"homepage": "https://github.com/sanemat/node-boolify-string",
"bugs": "https://github.com/sanemat/node-boolify-string/issues",
"license": "MIT",
"main": "lib/boolify-string.js",
"version": "1.0.1",
"author": {

@@ -13,22 +9,13 @@ "name": "sanemat",

},
"repository": {
"type": "git",
"url": "https://github.com/sanemat/node-boolify-string"
},
"keywords": [],
"bugs": "https://github.com/sanemat/node-boolify-string/issues",
"dependencies": {},
"devDependencies": {
"coveralls": "^2.10.0",
"espower-loader": "^0.7.1",
"gulp": "^3.6.2",
"gulp-if": "^1.2.1",
"gulp-istanbul": "^0.2.0",
"gulp-jscs": "^0.4.2",
"gulp-jshint": "^1.5.5",
"gulp-load-plugins": "^0.5.1",
"gulp-mocha": "^0.4.1",
"gulp-plumber": "^0.6.2",
"intelli-espower-loader": "^0.1.0",
"jshint-stylish": "^0.2.0",
"power-assert": "^0.7.2"
"david": "^6.1.6",
"espower-loader": "^0.11.0",
"fixpack": "^2.2.0",
"intelli-espower-loader": "^0.7.0",
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"mocha": "^2.2.5",
"power-assert": "^0.11.0"
},

@@ -38,6 +25,22 @@ "directories": {

},
"homepage": "https://github.com/sanemat/node-boolify-string",
"keywords": [
"string",
"environment",
"bool"
],
"license": "MIT",
"main": "lib/boolify-string.js",
"repository": {
"type": "git",
"url": "https://github.com/sanemat/node-boolify-string"
},
"scripts": {
"coveralls": "gulp test && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"test": "gulp test"
"david": "david",
"fixpack": "fixpack",
"jscs": "jscs lib/boolify-string.js test/boolify-string_test.js example/simple.js",
"jshint": "jshint lib/boolify-string.js test/boolify-string_test.js example/simple.js",
"test": "mocha --require intelli-espower-loader",
"verify": "npm run jscs && npm run jshint && npm run test"
}
}
# boolify-string
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image] [![Coverage Status][coveralls-image]][coveralls-url]
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image]
Check a string whether truthy or falsy.
# Use case
Read from environmental variable, e.g. process.env.CI = (TRUE/(empty))
## Use case
Read from environment variable, sometimes these are 'True', 'false', '1', '', undefined, etc.
```javascript
if (boolifyString(process.env.CI)){
something_do();
}
```
if (boolifyString(process.env.CI)){ something_do(); }
```

@@ -38,15 +41,21 @@ ## Install

boolifyString('null');// #=> false
// primitive values as is
boolifyString(true);// #=> true
boolifyString(false);// #=> false
boolifyString({});// #=> true
boolifyString(1);// #=> true
boolifyString(-1);// #=> true
boolifyString(0);// #=> false
boolifyString([]);// #=> true
boolifyString(undefined);// #=> false
boolifyString(null);// #=> false
```
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [gulp](http://gulpjs.com/).
## License
Copyright (c) 2014 sanemat. Licensed under the MIT license.
Copyright (c) 2014-2015 sanemat. Licensed under the MIT license.
[npm-url]: https://npmjs.org/package/boolify-string

@@ -58,3 +67,1 @@ [npm-image]: https://badge.fury.io/js/boolify-string.svg

[daviddm-image]: https://david-dm.org/sanemat/node-boolify-string
[coveralls-url]: https://coveralls.io/r/sanemat/node-boolify-string
[coveralls-image]: https://coveralls.io/repos/sanemat/node-boolify-string/badge.png

@@ -52,8 +52,31 @@ 'use strict';

it('actual true should be true', function(){
assert.equal(boolifyString(true), true);
describe('primitive values as is', function () {
it('true should be true', function(){
assert.equal(boolifyString(true), true);
});
it('false should be false', function(){
assert.equal(boolifyString(false), false);
});
it('object should be true', function(){
assert.equal(boolifyString({}), true);
});
it('1 should be true', function(){
assert.equal(boolifyString(1), true);
});
it('-1 should be true', function(){
assert.equal(boolifyString(-1), true);
});
it('0 should be false', function(){
assert.equal(boolifyString(0), false);
});
it('array should be true', function(){
assert.equal(boolifyString([]), true);
});
it('undefined should be false', function(){
assert.equal(boolifyString(undefined), false);
});
it('null should be false', function(){
assert.equal(boolifyString(null), false);
});
});
it('actual false should be false', function(){
assert.equal(boolifyString(false), false);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc