UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

28 lines (23 loc) 501 B
'use strict'; /*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ // src/fromString2Primitive.ts function fromStringToPrimitives(value) { if (typeof value !== "string") { return value; } if (value.match(/^[+-]?(?:\d*\.)?\d+$/)) { return Number(value); } if (value === "true") { return true; } if (value === "false") { return false; } return value; } exports.fromStringToPrimitives = fromStringToPrimitives;