p-hatan/ mirror

pub repository

mirror.p-hatan.com

sprintf

7.0.0

Dart implementation of sprintf. Provides simple printf like formatting such as sprintf("hello %s", ["world"]);

Download archive

Readme

dart-sprintf

Dart implementation of sprintf.

Build Status

ChangeLog

ChangeLog.md

Getting Started

Add the following to your pubspec.yaml:

dependencies:
  sprintf: "^7.0.0"

then run pub install.

Next, import dart-sprintf:

import 'package:sprintf/sprintf.dart';

Example

import 'package:sprintf/sprintf.dart';

void main() {
	print(sprintf("%04i", [-42]));
	print(sprintf("%s %s", ["Hello", "World"]));
	print(sprintf("%#04x", [10]));
}
-042
Hello World
0x0a

Limitations

  • Negative numbers are wrapped as 64bit ints when formatted as hex or octal.

Differences to C's printf

  • When using fixed point printing of numbers with large exponents, C introduces errors after 20 decimal places. Dart-printf will just print 0s.
Changelog

v7.0.0 (2022-09-30)

* properly format Infinity and NaN for %f and %G  (#33)

v6.0.2 (2022-08-10)

* pub policy compliance

v6.0.1 (2022-02-24)

* Upgrade analyze package to dart:lint
* code formatting

v6.0.0 (2021-03-04)

* Promote null-safety to stable

v6.0.0-nullsafety (2020-12-10)

* Add null-safety support

v5.0.0 (2020-09-25)

* Fix #22: position arguments didn't work. Major version bump because it's
  a different API. The following now works:
  ```
  sprintf('|%2\$d %2\$d %1\$d|', [5, 10]); // '|10 10 5|'
  ```

v4.1.0 (2020-07-26)

* Used dart padentic to fix up some code
* changed SDK requirements to be >=2, <3

v4.0.3 (2020-07-26)

* Fixed formatting of "1.0" (#18); it was being truncated to "1" and then
  failing the regex.

v4.0.2 (2019-02-19)

* Fixed v4.0.1
* Fixed rounding bug if 0 or 1 digits of rounding are requested (#15)

v4.0.1 (2019-02-19)

* **BROKEN** Fixed rounding bug if 0 or 1 digits of rounding are requested (#15)

v4.0.0 (2018-07-02)

* **Breaking change** (#13)
  As of dart 2, int types are going to be fixed width, and the width depends on
  implementation (dart2js vs dartvm). Dart started warning about constants that
  are greater than the max int of javascript. To fix that, this patch will limit
  int (when formatted as hex or octal) to the max limit of javascript (2**53 - 1).
  Any int outside of the +-(2**53 -1) range is not guaranteed to format correctly!

v3.0.2 (2017-08-17)

* Fixed bad publish

v3.0.1 (2017-08-17)

* Fixed weak typing which stopped dartdevc from working (#11 thanks @bergwerf)

v3.0.0 (2017-04-20)

* Fixed rounding of floats, again. Bumping major version because it's different from previous behaviour

v2.0.0 (2017-03-23)

* Fixed rounding of floats. Bumping major version, because previous behaviour was to always round down.

v1.1.1 (2016-11-16)

* Updated to use `test` library since `unittest` has been deprecated.

v1.1.0 (2014-08-21)

* **API change**: Any object with a valid `toString` method can be formatted with `'%s'` (#7)

v1.0.9 (2013-12-15)

* Round numbers when they're truncated. (#6)

v1.0.8 (2013-10-08)

* Remove trailing decimal point if there are no following digits (#6)

v1.0.7 (2013-05-07)

* Update for new dart version

v1.0.6 (2013-04-16)

* Update for new dart version

v1.0.5 (2013-03-25)

* Fixed dependencies example in README (#5)

v1.0.4 (2013-03-21)

* Update for new dart version

* Update for new pubspec format

v1.0.3 (2013-02-12)

* Update for dart M2

v1.0.2 (2013-01-21)

* Pubspec and whitespace fixes

v1.0.1 (2012-11-12)

* Update for new dart version

v1.0.0 (2012-10-08)

First release with semver

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add sprintf
pubspec.yaml
name: sprintf
version: 7.0.0
description: Dart implementation of sprintf. Provides simple printf like
  formatting such as sprintf("hello %s", ["world"]);
homepage: https://github.com/Naddiseo/dart-sprintf

environment:
  sdk: ">=2.12.0-0 <3.0.0"

dev_dependencies:
  test: ^1.16.0-nullsafety.13
  lints: ^1.0.1

Version history

VersionPublishedArchiveSHA-256
1.0.0-alpha12012-10-08T19:35:30.494780ZDownloada6728ba204ecb49c429c04c68e1b31b5b64f6156d6a2a5894c0a1bcbf07ae081
1.0.12012-11-16T01:16:45.504950ZDownload61082cd04d7208d6a91a00bad9f33de612a3e4371095fdb7311b342b5c906598
1.0.22013-02-12T01:50:59.086290ZDownload7f7da7aedc8b4ff113109853e9996e59049367c8f33e660a31cbf40ed4b36e80
1.0.32013-02-12T23:50:35.241910ZDownload91c5252f0c4dddccd98e54c31afea0e086e8a8769a6187b5ae48a74d2db1c10b
1.0.42013-03-21T22:48:34.480090ZDownload23567a5a7d33843072459de359fab3c8d0203d5d9a7129191301b2d3484ce230
1.0.52013-03-29T01:06:13.727900ZDownloada7f26d36ae0a91585795abdd2847decd9520a84c6ea5b2a3e832eb7f5e8373e5
1.0.62013-04-16T18:26:56.574660ZDownload378e7458b9bacc3d9a83f43127f8f424c38f218c33898127923a92aaf67f9b2b
1.0.72013-05-07T14:16:55.132720ZDownload1ba6bbb7965bcaf65c1b69da602e67da43f505b79b759f1734d15dc760e76fc6
1.0.82013-10-09T02:22:49.721890ZDownloaddd5354baedf4f99f26f26554818865b55c2cc3293d23a25552266085177df63b
3.0.02017-04-20T19:48:24.042407ZDownload192621df191c2a6941c66faa85393cb78ba36d6a485d3f4ec879674a22fa6196
3.0.12017-08-18T00:53:53.384314ZDownloadfbce46f6b4fd4fe29e5510dd6ab56352adf0d6c8d9157618dcfc636e096b4aa3
3.0.22017-08-18T00:58:09.924975ZDownloadc1488c526197d5f0cf7a891c837a82e20b7949586ba2913e9647eeb6285c66c4
4.0.02018-07-28T18:56:42.828034ZDownload99f2e3976984e160d5c79427b797cd7ba0e03b20aa5ec2ce028429d1f85379f2
4.0.12019-02-19T16:13:43.336115ZDownload4f4023cc4c9a0c61220a6210d96ed9f1de64be11fefd0692d6c1883b90b6f7d5
4.0.22019-02-20T04:04:09.513950ZDownloadfc340e40d0e285fb074588a555017cc73789b5ff7b4726151b055494dd02a991
4.0.32020-07-26T17:36:25.151994ZDownload55e2bb7229c63723f5b66062ed07b80e6be014f71640bb6af6c95f1a50b6bfdd
4.1.02020-07-26T18:18:53.715786ZDownloade5b1c200ad13904bf3a5d4b1a969cfa3fb3ca7f8a46a6af50b614c14afbb1625
5.0.02020-09-26T02:03:09.537290ZDownloadb6041625ba960702d833168e86f8ab7cbf1c0f45258b76d2c61654121b71c27a
6.0.0-nullsafety2020-12-10T15:57:26.944161ZDownloadf21cf219f13c5f44be6eba988308851eb4b6ecb346ef3ff4c0860a38d3c5c03c
6.0.02021-03-04T15:28:53.906544ZDownload936056f5ed53a4c69a1446b78434a24b9264cac67da4c98b39403e8f5d9fc526
6.0.22022-08-10T19:58:07.841038ZDownloadec76d38910b6f1c854ce1353c62d37e7ef82b53dc5ab048c25400d35970776d1
7.0.02022-09-30T16:45:36.337606ZDownload1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23

Dependencies

No direct dependencies declared.