パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリlemoony/adaptive_number_dart

adaptive_number_dart

lemoony/adaptive_number_dart open-source repository details.

adaptive_number_dart のプロジェクト画像
スター
5
フォーク
1
最終プッシュ(UTC)
2021/09/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 ↗