serialijse
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "serialijse", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "serialize and deserialize your javascript objects, preserve your object model ", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"pretest": "browserify index.js --standalone serialijse > dist/serialijse.bundle.js && uglifyjs2 dist/serialijse.bundle.js -o dist/serialijse.bundle.min.js", | ||
"test": "mocha -R spec" | ||
"test": "mocha -R spec && mocha-phantomjs -R spec test_html/demo.html" | ||
}, | ||
@@ -42,3 +42,4 @@ "repository": { | ||
"underscore": "^1.6.0" | ||
} | ||
}, | ||
"types": "./lib/serialijse.d.ts" | ||
} |
@@ -37,3 +37,29 @@ serialijse | ||
Using serialijse in browser | ||
---------------------------- | ||
* install serialijse component: | ||
````sh | ||
bower install serialijse | ||
```` | ||
* in your html file: | ||
```html | ||
<script src="components/serialijse/dist/serialijse.bundle.js"> | ||
<script> | ||
var serialize = serialijse.serialize; | ||
var deserialize = serialijse.deserialize; | ||
var declarePersistable = serialijse.declarePersistable; | ||
var serializeZ = serialijse.serializeZ; | ||
var deserializeZ = serialijse.deserializeZ; | ||
var vehicule = new Vehicule(); | ||
... | ||
var serializationString = serialize(vehicule); | ||
... | ||
var reconstructedObject = deserialize(serializationString); | ||
</script> | ||
``` | ||
Examples | ||
@@ -154,1 +180,33 @@ ======== | ||
``` | ||
TypeScript example | ||
------------------ | ||
```TypeScript | ||
import * as serialijse from "serialijse"; | ||
class Greeter { | ||
constructor( | ||
private myName: string | ||
) {} | ||
greet(name: string): void { | ||
console.log(`${this.myName} says: Hello ${name}`); | ||
} | ||
} | ||
let greeter = new Greeter('Spock'); | ||
greeter.greet('Scotty'); | ||
// serialize | ||
serialijse.declarePersistable(Greeter); | ||
let greeterJson: string = serialijse.serialize(greeter); | ||
// deserialize | ||
serialijse.declarePersistable(Greeter); // not necessary in this example, but needed if deserializing in a new js context | ||
let greeter1: Greeter = serialijse.deserialize<Greeter>(greeterJson); | ||
greeter1.greet('Jean-Luc'); | ||
``` | ||
/*global describe, it*/ | ||
var Should; | ||
if(typeof require !== "undefined") { | ||
var should = require("should"); | ||
Should = require("should"); | ||
var serialijse = require("../"); | ||
} else { | ||
var should = Should; | ||
} | ||
Should(true).eql(true); | ||
var serialize = serialijse.serialize; | ||
@@ -15,2 +18,6 @@ var deserialize = serialijse.deserialize; | ||
(function () { | ||
"use strict"; | ||
@@ -34,2 +41,4 @@ | ||
it("should persist a simple javascript object", function () { | ||
@@ -102,3 +111,3 @@ | ||
should(the_vehicule.____index).eql(undefined); | ||
Should(the_vehicule.____index).eql(undefined); | ||
@@ -266,3 +275,3 @@ var expected = '[['+ | ||
should(function(){ | ||
Should(function(){ | ||
JSON.stringify(mark); | ||
@@ -269,0 +278,0 @@ }).throwError(); // Circular |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
807610
18
19490
211
0