# strict-cast **Repository Path**: mirrors_TrySound/strict-cast ## Basic Information - **Project Name**: strict-cast - **Description**: Strict type conversion utilities for javascript - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-26 - **Last Updated**: 2025-09-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # strict-cast [![Travis Build Status][travis-img]][travis] [travis-img]: https://travis-ci.org/TrySound/strict-cast.svg [travis]: https://travis-ci.org/TrySound/strict-cast Strict type conversion for javascript. Inspired by [reason string convertion functions](https://reasonml.github.io/api/Pervasives.html#6_Stringconversionfunctions) ## Usage ```js import { float_of_string } from "strict-cast"; float_of_string("10.5"); // 10.5 ``` ## API ```js let string_of_bool: boolean => string; ``` Return the string representation of a boolean. As the returned values may be shared, the user should not modify them directly. ```js let bool_of_string: string => boolean; ``` Convert the given string to a boolean. Raise `Invalid_argument "bool_of_string"` if the string is not "true" or "false". ```js let string_of_float: float => string; ``` Return the string representation of a floating-point number. ```js let float_of_string: string => float; ``` Convert the given string to a float. Raise `Failure "float_of_string"` if the given string is not a valid representation of a float. ## eslint plugin The plugin is used to forbid the usage of unsafe `Number`, `Boolean` and `String` type conversions. ``` yarn add eslint-plugin-strict-cast --dev ``` ```js module.exports = { plugins: ["strict-cast"], rules: { "strict-cast/strict-cast": "error" } }; ```