New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

falsify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

falsify

Helps you deny the existence of specified truthy values (e.g. 'someString', aParticularObject)

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

falsify

This node module helps you deny the existence of specified truthy values (e.g. 'some string', aParticularObject)

Install

$ npm install falsify

Usage

var falsify = require('falsify')

Now falsify is a function that, when called, will return to you a function. falsify expects to be passed 0 or more arguments. These are the values that you would like your new function to consider falsy. The new function accepts an argument that it will attempt to match against the values you originally supplied to falsify. If such a match is found, the new function will return false. If a match is not found, the new function will return the standard 'truthiness' of the argument.

The examples below (and the tests within test/test.js) should serve to clarify any questions you may have.

Example

const
  falsify = require('falsify')
, isTruthyButNotTheBooleanLiteralTrue = falsify(true)
, someObject = {}
, isTruthyButNotHelloOrSomeObject = falsify('hello', someObject)


console.log(isTruthyButNotTheBooleanLiteralTrue(true))        // false
console.log(isTruthyButNotTheBooleanLiteralTrue(0))           // false
console.log(isTruthyButNotTheBooleanLiteralTrue(undefined))   // false
console.log(isTruthyButNotTheBooleanLiteralTrue(NaN))         // false
console.log(isTruthyButNotTheBooleanLiteralTrue(null))        // false
console.log(isTruthyButNotTheBooleanLiteralTrue(''))          // false
console.log(isTruthyButNotTheBooleanLiteralTrue(false))       // false
console.log(isTruthyButNotTheBooleanLiteralTrue('hi'))        // true
console.log(isTruthyButNotTheBooleanLiteralTrue({}))          // true
console.log(isTruthyButNotTheBooleanLiteralTrue([]))          // true


console.log(isTruthyButNotHelloOrSomeObject('hello'))         // false
console.log(isTruthyButNotHelloOrSomeObject(someObject))      // false
console.log(isTruthyButNotHelloOrSomeObject(0))               // false
console.log(isTruthyButNotHelloOrSomeObject(undefined))       // false
console.log(isTruthyButNotHelloOrSomeObject(NaN))             // false
console.log(isTruthyButNotHelloOrSomeObject(null))            // false
console.log(isTruthyButNotHelloOrSomeObject(''))              // false
console.log(isTruthyButNotHelloOrSomeObject(false))           // false
console.log(isTruthyButNotHelloOrSomeObject('hi'))            // true
console.log(isTruthyButNotHelloOrSomeObject({}))              // true
console.log(isTruthyButNotHelloOrSomeObject([]))              // true

ISC License (ISC)

Copyright 2015, Instancetype

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.

Keywords

boolean

FAQs

Package last updated on 03 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts