Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@flourish/pocket-knife
Advanced tools
A module with handy tools that you can use in Flourish templates.
import { isUrl, isImage } from "@flourish/pocket-knife"
Create a temporary SVG element that can be used in the SVG export. Takes a target
element, which it uses to set the boundaries and position of the main svg container; and an id
which is used to set a unique id of the SVG element.
This function returns an .addTextElements(els)
, .addCircleElements(els)
, .addGradient(el, colorFunction, domain)
, and .remove()
method. .remove()
will remove the SVG. addTextElements
takes a node list (els
) and will convert them to an SVG <text>
elements, incorporating the element's font styles and line height. Similarly, addCircleElements
takes elements (e.g. divs with a background color) and converts them to SVG <circle>
elements. addGradient
takes an element, a color function, and a domain; the domain should be an object with a min
and max
representing the starting and ending values the gradient represents, and the color function should take a number within the domain and return the color which represents that number.
This function can be used in the template's screenshot()
function to temporarily create an SVG that will be included in the SVG export.
Gets dimensions of text. First argument contains the text you want to calculate the width for. The second argument is optional and lets you set font settings for the text in the standard css font property, eg. bold 16px arial
. If font
is empty, it uses 10px sans-serif
. Returns an object with properties width
and height
.
Gets computed text direction on document.body. Returns a "ltr" or "rtl".
Gets height of text. Uses same arguments as getTextDimensions
. Returns a number.
Gets width of text. Uses same arguments as getTextDimensions
. Returns a number.
Gets all the unique values in a column associated to a data binding. If it is a multi column binding you can pass in index that is used to work out which of the bound columns it should look at. If you pass it no index and it is a multi column binding it will default to zero.
Converts hex to d3 color object as described here
hexToColor("#00ff00", 0.5); // {r: 0, g: 255, b: 0, a: 0.5}
Converts hex to rgba string
hexToRgba("#00ff00", 0.5); // rgba(0, 255, 0, 0.5)
Checks if string looks like valid image URL. Returns true
or false
Returns if color is pale or not
Checks if string looks like valid URL. Returns true
or false
Converts value specified in rems to px
Takes a string, and returns an array of strings where each string is one lines worth of text.
FAQs
Flourish module with handy tools
The npm package @flourish/pocket-knife receives a total of 162 weekly downloads. As such, @flourish/pocket-knife popularity was classified as not popular.
We found that @flourish/pocket-knife demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.