
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
canvas-string-ellipsis
Advanced tools
通过 canvas 测量文字长度,超过长度则使用省略号
有时候我们不得不手动根据长度测量截取字符串,那么这个时候这个就很有用
npm i canvas-string-ellipsis -S
import cse from 'canvas-string-ellipsis';
const str = 'canvas-string-ellipisis';
const [res, sliced, width] = cse(str, 100)
// res: canvas-string-ellipisis
// sliced: false
// width: 96
const [res2, sliced2, width2] = cse(str, 50)
// res: canvas-stri...
// sliced: true
// width: 50
function cse(str: string, maxWidth: number, font?: string): [string, boolean, number]
原始字符串
长度
canvas font 设置,默认为 14px sans-serif
返回值有三个组成一个数组,分别为截取后的字符串,是否截取,真实宽度
1.0.1 (2020-02-20)
<a name="1.0.0"></a>
FAQs
通过 canvas 测量文字长度,超过长度则使用省略号
The npm package canvas-string-ellipsis receives a total of 0 weekly downloads. As such, canvas-string-ellipsis popularity was classified as not popular.
We found that canvas-string-ellipsis 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.