![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
formula-store
Advanced tools
A package to handle formula calculations and dependency management
A versatile and efficient package for managing and calculating formula fields in a store.
🧮 formula-store
is a TypeScript library designed to provide a flexible solution for handling formula fields. It enables you to manage dependencies, calculate values, and receive updates seamlessly. This package is well-suited for scenarios where dynamic formula-based computations are crucial and performance and robust api design matters.
yarn add formula-store
npm install formula-store
Initialize a FormulaStore
to manage and update formula fields.
import { createFormulaStore } from "formula-store";
// Example Usage:
const store = createFormulaStore({
onChange: updates => {
// Handle updates when formula fields change.
}
});
Create instances of FormulaField
representing the formula fields you want to manage in your store.
import { FormulaField, FormulaStore } from "formula-store";
// Example Usage:
const myFormulaField: FormulaField<number> = {
id: "uniqueId",
value: 42,
dependencies: ["dependencyA", "dependencyB"],
calculate: (dependencyA, dependencyB) => dependencyA + dependencyB
};
Utilize the store to manage formula fields and receive updates.
// Example Usage:
// Add fields for dependencies.
store.addField({
dependencies: [],
id: "a",
value: 1
});
store.addField({
dependencies: [],
id: "b",
value: 3
});
store.addField({
dependencies: ["a", "b"],
id: "c",
value: 0,
calculate: (a, b) => a + b
});
// Update the values of formula fields in the store.
store.updateFieldsValue([
{ id: "a", value: 2 }
// Add more updates as needed.
]);
// Remove a formula field from the store.
const affectedFields = store.removeField("a");
console.log("Affected Fields: ", affectedFields);
// Edit a store field.
store.editField({
dependencies: ["a", "b"],
id: "c",
value: 0,
calculate: (a, b) => a + b
});
// Get previously added field.
const fieldA = store.getFieldById("a");
console.log("Field a: ", fieldA);
FormulaField<T>
Represents a field that is either a direct formula or a field that will be used inside another formula.
id
: Unique identifier for the formula field.value
: The current value of the formula field.dependencies
: An array of other formula field ids representing the dependencies of the formula field.calculate
: A function that calculates the new value based on the provided dependencies. (Optional)FormulaUpdate
Represents an update for a formula field in the store.
id
: Unique identifier for the formula field to be updated.value
: The new value for the formula field.FormulaStoreInput
Represents the input configuration for the FormulaStore.
onChange
: A callback function to be called when formula fields are updated.FormulaStore
Represents a store for managing formula fields.
addField
: Adds a new formula field to the store.editField
: Edits a formula previously added to the store.removeField
: Removes a formula field from the store based on its identifier.updateFieldsValue
: Updates the values of multiple formula fields in the store.getFieldById
: Gets a field from the store by id.Contributions are welcome! Please submit a pull request with any improvements or bug fixes. Make sure to add tests for any new features and bug fixes, and ensure that the existing tests pass.
This project is licensed under the MIT License.
If you need help or have questions, feel free to open an issue in the GitHub repository.
FAQs
A package to handle formula calculations and dependency management
The npm package formula-store receives a total of 8 weekly downloads. As such, formula-store popularity was classified as not popular.
We found that formula-store demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.