urbit-ob, but in Dart #
This is urbit-ob but in dart, and only implementing the functions I care about:
- works in VM & JS runtimes
- test suite that matches urbit-ob
import 'package:urbit_ob/urbit_ob.dart' as ob; final point = BigInt.from(19268096); final data = BigInt.from(2884880786); final name = "~bosnyt-raddux"; // patp assert(ob.patp(point) == name); assert(ob.patp2dec(name) == point); // patq assert(ob.patq(encodeBigInt(data)) == name); assert(ob.patq2buf(name) == encodeBigInt(data));
idk how to encode strings that match BN.js's encoding, so string patqs won't be compatible between dart and js until that works
for example, if you encode 'hello world' as a utf8 byte list in dart, you'll get
utf8.encode('hello world'); // -> [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
but when you encode a string as a byte array using BN.js you get
new BN('hello world').toArray() // -> [ 4, 86, 168, 105, 235 ]
look they work in the vm!
pub run test
whoa, they work in chrome!
puh run test -p chrome
- Initial version, created by Stagehand
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: urbit_ob: ^1.0.0
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.1
- pana: 0.13.6
lib/src/urbit_ob_base.dart. (-0.50 points)
lib/src/urbit_ob_base.dart reported 1 hint:
line 10 col 14: The declaration '_log' isn't referenced.
dartfmt to format
dartfmt to format
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
urbit_ob.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
The package description is too short. (-8 points)
Add more detail to the
description field of
pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.