
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
react-middle-ellipsis
Advanced tools
Put the dots in the middle of a long string, versus the end.
Adding ellipses to the end of long text is cool. But not always! Sometimes the end of the text contains vital information, particularly for URLs or filenames.
This React component is designed with that use case in mind.
yarn add react-middle-ellipsis
Once import
ed, you can then wrap any node with <MiddleEllipsis>
. This will
compute the width of the surrounding parent node. Then, it will look for the
child node (so make sure to add a span
at minimum internally): it will use
this element to compute the width of the child, and then shorten the text
element whose class is ellipseMe
(optional) to fit within the parent.
The component re-computes things if the browser window is resized, too!
import React from "react";
import MiddleEllipsis from "react-middle-ellipsis";
const Component = props => {
return (
<>
<div style={{ width: "350px", whiteSpace: "nowrap" }}>
<MiddleEllipsis>
<span>
I am some long text that should be ellipsed in the middle because
the end contains important stuff.
</span>
</MiddleEllipsis>
</div>
<div style={{ width: "350px", whiteSpace: "nowrap" }}>
<MiddleEllipsis>
<span>
Don't ellipse me.{" "}
<span className="ellipseMe">
I am some long text that should be ellipsed in the middle because
the end contains important stuff.
</span>
</span>
</MiddleEllipsis>
</div>
<>
);
};
export default Component;
Notes for developing this component.
yarn && yarn run start
in this directory and separately also in /example
.
This will live reload any changes made in /src
.
Change the version number in package.json
and npm publish
once
complete.Then, go to Github Releases and follow the instructions to publish a
new version there too.
MIT © bluepeter
FAQs
Put the dots in the middle of a long string, versus the end.
The npm package react-middle-ellipsis receives a total of 8,612 weekly downloads. As such, react-middle-ellipsis popularity was classified as popular.
We found that react-middle-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
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.