패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소lemoony/adaptive_number_dart

adaptive_number_dart

lemoony/adaptive_number_dart open-source repository details.

adaptive_number_dart 프로젝트 이미지
스타
5
포크
1
최근 푸시(UTC)
2021. 9. 16.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

adaptive_number

pub package Language Build codecov

A library providing a Number implementation that is dependent on the platform it is compiled for. For JS runtimes, the implementation uses a 64-bit signed fixed-width integer, for all other platforms the default Dart int data type.

Use cases of this library

The Number substitute is useful in situations where a value may overflow on JS runtimes since the available value range is not the same compared to mobile or desktop platforms:

https://api.dart.dev/stable/2.8.4/dart-core/int-class.html

The overflow on JS environments can be circumvented by using a BigInt or the fixed-with implementation of this library: https://pub.dev/packages/fixnum

The disadvantage of just replacing all usages of int with BigInt or fixnum/Int64 is that the performance on mobile platforms may suffer significantly.

The adpative_number library takes a conditional import approach to ease this problem:

  • If it runs on a JS runtime, Number wraps a fixnum/Int64
  • For all other platforms Number wraps a default Dart int type.

Some historical background of this library can also be seen in: https://github.com/MixinNetwork/libsignal_protocol_dart/pull/43

Usage

A Number instance is created by wrapping it around a default int value:

import 'package:adaptive_number/adaptive_number.dart';

void main() {
  final number1 = Number(93432);
  final number2 = Number(42435);
  assert((number1 + number2) == Number(51777));
}

All other operations on Number behave the same way as with int.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Philipp Seßler GitHub avatar
GitHub 작성자

Philipp Seßler ↗

iteratec GmbHMunich
언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개

  • fixnum^1.0.0
  • pedantic개발 의존성^1.10.0
  • test개발 의존성^1.16.0

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗