Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@balena/balena-pricing
Advanced tools
This library provides a set of functions that can be used to calculate credit purchase costs and savings when compared to dynamic billing. Credit pricing definitions can be passed in during instantiation, useful for testing and experimentation, but pricing definitions used in production are also defined within this package.
import { CreditPricing } from '@balena/balena-pricing';
// Format output to dollar currency.
const dollar = Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});
function toDollar(pennies: number): string {
return dollar.format(pennies / 100);
}
// Set dynamic base price.
const dynamicPrice = 150;
// Use production credit pricing definitions.
let pricing = new CreditPricing();
// Use production credit pricing definitions.
// Explicitly target current versions (default).
let pricing = new CreditPricing({
target: 'current',
});
// Use production credit pricing definitions.
// Target most recent versions, even those slated for future use.
pricing = new CreditPricing({
target: 'latest',
});
// Use production credit pricing parameters.
// Target version 2, will return undefined for features without a version 2.
let pricing = new CreditPricing({
target: 2,
});
// Use production credit pricing parameters.
// Target most recent versions valid up to a given date.
let pricing = new CreditPricing({
target: new Date('2023-03-01T00:00:00Z'),
});
// Use custom credit pricing parameters.
// Mostly useful for testing parameters against the curve,
// should not normally be used in production.
pricing = CreditPricing({
credits: {
'foo:bar': [
{
version: 1,
validFrom: new Date('2023-02-01T00:00:00Z'),
basePriceCents: 150,
firstDiscountPriceCents: 149,
discountRate: 0.33,
discountThreshold: 12000,
discountThresholdPriceCents: 125,
},
],
},
});
// Get individual credit price
const creditPrice = pricing.getCreditPrice('foo:bar', 0, 1000);
console.log('Credit unit price:', toDollar(creditPrice));
// Get total price for credit purchase
const totalPrice = pricing.getCreditTotalPrice('foo:bar', 0, 1000);
console.log('Credit total price:', toDollar(totalPrice));
// Get discount percentage compared to dynamic
const discount = pricing.getDiscountOverDynamic('foo:bar', 0, 1000, dynamicPrice);
console.log('Discount over dynamic:', `${discount}%`);
// Get total savings for credit purchase compared to dynamic
const totalSavings = pricing.getTotalSavings('foo:bar', 0, 1000, dynamicPrice);
console.log('Total savings:', toDollar(totalSavings));
1.3.0 - 2023-03-28
FAQs
Balena pricing/savings calculators
The npm package @balena/balena-pricing receives a total of 1,144 weekly downloads. As such, @balena/balena-pricing popularity was classified as popular.
We found that @balena/balena-pricing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.