Skip to content

Commit

Permalink
Merge 30ed398 into 7e4144e
Browse files Browse the repository at this point in the history
  • Loading branch information
10xLaCroixDrinker committed Nov 8, 2019
2 parents 7e4144e + 30ed398 commit 92b58b9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
@@ -1,9 +1,9 @@
language: node_js
sudo: false
node_js:
- "4"
- "5"
- "6"
- "8"
- "10"
- "12"
- "node"
script:
- "npm run lint"
Expand Down
25 changes: 13 additions & 12 deletions index.js
Expand Up @@ -83,15 +83,15 @@ function createWriterHandlers(extras, recordMap, predicate) {
}

var handlers = transit.map([
Immutable.Map, transit.makeWriteHandler({
Immutable.OrderedMap, transit.makeWriteHandler({
tag: function() {
return 'iM';
return 'iOM';
},
rep: mapSerializer
}),
Immutable.OrderedMap, transit.makeWriteHandler({
Immutable.Map, transit.makeWriteHandler({
tag: function() {
return 'iOM';
return 'iM';
},
rep: mapSerializer
}),
Expand All @@ -117,9 +117,9 @@ function createWriterHandlers(extras, recordMap, predicate) {
return v.toArray();
}
}),
Immutable.Set, transit.makeWriteHandler({
Immutable.OrderedSet, transit.makeWriteHandler({
tag: function() {
return "iS";
return "iOS";
},
rep: function(v) {
if (predicate) {
Expand All @@ -128,9 +128,9 @@ function createWriterHandlers(extras, recordMap, predicate) {
return v.toArray();
}
}),
Immutable.OrderedSet, transit.makeWriteHandler({
Immutable.Set, transit.makeWriteHandler({
tag: function() {
return "iOS";
return "iS";
},
rep: function(v) {
if (predicate) {
Expand All @@ -152,11 +152,11 @@ function createWriterHandlers(extras, recordMap, predicate) {
return 'iM';
},
rep: function(m) {
if (!('toMap' in m)) {
var e = "Error serializing unrecognized object " + m.toString();
throw new Error(e);
if ((Immutable.isImmutable && Immutable.isImmutable(m)) || ('toMap' in m)) {
return mapSerializer(Immutable.Map(m));
}
return mapSerializer(m.toMap());
var e = "Error serializing unrecognized object " + m.toString();
throw new Error(e);
}
})
]);
Expand Down Expand Up @@ -205,6 +205,7 @@ function invalidExtras(data, msg) {

function recordName(record) {
/* eslint no-underscore-dangle: 0 */
/* istanbul ignore next */
return record._name || record.constructor.name || 'Record';
}

Expand Down
10 changes: 6 additions & 4 deletions package.json
Expand Up @@ -4,9 +4,11 @@
"description": "Transit serialisation for Immutable.js",
"main": "index.js",
"scripts": {
"test": "mocha",
"test:3": "npm install --no-save immutable@^3.7.4 && mocha",
"test:4": "npm install --no-save immutable@^4.0.0-rc.12 && mocha",
"test": "npm run test:3 && npm run test:4",
"lint": "eslint .",
"coverage": "istanbul cover _mocha --"
"coverage": "nyc npm test && nyc report --reporter=lcov --reporter=json"
},
"repository": {
"type": "git",
Expand All @@ -27,9 +29,9 @@
"chai-immutable": "^1.2.0",
"coveralls": "^2.11.2",
"eslint": "^0.24.1",
"immutable": "^3.7.4",
"istanbul": "^0.3.14",
"immutable": ">=3.7.4",
"mocha": "^2.2.5",
"nyc": "^14.1.1",
"transit-js": "^0.8.807"
}
}

0 comments on commit 92b58b9

Please sign in to comment.