Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"jsxBracketSameLine": false,
"printWidth": 80,
"parser": "typescript",
"singleQuote": true,
"trailingComma": "all"
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const data = {

// Serialization
const json = serialize(data)
// json == '{"x":{"__iterable":"Map","data":[["y",{"__iterable":"List","data":[1,2,3]"}]]}}'
// json == '{"x":{"__collection":"Map","data":[["y",{"__collection":"List","data":[1,2,3]"}]]}}'

// Deserialize
const result = deserialize(json)
Expand Down Expand Up @@ -108,6 +108,7 @@ NOTE: When an unknown Immutable iterable type is encountered during deserializat
- `json`: A JSON representation of data.
- `options={}`: Deserialization options.
- `recordTypes={}`: `immutable.Record` factories.
- `throwOnMissingRecordType=true`: Creates an `AnonymousRecord` for missing RecordTypes with all decoded data keys.

Return value:

Expand Down
42 changes: 32 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
{
"name": "json-immutable",
"version": "0.4.0",
"main": "lib/index",
"version": "1.0.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"prepublish": "babel src/ -d lib/",
"test": "npm run prepublish && ava"
"build": "tsc",
"lint-fix": "tslint -c ./tslint.json --project ./tsconfig.json --fix",
"lint": "tslint -c ./tslint.json --project ./tsconfig.json",
"prettier": "prettier \"{src,test}/**/*.{js,jsx,ts,tsx}\" --write",
"test": "npm run build && ava",
"typecheck": "tsc --noEmit --listFiles false"
},
"lint-staged": {
"{src}/**/*.{ts,tsx}": [
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "echo 'Running TSLint' && npm run lint && echo 'Running Typechecks' && npm run typecheck"
}
},
"peerDependencies": {
"immutable": "3.x.x"
"immutable": "^4.0.0-rc.12"
},
"dependencies": {
"json-stream-stringify": "1.5.x"
"@types/node": "^11.10.0",
"json-stream-stringify": "^1.5.x"
},
"devDependencies": {
"ava": "0.16.x",
"babel-cli": "6.14.x",
"babel-preset-es2015": "6.14.x",
"immutable": "3.8.x"
"ava": "^1.2.1",
"husky": "^1.3.1",
"immutable": "^4.0.0-rc.12",
"lint-staged": "^8.1.5",
"prettier": "^1.16.4",
"tslint": "^5.13.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.3.3333"
},
"repository": {
"type": "git",
Expand Down
71 changes: 0 additions & 71 deletions src/deserialize.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/deserialize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DeserializationOptions } from './types/options';
import { decodeData } from './utils/decoders';

export function deserialize(
json: string,
options: DeserializationOptions = {},
) {
return JSON.parse(json, (key, value) => {
return decodeData(key, value, options);
});
}
43 changes: 0 additions & 43 deletions src/helpers/native-type-helpers.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/index.js

This file was deleted.

6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './deserialize';
export * from './serialize';

export * from './types/options';
export * from './types/serializedData';
export * from './types/collectionTypes';
Loading