
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@lweb-utils/string
Advanced tools
字符串相关工具函数
npm i @lweb-utils/string --save
fixedZero(number)
生成两位数字格式的字符串,如06
,12
。
number(number): 需要生成的数字。
(string): 生成的两位数字符串。
const num1 = fixedZero(8);
// '08'
const num2 = fixedZero(16);
// '16'
numberWithCommas(number, decimal)
生成逗号分隔的三位数格式字符串。
number(string): 纯数字或小数点组成的字符串。 decimal(number): 小数位数。
(string): 逗号分隔的数字字符串。
// 使用默认小数位数
const result = numberWithCommas('1234567');
// '1,234,567.00'
const result = numberWithCommas('1234567.1234');
// '1,234,567.12'
// 指定小数位数
const result = numberWithCommas('1234567.1234', 3);
// '1,234,567.123'
percentStr(number, decimal)
数字字符串转换成百分比格式。
number(string|number): 需要转换的数字或字符串。 decimal(number): 转换成百分比后小数位数。
(string): 百分比格式的字符串。
// 使用默认小数位数
percentStr(0.123);
// '12.30%'
// 指定小数位数
percentStr(0.123, 1);
// '12.3%'
randomStr(length)
生成指定长度的随机字符串。
length(number): 随机字符串的长度,默认为4。
(string): 随机字符串,包含大小写字母和数字。
// 使用默认长度
const str = randomStr();
// '4Ex6'
// 使用指定长度
const str = randomStr(6);
// '5r8DdU'
toCapital(string)
字符串转换成首字母大写的格式。
string(string): 字符串。
(string): 首字母大写的字符串。
const str = toCapital('abcd');
// 'Abcd'
FAQs
@lweb-utils/string
The npm package @lweb-utils/string receives a total of 1 weekly downloads. As such, @lweb-utils/string popularity was classified as not popular.
We found that @lweb-utils/string demonstrated a not healthy version release cadence and project activity because the last version was released 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
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.