1.5.5 • Published 2 years ago

boolean-jokes v1.5.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

boolean-jokes

ℹ Some useful functions to work with boolean.

Javascript ESModule.


Index of Contents


Installation

npm install boolean-jokes

Functions & Examples

  • true_false(Buffer:string):boolean

Converts only the strings "true" and "false" to boolean respectively.

// only string true or false are parsed

import { true_false } from 'boolean-jokes'

const converted = await bool( 'true' )
console.log( converted )

  • map(object, string|number):boolean

Given an object it will map the property name to the corresponding boolean value set.

ℹ It accepts only type object for the logic parameter, and it will check if any of the value set for the property is a boolean and not any other type.
ℹ It accepts only type string or number for the against parameter

This will return false

import { map } from 'boolean-jokes'

/**
 * @type {string}
 */
const against = 'no'

/**
 * @type {{no: boolean, yes: boolean, true: boolean, false: boolean}}
 */
const logic = {
    true: true, 
    false: false, 
    yes: true, 
    no: false
}
const matchBool = await map( logic, against )

console.log( matchBool ) // return 'false'

This will reject with:

your against value haven't matched any of your logic object. given against: ok

import { map } from 'boolean-jokes'

/**
 * @type {string}
 */
const against = 'ok'

/**
 * @type {{no: boolean, yes: boolean, true: boolean, false: boolean}}
 */
const logic = {
    true: true, 
    false: false, 
    yes: true, 
    no: false
}
const matchBool = await map( logic, against )

console.log( matchBool ) // reject -> your `against` value haven't matched any of your `logic` object. given `against`: ok
1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.7

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago