Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@anchor-protocol/notation
Advanced tools
Readme
@anchor-protocol/notation
TODO
import { aUST, bLuna, Luna, Percent, Rate, UST } from '@anchor-protocol/types';
import {
formatAUST,
formatAUSTInput,
formatAUSTWithPostfixUnits,
formatLuna,
formatLunaInput,
formatPercentage,
formatRate,
formatUST,
formatUSTInput,
formatUSTWithPostfixUnits,
} from '../';
describe('notation', () => {
test('should format numbers to the correct strings', () => {
expect(formatUST('1.342131' as UST)).toBe('1.342');
expect(formatUST('1.12049312' as UST)).toBe('1.12');
expect(formatUST('1.10049312' as UST)).toBe('1.1');
expect(formatUST('0.0001' as UST)).toBe('<0.001');
expect(formatAUST('1.00049312' as aUST)).toBe('1.000493');
expect(formatAUST('1000.1234000' as aUST)).toBe('1,000.1234');
expect(formatAUST('1000.120000' as aUST)).toBe('1,000.12');
expect(formatUSTWithPostfixUnits('1342131' as UST)).toBe('1.34M');
expect(formatUSTWithPostfixUnits('1342131.34432' as UST)).toBe('1.34M');
expect(formatUSTWithPostfixUnits('1100493' as UST)).toBe('1.1M');
expect(formatUSTWithPostfixUnits('1100493.2435' as UST)).toBe('1.1M');
expect(formatUSTWithPostfixUnits('11103452' as UST)).toBe('11.1M');
expect(formatUSTWithPostfixUnits('1000345' as UST)).toBe('1M');
expect(formatUSTWithPostfixUnits('1000345000' as UST)).toBe('1,000.34M');
expect(formatAUSTWithPostfixUnits('10003450' as aUST)).toBe('10.003M');
expect(formatAUSTWithPostfixUnits('1120.33434' as aUST)).toBe(
'1,120.33434',
);
expect(formatAUSTWithPostfixUnits('1123.4000' as aUST)).toBe('1,123.4');
expect(formatAUSTWithPostfixUnits('1120.000' as aUST)).toBe('1,120');
expect(formatAUSTWithPostfixUnits('1000' as aUST)).toBe('1,000');
expect(formatAUSTWithPostfixUnits('1010' as aUST)).toBe('1,010');
expect(formatLuna('1.342131' as Luna)).toBe('1.342131');
expect(formatLuna('1.12049312' as Luna)).toBe('1.120493');
expect(formatLuna('1.1004000' as Luna)).toBe('1.1004');
expect(formatLuna('1.00049312' as bLuna)).toBe('1.000493');
expect(formatLuna('1000.1234000' as bLuna)).toBe('1,000.1234');
expect(formatLuna('1000.120000' as bLuna)).toBe('1,000.12');
expect(formatPercentage('1.342131' as Percent)).toBe('1.34');
expect(formatPercentage('1.12049312' as Percent)).toBe('1.12');
expect(formatPercentage('1.1004000' as Percent)).toBe('1.1');
expect(formatPercentage('1.00049312' as Percent)).toBe('1');
expect(formatPercentage('1000.1234000' as Percent)).toBe('1,000.12');
expect(formatPercentage('1000.120000' as Percent)).toBe('1,000.12');
expect(formatPercentage('-1000.120000' as Percent)).toBe('-1,000.12');
expect(formatRate('0.00725188639837987036' as Rate)).toBe('0.72');
expect(formatRate('-0.00725188639837987036' as Rate)).toBe('-0.72');
expect(formatUSTInput('10.3436' as UST)).toBe('10.343');
expect(formatAUSTInput('10.00' as aUST)).toBe('10');
expect(formatLunaInput('10.3436' as Luna)).toBe('10.3436');
expect(formatLunaInput('10.00' as bLuna)).toBe('10');
});
test('error cases', () => {
expect(formatRate('0.195545188517526138' as Rate)).toBe('19.55');
});
});
https://anchor-storybook.vercel.app/?path=/story/components-animatenumber--basic
__stories__/AnimateNumber.stories.tsx
import {
AnimateNumber,
formatUSTWithPostfixUnits,
} from '@anchor-protocol/notation';
import { UST } from '@anchor-protocol/types';
import { useCallback, useState } from 'react';
export default {
title: 'components/AnimateNumber',
};
export const Basic = () => {
const [n, setN] = useState<UST>('1000' as UST);
const updateNumber = useCallback(() => {
setN(
Math.floor(
Math.random() * (Math.random() > 0.5 ? 100000000 : 100000),
).toString() as UST,
);
}, []);
return (
<div>
<AnimateNumber format={formatUSTWithPostfixUnits}>{n}</AnimateNumber>
<div>
<button onClick={updateNumber}>Update Number</button>
</div>
</div>
);
};
FAQs
TODO
The npm package @anchor-protocol/notation receives a total of 6 weekly downloads. As such, @anchor-protocol/notation popularity was classified as not popular.
We found that @anchor-protocol/notation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.