https://github.com/wanadev/abitbol-serializable
Serializable classes based on Abibol classes
https://github.com/wanadev/abitbol-serializable
Last synced: about 2 months ago
JSON representation
Serializable classes based on Abibol classes
- Host: GitHub
- URL: https://github.com/wanadev/abitbol-serializable
- Owner: wanadev
- License: other
- Created: 2016-02-01T09:06:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T07:47:43.000Z (about 1 year ago)
- Last Synced: 2024-04-23T09:50:26.799Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://wanadev.github.io/abitbol-serializable/
- Size: 342 KB
- Stars: 0
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# abitbol-serializable
[](https://github.com/wanadev/abitbol-serializable/actions/workflows/node-ci.yml)
[](https://www.npmjs.com/package/abitbol-serializable)
[](https://github.com/wanadev/abitbol-serializable/blob/master/LICENSE)
[](https://discord.gg/BmUkEdMuFp)**Abitbol Serializable** is an [abitbol][] class that can serialize its
properties.**Features:**
* Serialize / Unserialize all computed properties that have a getter and
a setter,
* Skip properties annotated with `"@serializable false"`.
* Use custom serialization function for specific properties.**Example Class:**
```javascript
var SerializableClass = require("abitbol-serializable");var Person = SerializableClass.$extend({
__name__: "Person", // The class name
__init__: function(params) {
this.$data.firstName = "John";
this.$data.lastName = "DOE";
this.$data.age = 0;
this.$super(params);
},getFirstName: function() {
return this.$data.firstName;
},setFirstName: function(firstName) {
this.$data.firstName = firstName;
},getLastName: function() {
return this.$data.lastName;
},setLastName: function(lastName) {
this.$data.lastName = lastName;
},getAge: function() {
"@serializable false";
return this.$data.age;
},setAge: function(age) {
this.$data.age = age;
}});
```**Example Serialization:**
```javascript
var john = new Person({
lastName: "Wayne",
age: 72
});john.serialize();
// -> {
// __name__: "Person",
// id: "",
// firstName: "John",
// lastName: "Wayne"
// }
```[abitbol]: https://github.com/wanadev/abitbol
## Install
To install Abitbol Serializable run the following command:
npm install abitbol-serializable
## Documentation
* https://wanadev.github.io/abitbol-serializable/
## Contributing
### Questions
If you have any question, you can:
* [Open an issue on GitHub][gh-issue]
* [Ask on discord][discord]### Bugs
If you found a bug, please [open an issue on Github][gh-issue] with as much information as possible.
### Pull Requests
Please consider [filing a bug][gh-issue] before starting to work on a new feature. This will allow us to discuss the best way to do it. This is of course not necessary if you just want to fix some typo or small errors in the code.
### Coding Style / Lint
To check coding style, run the follwoing command:
npm run lint
### Tests
Tu run tests, use the following command:
npm run test
[gh-issue]: https://github.com/wanadev/abitbol-serializable/issues
[discord]: https://discord.gg/BmUkEdMuFp## Changelog
* **[NEXT]** (changes on master that have not been released yet):
* Nothing yet ;)
* **v2.1.0:**
* feat: Removed dependency to the uuid library. Use browser/Node's secure implementation if available, or a fallback one else (@flozz)
* feat: Only include used parts of lodash instead of the whole library (@flozz)* **v2.0.2:**
* feat: Added TypeScript type declaration for SerializableClass and serializer (@Pduhard, #26)
* misc: Updated dev dependencies (@dependabot)* **v2.0.1:**
* Updated dependencies (@jbghoul, #12)
* **v2.0.0:**
* Updates `abitbol` dependency to 2.0.0
* **v1.0.2:**
* Documentation site
* **v1.0.1:**
* Updates `uuid` dependency to 3.0.0
* **v1.0.0:**
* Initial release