New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@flourish/pocket-knife

Package Overview
Dependencies
Maintainers
10
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flourish/pocket-knife - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

5

package.json
{
"name": "@flourish/pocket-knife",
"version": "0.4.0",
"version": "0.5.0",
"description": "Flourish module with handy tools",

@@ -31,3 +31,6 @@ "main": "pocket-knife.js",

"*.js": "eslint src"
},
"dependencies": {
"d3-color": "^1.4.0"
}
}

14

README.md

@@ -16,2 +16,14 @@ # Flourish pocket knife

### getTextWidth(string, font)
Gets width 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. `16px arial bold`. If `font` is empty, it uses `10px sans-serif`.
Gets width 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. `16px arial bold`. If `font` is empty, it uses `10px sans-serif`.
### hexToColor(hex_string, opacity)
Converts hex to d3 color object as described [here](https://github.com/d3/d3-color#color)
```
hexToColor("#00ff00", 0.5); // {r: 0, g: 255, b: 0, a: 0.5}
```
### hexToRgba(hex_string, opacity)
Converts hex to rgba string
```
hexToRgba("#00ff00", 0.5); // rgba(0, 255, 0, 0.5)
```

@@ -0,1 +1,5 @@

### 0.5.0
* Add `hexToColor()`
* Add `hexToRgba()`
### 0.4.0

@@ -2,0 +6,0 @@ * Recognise `data:` URIs in the `isUrl()` and `isImage()` functions

@@ -0,1 +1,3 @@

import { color } from "d3-color";
var getTextWidth = (function() {

@@ -20,2 +22,15 @@ var context = document.createElement("canvas").getContext("2d");

export { getTextWidth, isImage, isUrl }
function hexToColor(hex_string, opacity) {
if (typeof hex_string != "string") return false;
var c = color(hex_string);
c.opacity = opacity !== undefined ? opacity : 1;
return c;
}
function hexToRgba(hex_string, opacity) {
var c = hexToColor(hex_string, opacity);
return c ? c.toString() : false;
}
export { getTextWidth, isImage, isUrl, hexToColor, hexToRgba };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc