Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jest-serializer module #5609

Merged
merged 3 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address feedback: "package.json" + "README.md"
  • Loading branch information
Miguel Jimenez Esun committed Feb 19, 2018
commit ea468e53a3c4882b36fc9970fed755ca48b752a9
18 changes: 9 additions & 9 deletions packages/jest-serializer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ memory. This is useful when willing to transfer over HTTP, TCP or via UNIX
pipes.

```javascript
import serializer from 'jest-serializer';
import {serialize, deserialize} serializer from 'jest-serializer';

const myObject = {
foo: 'bar',
baz: [0, true, '2', [], {}],
};

const buffer = serializer.serialize(myObject);
const myCopyObject = serializer.deserialize(buffer);
const buffer = serialize(myObject);
const myCopyObject = deserialize(buffer);
```

### Synchronous persistent filesystem: `readFileSync` and `writeFileSync`
Expand All @@ -40,7 +40,7 @@ This set of functions allow to send to disk a serialization result and retrieve
it back, in a synchronous way. It mimics the `fs` API so it looks familiar.

```javascript
import serializer from 'jest-serializer';
import {readFileSync, writeFileSync} serializer from 'jest-serializer';

const myObject = {
foo: 'bar',
Expand All @@ -49,8 +49,8 @@ const myObject = {

const myFile = '/tmp/obj';

serializer.writeFileSync(myFile, myObject);
const myCopyObject = serializer.readFileSync(myFile);
writeFileSync(myFile, myObject);
const myCopyObject = readFileSync(myFile);
```

### Asynchronous persistent filesystem: `readFile` and `writeFile`
Expand All @@ -59,7 +59,7 @@ Pretty similar to the synchronous one, but providing a callback. It also mimics
the `fs` API.

```javascript
import serializer from 'jest-serializer';
import {readFile, writeFile} from 'jest-serializer';

const myObject = {
foo: 'bar',
Expand All @@ -68,13 +68,13 @@ const myObject = {

const myFile = '/tmp/obj';

serializer.writeFile(myFile, myObject, (err) => {
writeFile(myFile, myObject, (err) => {
if (err) {
console.error(err);
return;
}

serializer.readFile(myFile, (err, data) => {
readFile(myFile, (err, data) => {
if (err) {
console.error(err);
return;
Expand Down
5 changes: 1 addition & 4 deletions packages/jest-serializer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
"url": "https://github.com/facebook/jest.git"
},
"license": "MIT",
"main": "build/index.js",
"dependencies": {
"merge-stream": "^1.0.1"
}
"main": "build/index.js"
}