Contributing: Added G7 "Standard Methods"
This commit is contained in:
parent
e4cf84519d
commit
f6c7ec5d22
@ -105,6 +105,19 @@ DON'T:
|
|||||||
var bufferUtil = require('./util/buffer');
|
var bufferUtil = require('./util/buffer');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### G7 - General: Standard Methods
|
||||||
|
|
||||||
|
When possible, bitcore objects should have standard methods on an instance prototype:
|
||||||
|
* `toObject` - A plain JavaScript object that can be JSON stringified
|
||||||
|
* `toJSON` - A JSON stringified object of the instance
|
||||||
|
* `toString` - A string representation of the instance
|
||||||
|
* `toBuffer` - A hex Buffer
|
||||||
|
|
||||||
|
These should have a matching static method that can be used for instantiation:
|
||||||
|
* `fromJSON` - Should handle both JSON from `toJSON` and plain JavaScript object from `toObject`
|
||||||
|
* `fromString` - Should be able to instantiate with output from `toString`
|
||||||
|
* `fromBuffer` - Should likewise be able to instantiate from output from `toBuffer`
|
||||||
|
|
||||||
### E1 - Errors: Use bitcore.Errors
|
### E1 - Errors: Use bitcore.Errors
|
||||||
|
|
||||||
We've designed a structure for Errors to follow and are slowly migrating to it.
|
We've designed a structure for Errors to follow and are slowly migrating to it.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user