@the-grid/immutable
Advanced tools
Comparing version
@@ -129,2 +129,4 @@ 'use strict'; | ||
var schemaKeys = []; | ||
for (var keyPath in schema) { | ||
@@ -138,2 +140,5 @@ | ||
} | ||
schemaKeys.push(keyPath); | ||
//if (keyPath === 'DEBUG') { | ||
@@ -245,2 +250,3 @@ // DEBUG = keyConfig | ||
var _set = RecordType.prototype.set; | ||
var _toJS = RecordType.prototype.toJS; | ||
@@ -419,2 +425,19 @@ var StructType = function (_RecordType) { | ||
// toJS( includeComputed = false ) | ||
// --------------------------------------------------- | ||
StructType.prototype.toJS = function toJS(includeComputed) { | ||
if (!includeComputed) return _toJS.call(this); | ||
var result = {}; | ||
for (var i = 0; i < schemaKeys.length; i++) { | ||
var key = schemaKeys[i]; | ||
var val = this.get(key); | ||
result[key] = val.toJS ? val.toJS(includeComputed) : val; | ||
} | ||
return result; | ||
}; | ||
return StructType; | ||
@@ -443,2 +466,5 @@ }(RecordType); | ||
StructType.schema = schema; | ||
//StructType.cacheReset = cacheReset | ||
return StructType; | ||
@@ -445,0 +471,0 @@ }; |
{ | ||
"name": "@the-grid/immutable", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Describe struct here", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -20,3 +20,2 @@ # @the-grid/immutable | ||
[coveralls-badge]: https://img.shields.io/coveralls/user/repo/master.svg?style=flat-square | ||
[coveralls]: https://coveralls.io/github/user/repo | ||
[coveralls]: https://coveralls.io/github/user/repo |
30664
3.77%9
12.5%655
2.66%20
-9.09%