npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

float_data_type

v1.1.1

Published

The library is used to create the `float` data type with its own set of methods

Downloads

4

Readme

Float

The library is used to create a float data type with its own set of methods.

The Float() function can be called as a constructor with or without a parameter. In both cases, it will return an instance of Float with the value property, where the value will be a fractional number. In the latter case, the value of this property will be a random fractional number.

// 1
let float1 = new Float();
console.log(float1); // Float { value: random fractional number }
console.log(float1.value); // random fractional number

// 2
let float2 = new Float(-1.7);
console.log(float2); // Float { value: -1.7 }

Also Float() can be called as a normal function and work similarly as if Float.random() is called.

let float3 = Float();
console.log(float3); // random fractional number

The typeof operator does not return the float data type in this library.

console.log(typeof float1); // "object"
console.log(typeof float3); // "number"

Methods

Float.prototype.toFixed()

Works similarly to Number.prototype.toFixed().

let float4 = new Float(1.234);
console.log(float4); // Float { value: 1.234 }
console.log(
    float4.toFixed(), // Float { value: "1" }
);

Float.random([min, max])

Generates a random fractional number.

let float5 = Float.random(20, 21);
console.log(float5); // some fractional number between 20 inclusive and 21 not inclusive.

Float.is()

Returns true if the passed value is an instance of Float or a fractional number primitive.

console.log(
    Float.is(123), // false
    Float.is("12.3"), // false
    Float.is("1.5.5"), // false
    Float.is(float1), // true
    Float.is(float2), // true
    Float.is(float3), // true
);

Float.like()

Returns true in all cases of true for Float.is(), and also if the passed value is a string consisting entirely of a fractional number.

console.log(Float.like("12.3")); // true

How to install

  1. Install the library into your project using the command - npm i float_data_type.
  2. The library uses CommonJS modules. Connect the module to your file as follows: const { Float } = require('float_data_type');