Skip to content

Commit

Permalink
Generate Bits prefixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
haimkastner committed May 18, 2024
1 parent 619d18a commit c8c0e3b
Show file tree
Hide file tree
Showing 6 changed files with 860 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
yarn run cover
- name: Publish to Coveralls
uses: coverallsapp/github-action@v1.1.2
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
23 changes: 22 additions & 1 deletion generator-scripts/src/models/units-definition.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
export declare type Prefix = 'Nano' | 'Micro' | 'Milli' | 'Centi' | 'Deci' | 'Deca' | 'Hecto' | 'Kilo' | 'Mega' | 'Giga' | 'Tera' | 'Peta' | 'Pico' | 'Exa' | 'Femto';
export declare type Prefix =
'Nano'
| 'Micro'
| 'Milli'
| 'Centi'
| 'Deci'
| 'Deca'
| 'Hecto'
| 'Kilo'
| 'Mega'
| 'Giga'
| 'Tera'
| 'Peta'
| 'Pico'
| 'Exa'
| 'Femto'
| 'Kibi'
| 'Mebi'
| 'Gibi'
| 'Tebi'
| 'Pebi'
| 'Exbi';

export declare interface Abbreviation {
Culture: string;
Expand Down
14 changes: 13 additions & 1 deletion generator-scripts/src/units-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const prefixesFactor: { [key in Prefix]: number } = {
Nano: 1e-9,
Pico: 1e-12,
Femto: 1e-15,
Kibi: 1024,
Mebi: Math.pow(1024, 2),
Gibi: Math.pow(1024, 3),
Tebi: Math.pow(1024, 4),
Pebi: Math.pow(1024, 5),
Exbi: Math.pow(1024, 6),
};

const prefixesAbbreviation: { [key in Prefix]: string } = {
Expand All @@ -39,7 +45,13 @@ const prefixesAbbreviation: { [key in Prefix]: string } = {
Micro: 'μ',
Nano: 'n',
Pico: 'p',
Femto: 'f'
Femto: 'f',
Kibi: 'KiB',
Mebi: 'MiB',
Gibi: 'GiB',
Tebi: 'TiB',
Pebi: 'PiB',
Exbi: 'EiB',
};

/**
Expand Down
Loading

0 comments on commit c8c0e3b

Please sign in to comment.