पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv1.0.0

adaptive_number

एक एडाप्टिव नंबर के कार्यान्वयन प्रदान करने वाली लाइब्रेरी। JS रनटाइम में, 64-बिट साइन्ड फिक्स्ड-विड्थ पूर्णांक का उपयोग किया जाएगा और सभी अन्य प्लेटफॉर्म के लिए डार्ट के डिफ़ॉल्ट int डेटा प्रकार का उपयोग किया जाएगा।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
7 लाख
लाइक
2
Pub अंक
150

पैकेज इंस्टॉल करें

flutter pub add adaptive_number

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

adaptive_number पैकेज एक संख्या प्रकार प्रदान करता है जो रनटाइम वातावरण के अनुसार अनुकूलित होता है। JavaScript प्लेटफॉर्म पर, यह एक 64-बिट साइन्ड फिक्स्ड-विड्थ पूर्णांक का उपयोग करता है जिससे स्थिर अचूकता मिलती है, जबकि अन्य सभी प्लेटफॉर्म पर यह डार्ट के मूल int के रूप में डिफ़ॉल्ट होता है। यह वेब और नेटिव वातावरणों में विश्वसनीय व्यवहार सुनिश्चित करता है, विशेष रूप से बड़े पूर्णांकों के साथ काम करने या संख्यात्मक संचालन में क्रॉस-प्लेटफॉर्म सुसंगतता की आवश्यकता होने पर।

उपयोग

  • क्रॉस-प्लेटफ़ॉर्म पूर्णांक हैंडलिंग
  • बड़ी संख्या वाले वेब-आधारित एप्लिकेशन
  • प्लेटफॉर्म के आसपास सुसंगत अंकगणित
  • पूर्णांक के लिए डेटा सीरियलाइजेशन
  • Flutter वेब ऐप में संख्यात्मक गणना

मुख्य विशेषताएँ

  • प्लेटफॉर्म के आधार पर अनुकूलित पूर्णांक आकार
  • JS पर 64-बिट निर्धारित चौड़ाई के पूर्णांक
  • गैर-JS प्लेटफ़ॉर्म पर मूल int का फॉलबैक
  • रनटाइम्स के माध्यम से एकसमान व्यवहार
  • मौजूदा कोड के साथ सरल एकीकरण

इनके लिए उपयुक्त

  • वेब और नेटिव प्लेटफॉर्म के लिए डेवलपर्स
  • सटीक पूर्णांक अंकगणित की आवश्यकता वाले एप्स
  • संख्यात्मक तर्क के पोर्टेबिलिटी की आवश्यकता वाले प्रोजेक्ट
  • JS-विशेष संख्या सीमाओं से बचने वाले टीम्स
  • साझा व्यापार तर्क के साथ Flutter ऐप्स

विचार योग्य बातें

  • केवल पूर्णांक मानों तक सीमित
  • तैरते बिंदु संख्याओं का समर्थन नहीं है
  • गैर-JS प्लेटफॉर्म पर प्रदर्शन अतिरिक्त बोझ
  • सरल उपयोग के लिए आवश्यक नहीं हो सकता है
  • JS लक्ष्य पर सावधानीपूर्वक परीक्षण की आवश्यकता होती है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

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.

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 1 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट