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

@evidence-dev/component-utilities

Package Overview
Dependencies
Maintainers
4
Versions
384
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evidence-dev/component-utilities - npm Package Compare versions

Comparing version 0.0.0-45452685 to 0.0.0-45593986

CHANGELOG.md

4

package.json
{
"name": "@evidence-dev/component-utilities",
"version": "0.0.0-45452685",
"version": "0.0.0-45593986",
"description": "",

@@ -22,3 +22,3 @@ "main": "index.js",

"ssf": "^0.11.2",
"svelte": "^3.59.1"
"svelte": "3.55.0"
},

@@ -25,0 +25,0 @@ "scripts": {

@@ -7,2 +7,3 @@ import ssf from 'ssf';

import { standardizeDateString } from './dateParsing';
import { inferValueType } from './inferColumnTypes';

@@ -49,2 +50,29 @@ const AXIS_FORMATTING_CONTEXT = 'axis';

/**
* Returns an Evidence format object to be used in the applyFormatting function
* @param {string} formatString string containing an Excel-style format code, or a format name matching a built-in or custom format
* @param {string} valueType optional - a string representing the data type within the column that will be formatted ('number', 'date', 'boolean', or 'string)
* @returns a format object based on the formatString matching a built-in or custom format name, or a new custom format object containing an Excel-style format code
*/
export function getFormatObjectFromString(formatString, valueType = undefined) {
let potentialFormatTag = formatString;
let customFormats = getCustomFormats();
let matchingFormat = [...BUILT_IN_FORMATS, ...customFormats].find(
(format) => format.formatTag?.toLowerCase() === potentialFormatTag?.toLowerCase()
);
let newFormat = {};
if (matchingFormat) {
return matchingFormat;
} else {
newFormat = {
formatTag: 'custom',
formatCode: potentialFormatTag
};
if (valueType) {
newFormat.valueType = valueType;
}
return newFormat;
}
}
export const formatValue = (value, columnFormat = undefined, columnUnitSummary = undefined) => {

@@ -140,2 +168,3 @@ try {

}
let result = undefined;

@@ -205,1 +234,14 @@ if (columnFormat) {

}
/**
* Formats a value to whichever format is passed in
* @param {*} value the value to be formatted
* @param {string} format string containing an Excel-style format code, or a format name matching a built-in or custom format
* @returns a formatted value
*/
export function fmt(value, format) {
let formatObj = getFormatObjectFromString(format);
let valueType = inferValueType(value);
formatObj.valueType = valueType;
return formatValue(value, formatObj);
}

@@ -17,3 +17,3 @@ // To-do, replace with import from db-commons

const inferValueType = function (columnValue) {
export const inferValueType = function (columnValue) {
if (typeof columnValue === 'number') {

@@ -20,0 +20,0 @@ return EvidenceType.NUMBER;

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