Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
final-form-calculate
Advanced tools
Decorator for calculating field values based on other field values in 🏁 Final Form
Decorator for 🏁 Final Form that allows you to define calculations that happen between fields, i.e. "When field X changes, update field Y."
npm install --save final-form-calculate
or
yarn add final-form-calculate
import { createForm } from 'final-form'
import createDecorator from 'final-form-calculate'
// Create Form
const form = createForm({ onSubmit })
// Create Decorator
const decorator = createDecorator(
// Calculations:
{
field: 'foo', // when the value of foo changes...
updates: [
{
// ...set field "doubleFoo" to twice the value of foo
doubleFoo: (fooValue, allValues) => fooValue * 2
}
]
},
{
field: /items\[\d+\]/, // when a field matching this pattern changes...
updates: {
// ...sets field "total" to the sum of all items
total: (itemValue, allValues) =>
(allValues.items || []).reduce((sum, value) => sum + value, 0)
}
}
)
// Decorate form
const undecorate = decorator(form)
// Use form as normal
createDecorator: (...calculations: Calculation[]) => Decorator
A function that takes a set of calculations and returns a 🏁 Final Form
Decorator
.
Calculation: { field: FieldPattern, updates: Updates }
A calculation to perform
FieldName: string
FieldPattern: FieldName | RegExp
A pattern to match a field with.
Updates: { [FieldName]: (value: any, allValues: Object) => any }
Updates to make on other fields.
FAQs
Decorator for calculating field values based on other field values in 🏁 Final Form
The npm package final-form-calculate receives a total of 37,691 weekly downloads. As such, final-form-calculate popularity was classified as popular.
We found that final-form-calculate 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.