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

design-size-convertor

v1.0.2

Published

Calculate real dimention according the design dimention, support px/rem/ etc. 根据设计长度算出特定宽度下的对应长度。

Downloads

25

Readme

css 长度单位转换器

对传入字符串进行正则替换,可以按顺序执行多个步骤,不 star 一个吗? (https://github.com/LiangWei88/Design-size-convertor)

单位转换

  • 一个单位按比例转换为另一个单位,如 16px, 转换为 rem 按照 1 像素等于 0.01 rem 的比值,保留 2 位小数,得出 0.16rem

等比数字转换

  • 同一个单位相互转换,如 640px 设计稿中的 16px 转换为 750px 设计稿中的数字,保留 0 位小数,得出 19px

注意

  • 满足下列几种格式,16px; 或 16px 16px 或 16px}
  • 即单位后必须带空格或分号或花括号
/*错误写法*/
.test {
    width:16px
}

/*正确写法, 三种都可以*/
.test {
    width:16px;
    margin: 16px 22px;
    font-size: 32px}

使用方法

直接使用

  • npm i --save design-size-convertor
  • node node_modules/design-size-convertor/index.js

快捷脚本

npm i --save design-size-convertor 安装完,
可以把 node node_modules/design-size-convertor/index.js 放入到你的 package.json 的 script 里面

"script" : {
    "dsc": "node node_modules/design-size-convertor/index.js"
} 

然后使用 npm run dsc

下载压缩包

到 github 上面直接下载 然后运行 node index.js

直接使用,不 star 一个吗?

github page

TODO

  1. 做成 webpack loader