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 1.1.0 to 2.0.0

14

changelog.md

@@ -0,1 +1,15 @@

<a name="2.0.0"></a>
# 2.0.0 (2015-07-19)
* Support YAML's specification. e.g. 'y/n', 'on/off'
* http://yaml.org/type/bool.html
* Breaking change!
### Features
* **specification:** support yaml specification ([d4ef6e4](https://github.com/sanemat/node-boolify-string/commit/d4ef6e4))
<a name="1.1.0"></a>

@@ -2,0 +16,0 @@ # 1.1.0 (2015-07-19)

@@ -40,1 +40,6 @@ /*

//null null false
// http://yaml.org/type/bool.html
//y|Y|yes|Yes|YES|n|N|no|No|NO
//|true|True|TRUE|false|False|FALSE
//|on|On|ON|off|Off|OFF

3

lib/boolify-string.js

@@ -30,2 +30,5 @@ /*

case '':
case 'n':
case 'no':
case 'off':
bool = false;

@@ -32,0 +35,0 @@ break;

9

package.json
{
"name": "boolify-string",
"description": "Check a string whether truthy or falsy.",
"version": "1.1.0",
"version": "2.0.0",
"author": {

@@ -28,4 +28,9 @@ "name": "sanemat",

"bool",
"boolean",
"environment",
"string"
"false",
"falsy",
"string",
"true",
"truthy"
],

@@ -32,0 +37,0 @@ "license": "MIT",

# boolify-string
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Appveyor Status][appveyor-image]][appveyor-url] [![Dependency Status][daviddm-url]][daviddm-image]
Check a string whether truthy or falsy.
> Check a string whether truthy or falsy.
## Use case

@@ -52,5 +53,42 @@ Read from environment variable, sometimes these are 'True', 'false', '1', '', undefined, etc.

boolifyString(null);// #=> false
// string constructor
boolifyString(new String('true'));// #=> true
boolifyString(new String('false'));// #=> false
// YAML's specification
// http://yaml.org/type/bool.html
// y|Y|yes|Yes|YES|n|N|no|No|NO
// |true|True|TRUE|false|False|FALSE
// |on|On|ON|off|Off|OFF
boolifyString('y');// #=> true
boolifyString('Y');// #=> true
boolifyString('yes');// #=> true
boolifyString('Yes');// #=> true
boolifyString('YES');// #=> true
boolifyString('n');// #=> false
boolifyString('N');// #=> false
boolifyString('no');// #=> false
boolifyString('No');// #=> false
boolifyString('NO');// #=> false
boolifyString('true');// #=> true
boolifyString('True');// #=> true
boolifyString('TRUE');// #=> true
boolifyString('false');// #=> false
boolifyString('False');// #=> false
boolifyString('FALSE');// #=> false
boolifyString('on');// #=> true
boolifyString('On');// #=> true
boolifyString('ON');// #=> true
boolifyString('off');// #=> false
boolifyString('Off');// #=> false
boolifyString('OFF');// #=> false
```
## Changelog
[changelog](./changelog.md)
## License

@@ -57,0 +95,0 @@

@@ -92,2 +92,70 @@ 'use strict';

});
describe('yaml specification', function (){
it('y should be true', function(){
assert.equal(boolifyString('y'), true);
});
it('Y should be true', function(){
assert.equal(boolifyString('Y'), true);
});
it('yes should be true', function(){
assert.equal(boolifyString('yes'), true);
});
it('Yes should be true', function(){
assert.equal(boolifyString('Yes'), true);
});
it('YES should be true', function(){
assert.equal(boolifyString('YES'), true);
});
it('n should be false', function(){
assert.equal(boolifyString('n'), false);
});
it('N should be false', function(){
assert.equal(boolifyString('N'), false);
});
it('no should be false', function(){
assert.equal(boolifyString('no'), false);
});
it('No should be false', function(){
assert.equal(boolifyString('No'), false);
});
it('NO should be false', function(){
assert.equal(boolifyString('NO'), false);
});
it('true should be true', function(){
assert.equal(boolifyString('true'), true);
});
it('True should be true', function(){
assert.equal(boolifyString('True'), true);
});
it('TRUE should be true', function(){
assert.equal(boolifyString('TRUE'), true);
});
it('false should be false', function(){
assert.equal(boolifyString('false'), false);
});
it('False should be false', function(){
assert.equal(boolifyString('False'), false);
});
it('FALSE should be false', function(){
assert.equal(boolifyString('FALSE'), false);
});
it('on should be true', function(){
assert.equal(boolifyString('on'), true);
});
it('On should be true', function(){
assert.equal(boolifyString('On'), true);
});
it('ON should be true', function(){
assert.equal(boolifyString('ON'), true);
});
it('off should be false', function(){
assert.equal(boolifyString('off'), false);
});
it('Off should be false', function(){
assert.equal(boolifyString('Off'), false);
});
it('OFF should be false', function(){
assert.equal(boolifyString('OFF'), false);
});
});
});
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