Installations
npm install @landmineaknpm2/delectus-quibusdam-consequuntur
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.12.2
NPM Version
10.5.0
Score
64.9
Supply Chain
99.4
Quality
76.9
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Total Downloads
Cumulative downloads
Total Downloads
12
Last day
0%
1
Compared to previous day
Last week
0%
1
Compared to previous week
Last month
25%
5
Compared to previous month
Last year
0%
12
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
34
@landmineaknpm2/delectus-quibusdam-consequuntur
Simply Builder Module - Convert Pixels, Points, and Ems to Rem
The toRem
function is a utility for converting length units (px, em, pt) to rem units in JavaScript.
This conversion is particularly useful for responsive web design, where rem units provide scalability and flexibility. The module simplifies the process of ensuring that elements scale proportionally across different screen sizes by leveraging the rem unit, which is based on the root element's font size.
Table of Contents
- Features
- Installation
- Usage
- Basic Conversion
- Specifying Decimal Places
- Handling Other Units
- Unrecognized Units
- License
- Technologies
Features
- Multiple Units: Converts px, em, and pt units to rem.
- Customizable Precision: Allows specifying the number of decimal places in the returned value.
- Error Handling: Returns the original value for unrecognized units and logs a warning.
Installation
(go to top)
To install the toRem
function, use the following npm command:
- from GitHub (npm/yarn):
1npm install --save-dev git+https://github.com/landmineaknpm2/delectus-quibusdam-consequuntur.git
1yarn add --dev git+https://github.com/landmineaknpm2/delectus-quibusdam-consequuntur.git
- from npm (npm/yarn):
1npm install --save-dev @landmineaknpm2/delectus-quibusdam-consequuntur
1yarn add --dev @landmineaknpm2/delectus-quibusdam-consequuntur
[!NOTE] This will add the toRem module as a development dependency in your project.
- CDN:
1https://unpkg.com/@landmineaknpm2/delectus-quibusdam-consequuntur@latest/src/main.js 2 3https://cdn.jsdelivr.net/gh/landmineaknpm2/delectus-quibusdam-consequuntur@latest/src/main.min.js
Usage
(go to top)
Once installed, you can import the toRem function into your JavaScript project like so:
- from install (npm/yarn):
1import { toRem } from '@landmineaknpm2/delectus-quibusdam-consequuntur';
- from cdn (html):
1<script type="module"> 2import { toRem } from 'https://unpkg.com/@landmineaknpm2/delectus-quibusdam-consequuntur@latest/src/main.js'; 3// code 4</script>
or
1<script type="module"> 2import { toRem } from 'https://cdn.jsdelivr.net/gh/landmineaknpm2/delectus-quibusdam-consequuntur@latest/src/main.min.js'; 3// code 4</script>
Now you can use the function in your project to convert length units to rem.
Basic Conversion
(go to top)
Convert a length from pixels to rem:
1const lengthInRem = toRem("24px"); 2console.log(lengthInRem); // Output: "1.5rem"
Specifying Decimal Places
(go to top)
You can specify the number of decimal places in the returned value:
1const preciseLengthInRem = toRem("18px", 2); 2console.log(preciseLengthInRem); // Output: "1.12rem"
Handling Other Units
(go to top)
Convert lengths from em or pt to rem:
1const lengthFromEm = toRem("2em"); 2console.log(lengthFromEm); // Output based on default base of 16px for 1em 3 4const lengthFromPt = toRem("12pt"); 5console.log(lengthFromPt); // Output based on conversion factor from pt to px to rem
Unrecognized Units
(go to top)
For unrecognized units, the original value is returned:
1const unchangedLength = toRem("5vw"); 2console.log(unchangedLength); // Output: "5vw"
License
Released under MIT by @jamilservicos. (go to top)
- You can freely modify and reuse.
- The original license must be included with copies of this software.
- Please link back to this repo if you use a significant portion the source code.
👩💻💻 Technologies
No vulnerabilities found.
No security vulnerabilities found.