Giter Site home page Giter Site logo

boolean's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar goloroden avatar grundhoeferj avatar mr-perseus avatar ohar avatar ryasmi avatar semantic-release-bot avatar smares avatar thomaschaaf avatar yeldirium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

boolean's Issues

v3.1.3 dependent on node >= 16.7.0

The recent v3.1.3 has a set dependency for node >= 16.7.0. As it's a patch release, this breaks other packages dependent on it without a specified exact version number (in our case, pm2) when using a lower node version.

ON / on to true

Hi,

Can you add the string "ON" and "on" to convert this to true?
Or is there a reason it shouldn't be?

Thanks!

Feature Request: isBooleanable()

I would love to see a function that tells you if an object/string/whatever is one of the "booleanable" options.

For example isBooleanable() would return True for the values you consider a truth or false: true, false, 'Y', 'N', '1', 0, 'on', 'off', etc...

But when passing something that isn't one of the covered true/false items, it would return False: 'computer', '2022-02-15T11:37:00-08:00', etc...

That would allow you to check if an object is something that should evaluate to a true/false before calling boolean() and potentially getting False as the default result.

"TRUE "

Nice package. However, I was testing this package for my test cases and if failed for "TRUE " or "true ". trim might be required.

Readme is incorrect

This library is much more permissive than the readme claims.

Take this code as an example

var boolean = require('boolean')

console.log(boolean([false]))
console.log(boolean({}))
console.log(boolean(001))
console.log(boolean(100))
console.log(boolean('negative'))
console.log(boolean('hellyo'))
console.log(boolean('noyesno'))
console.log(boolean('321'))

All of these expressions will return true

Any object which is truthy and not a string will return true
Any string that contains a substring of 't', 'y', or 'yes' will return true
Any string that begins with the word 'true' or ends with the number 1 will return true

Lookbehind assertions are not compatible with FF

return /^(?<truthy>true|t|yes|y|on|1)$/iu.test(value.trim());

Lookbehind assertions got introduced in early 2018 and browsers like FF still don't support it. In order for this library to be more acceptable to work with all the major browsers, I would recommend to use look ahead assertions at this point in time.

This works on recent versions of Chrome and Safari. I haven't tested on IE.

Ref: https://stackoverflow.com/questions/641407/javascript-negative-lookbehind-equivalent#

SyntaxError using create-react-app and Node v13

Failed to compile.

./node_modules/boolean/build/lib/boolean.js
SyntaxError: /Users/gajus/dev/applaudience/applaudience-explorer-web-app/node_modules/boolean/build/lib/boolean.js: Expected atom at position 2
    ^(?<truthy>t
      ^
^C

Wrong result with primitive object wrappers

While I know it is advised not to use primitive object wrappers, you might still want to look into this:

const truthy = new String('true')
console.log(boolean(truthy)); // => false

A more robust approach would be doing something like this:

switch (Object.prototype.toString.call(value)) {
  case '[object String]':
    return [ 'true', 't', 'yes', 'y', 'on', '1' ].includes(value.trim().toLowerCase());
  case '[object Number]':
    return value.valueOf() === 1;
  case '[object Boolean]':
    return value.valueOf();
  default:
    return false;
}

Changelog missing 1.x and 2.x notes

Recently I've started working on a project that's badly outdated and "boolean" is "^0.2.0" ... I would like to 'just upgrade it' but not sure what the implications are.
Would be good if the changelog had some notes on any breaking changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.