Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
ember-computed-convert-unit
Advanced tools
Provides unit conversion as a computed property wrapper around convert-units
ember-computed-convert-unit is made for ember 3.12 and above, but probably works for older versions too.
ember install ember-computed-convert-unit
convertUnit is a computed property that you can use in the same way as you normally would do. It works for both 'classic' Ember and Ember Octane. To indicate a unit, you can use both the full name and the abbreviation of a unit. (e.g. 'kg'/'kilograms', 'ft'/'feet')
import Model from '@ember-data/model';
import convertUnit from 'ember-computed-convert-unit'
export default Model.extend({
lengthInMilimeters: attr('number'),
lengthInCentimeters: convertUnit('lengthInMilimeters', 'milimeters', 'centimeters')
})
import Model from '@ember-data/model';
import convertUnit from 'ember-computed-convert-unit'
export default class Paper extends Model {
@attr('number')
lengthInMilimeters;
@convertUnit('lengthInMilimeters', 'milimeters', 'centimeters')
lengthInCentimeters;
}
This addon uses convert-units to perform the actual conversion. Check its documentation for available conversions.
It's possible to add (or "overwrite") a conversion as shown in the example below. If you add a conversion for a type that's included in the library, you must use the abbreviation. In the example below feet/ft already exists as a type and TEU doesn't.
// utils/computed-convert-unit.js
export default [
{
from: 'ft',
to: 'TEU',
convert(value) {
return value / 20;
}
},
{
from: 'TEU',
to: 'ft',
convert(value) {
return value * 20;
}
}
];
// models/rock.js
import Model from '@ember-data/model';
import convertUnit from 'ember-computed-convert-unit'
export default class Rock extends Model {
@attr('number')
lengthInFeet;
@convertUnit('lengthInMilimeters', 'feet', 'TEU')
volumeInTeu;
}
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
Use convert unit as computed property or decorator
The npm package ember-computed-convert-unit receives a total of 7 weekly downloads. As such, ember-computed-convert-unit popularity was classified as not popular.
We found that ember-computed-convert-unit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.