
Research
/Security News
11 Malicious NuGet Tools Pose as Game Cheats to Drop a Windows Host-Surveillance Payload
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.
@sohu-bpd/utils
Advanced tools
Frontend utility library for common development tasks.
npm install @sohu-bpd/utils
# or
pnpm add @sohu-bpd/utils
# or
yarn add @sohu-bpd/utils
import { px2vw, px2px } from '@sohu-bpd/utils'
// or
const { px2vw, px2px } = require('@sohu-bpd/utils')
<script src="https://unpkg.com/@sohu-bpd/utils/dist/index.global.js"></script>
<script>
const { px2vw, px2px } = SohuUtils
</script>
将设计稿的 px 值转换为 vw 单位字符串,适用于响应式布局。
function px2vw(
px: number,
designWidth?: number,
unitPrecision?: number
): string
Parameters:
px - 设计稿上的 px 值designWidth - 设计稿基准宽度,默认 750unitPrecision - 小数位精度,默认 5Returns: vw 单位字符串,如 "13.33333vw"
Example:
import { px2vw } from '@sohu-bpd/utils'
// 基于 750px 设计稿
px2vw(100) // "13.33333vw"
px2vw(375) // "50vw"
// 基于 375px 设计稿
px2vw(100, 375) // "26.66667vw"
// 自定义精度
px2vw(100, 750, 2) // "13.33vw"
将设计稿的 px 值转换为当前屏幕的实际像素值,适用于 Canvas、动态计算等场景。
function px2px(px: number, designWidth?: number): number
Parameters:
px - 设计稿上的 px 值designWidth - 设计稿基准宽度,默认 750Returns: 实际像素值(number)
Example:
import { px2px } from '@sohu-bpd/utils'
// 假设当前屏幕宽度为 375px
px2px(100) // 50
px2px(750) // 375
// 基于 375px 设计稿
px2px(100, 375) // 100
This package is written in TypeScript and includes type definitions out of the box.
import type { } from '@sohu-bpd/utils'
// All functions are fully typed
const vwValue: string = px2vw(100)
const pxValue: number = px2px(100)
.mjs) - Modern JavaScript modules.js) - Node.js and bundlers.global.js) - Browser <script> tag with global SohuUtilspx2vw and px2px utilitiesMIT
FAQs
Frontend utility library
We found that @sohu-bpd/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.

Research
/Security News
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.